forked from OSGeo/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (117 loc) · 5.22 KB
/
Copy pathadditional_checks.yml
File metadata and controls
128 lines (117 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
name: Additional Checks
# Checks which are not in standardized tools such as custom checks by scripts
# in the source code or small 3rd party checks without large projects behind them.
# Number of disconnected, but simple checks can be combined into one workflow
# (and job) to reduce the number of jobs.
on:
push:
branches:
- main
- releasebranch_*
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
permissions: {}
jobs:
additional-checks:
name: Additional checks
runs-on: ubuntu-24.04
permissions:
contents: read
env:
# renovate: datasource=pypi depName=prek
PREK_VERSION: 0.3.4
steps:
- name: Checkout repository contents
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 31
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.14"
- name: Install uv and restore its cache
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1
with:
# To not have the last commit JSON and release notes files affected on
# releases, if copying the contents displayed in the CI logs.
enable-cache: false
- name: Check that files with the same content are the same
run: |
diff Dockerfile docker/ubuntu/Dockerfile
- name: Generate core modules with last commit JSON file and test it
run: |
python -m pip install pytest pytest-depends pytest-timeout
python utils/generate_last_commit_file.py .
pytest utils/test_generate_last_commit_file.py
- name: Generate release notes using git log
run: |
python -m pip install PyYAML requests
# Git works without any special permissions.
# Using current branch or the branch against the PR is open.
# Using the last 30 commits (for branches, tags, and PRs).
# End is the current (latest) commit.
python ./utils/generate_release_notes.py log \
"${GITHUB_REF_NAME}" \
"$(git rev-parse HEAD~30)" \
"" | \
tee -a "release_notes_sample.md"
- name: Upload release notes and core modules with last commit JSON file
if: ${{ !cancelled() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: release_notes-core_modules_with_last_commit
path: |-
core_modules_with_last_commit.json
release_notes_sample.md
- name: Remove created files
run: rm --verbose -f release_notes_sample.md core_modules_with_last_commit.json
- name: "Cache pre-commit/prek"
# Not used for releases, only for running pre-commit
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 # zizmor: ignore[cache-poisoning]
with:
path: |-
~/.cache/prek
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install prek
run: uv tool install "prek@${PREK_VERSION}"
- name: "Run pre-commit/prek for fixes"
run: |
echo '```console' > "$GITHUB_STEP_SUMMARY"
# Enable color output for pre-commit and remove it for the summary
# Use --hook-stage=manual to enable slower pre-commit hooks that are skipped by default
# Skip hooks already handled in another workflow, to avoid duplicate suggestions
# Skip hooks with no fixes made with these hooks (for now)
prek run --all-files --show-diff-on-failure --color=always --hook-stage=manual \
--skip ruff-check --skip ruff-format \
--skip actionlint \
--skip editorconfig-checker \
--skip flake8 \
--skip yamllint | \
tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> "$GITHUB_STEP_SUMMARY") >&1
exit_code="${PIPESTATUS[0]}"
echo '```' >> "$GITHUB_STEP_SUMMARY"
exit "$exit_code"
- name: Create and uploads code suggestions to apply for pre-commit
# Will fail fast here if there are changes required
id: diff-pre-commit
# To run after pre-commit step exits with failure
if: ${{ !cancelled() }}
uses: ./.github/actions/create-upload-suggestions
with:
tool-name: pre-commit
# To keep repo's file structure in formatted changes artifact
extra-upload-changes: pyproject.toml
- name: "Run pre-commit/prek"
run: |
echo '```console' > "$GITHUB_STEP_SUMMARY"
# Enable color output for pre-commit and remove it for the summary
# Use --hook-stage=manual to enable slower pre-commit hooks that are skipped by default
prek run --all-files --show-diff-on-failure --color=always --hook-stage=manual | \
tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> "$GITHUB_STEP_SUMMARY") >&1
exit_code="${PIPESTATUS[0]}"
echo '```' >> "$GITHUB_STEP_SUMMARY"
exit "$exit_code"