Skip to content

Commit 439bba1

Browse files
committed
ci: consolidate and improve GitHub Actions workflows
- Merge test_accuracy.yml and test_precommit.yml into pre_commit.yml - Add concurrency control to prevent duplicate workflow runs - Unify security scans to handle both PRs and scheduled runs - Move permissions to workflow level with job-level overrides - Standardize YAML formatting and schedule cron times - Use YAML anchors to reduce duplication in pre_commit.yml - Update deprecated set-output syntax to use GITHUB_OUTPUT - Simplify CodeQL matrix by moving build-mode to step level - Pin uv version to 0.9.27 for reproducibility - Add blank lines between steps for improved readability - Replace regex-match action with native bash Signed-off-by: mramotowski <maciej.ramotowski@intel.com>
1 parent 7a37fea commit 439bba1

12 files changed

Lines changed: 182 additions & 234 deletions

.github/workflows/codeql.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ name: "CodeQL Scan"
22

33
on:
44
push:
5-
branches: ["master"]
5+
branches:
6+
- "master"
67
pull_request:
7-
branches: ["master"]
8+
branches:
9+
- "master"
810
schedule:
9-
- cron: "37 3 * * 0"
11+
- cron: "0 2 * * 0"
1012

1113
permissions: {} # No permissions by default on workflow level
1214

@@ -16,18 +18,14 @@ jobs:
1618
runs-on: ubuntu-latest
1719
permissions:
1820
security-events: write # required to publish sarif
19-
2021
strategy:
2122
fail-fast: false
2223
matrix:
2324
include:
2425
- language: actions
25-
build-mode: none
2626
- language: python
27-
build-mode: none
28-
2927
steps:
30-
- name: Checkout repository
28+
- name: Checkout code
3129
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3230
with:
3331
persist-credentials: false
@@ -37,7 +35,7 @@ jobs:
3735
uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
3836
with:
3937
languages: ${{ matrix.language }}
40-
build-mode: ${{ matrix.build-mode }}
38+
build-mode: none
4139
queries: security-extended
4240

4341
- name: Perform CodeQL Analysis

.github/workflows/collect-sbom-library.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Collect Library Licenses
22

33
on:
44
schedule:
5-
- cron: "0 2 * * 1" # Weekly on Monday
5+
- cron: "0 2 * * 0"
66
workflow_dispatch:
77

8-
permissions: {}
8+
permissions: {} # No permissions by default on workflow level
99

1010
jobs:
1111
collect-licenses:

.github/workflows/docs.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
11
name: Build Docs
2-
permissions: {} # No permissions by default on workflow level
32

43
on:
54
workflow_dispatch: # run on request (no need for PR)
65
push:
76
branches:
87
- master
98

9+
permissions: {} # No permissions by default on workflow level
10+
1011
jobs:
1112
Build-Docs:
12-
runs-on: ubuntu-24.04
13+
runs-on: ubuntu-latest
1314
permissions:
1415
contents: write
1516
steps:
16-
- name: Checkout repository
17+
- name: Checkout code
1718
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1819
with:
1920
persist-credentials: false
21+
2022
- name: Set up Python
2123
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
2224
with:
2325
python-version-file: ".python-version"
26+
2427
- name: Install uv
2528
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
29+
with:
30+
version: "0.9.27"
31+
2632
- name: Install dependencies
2733
run: |
2834
uv sync --locked --extra docs
35+
2936
- name: Build Docs
30-
run: |
31-
cd docs
32-
uv run make html
37+
working-directory: docs
38+
run: uv run make html
39+
3340
- name: Branch name
3441
id: branch_name
35-
shell: bash
3642
run: |
37-
echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/}
43+
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
44+
3845
- name: Create gh-pages branch
3946
env:
4047
SOURCE: ${{steps.branch_name.outputs.SOURCE_NAME}}
@@ -67,6 +74,7 @@ jobs:
6774
else
6875
echo "Branch gh-pages already exists"
6976
fi
77+
7078
- name: Commit docs to gh-pages branch
7179
env:
7280
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
@@ -88,6 +96,7 @@ jobs:
8896
git add ./latest "$RELEASE_VERSION"
8997
git add index.html
9098
git commit -m "Update documentation" -a || true
99+
91100
- name: Push changes
92101
uses: ad-m/github-push-action@57116acb309081ee57864270b0e3c4cedbe45452
93102
with:

.github/workflows/pr-labeler.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
#####
55

66
name: "Pull Request Labeler"
7-
permissions: {} # No permissions by default on workflow level
7+
88
on:
99
- pull_request_target # zizmor: ignore[dangerous-triggers]
1010

11+
permissions: {} # No permissions by default on workflow level
12+
1113
jobs:
1214
labeler:
1315
permissions:

.github/workflows/pre_commit.yml

Lines changed: 99 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,123 @@
11
name: Pre-Commit Checks
2-
permissions: {} # No permissions by default on workflow level
32

43
on:
5-
push:
4+
pull_request:
5+
merge_group:
66
branches:
77
- master
8-
pull_request:
9-
types:
10-
- opened
11-
- reopened
12-
- synchronize
13-
- ready_for_review
148
workflow_dispatch: # run on request (no need for PR)
159

10+
permissions: {} # No permissions by default on workflow level
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
1616
jobs:
17-
Code-Quality-Checks:
18-
runs-on: ubuntu-24.04
17+
code_quality_checks:
18+
runs-on: ubuntu-latest
1919
steps:
20-
- name: CHECKOUT REPOSITORY
20+
- &checkout
21+
name: Checkout code
2122
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2223
with:
2324
persist-credentials: false
25+
2426
- name: Set up Python
2527
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
2628
with:
2729
python-version-file: ".python-version"
30+
2831
- name: Install uv
2932
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
33+
with:
34+
enable-cache: false
35+
version: "0.9.27"
36+
3037
- name: Install dependencies
31-
run: |
32-
uv sync --locked --all-extras
38+
run: uv sync --locked --all-extras
39+
3340
- name: Run pre-commit checks
34-
run: |
35-
uvx pre-commit run --all-files
36-
Unit-Tests:
37-
runs-on: ubuntu-24.04
41+
run: uvx pre-commit run --all-files
42+
43+
accuracy-tests:
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
os:
48+
- "ubuntu-latest"
49+
- "windows-latest"
50+
python-version:
51+
- "3.10"
52+
- "3.11"
53+
- "3.12"
54+
- "3.13"
55+
runs-on: ${{ matrix.os }}
3856
steps:
39-
- name: CHECKOUT REPOSITORY
40-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
41-
with:
42-
persist-credentials: false
43-
- name: Set up Python
44-
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
45-
with:
46-
python-version-file: ".python-version"
47-
- name: Install uv
57+
- *checkout
58+
59+
- &matrix-setup-uv
60+
name: Install uv
4861
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
49-
- name: Install dependencies
50-
run: |
51-
uv sync --locked --extra tests
62+
with:
63+
enable-cache: false
64+
python-version: ${{ matrix.python-version }}
65+
version: "0.9.27"
66+
67+
- &install-dependencies
68+
name: Install dependencies
69+
run: uv sync --locked --extra tests --extra-index-url https://download.pytorch.org/whl/cpu
70+
71+
- name: Prepare test data
72+
run: uv run python tests/accuracy/download_models.py -d data -j tests/accuracy/public_scope.json -l
73+
74+
- name: Run Python Test
75+
run: uv run pytest --data=./data tests/accuracy/test_accuracy.py
76+
77+
unit-functional-tests:
78+
strategy:
79+
fail-fast: false
80+
matrix:
81+
os:
82+
- "ubuntu-24.04"
83+
- "windows-2022"
84+
python-version:
85+
- "3.10"
86+
- "3.11"
87+
- "3.12"
88+
- "3.13"
89+
name: unit & functional tests (${{ matrix.os }}, Python ${{ matrix.python-version }})
90+
runs-on: ${{ matrix.os }}
91+
steps:
92+
- *checkout
93+
94+
- *matrix-setup-uv
95+
96+
- *install-dependencies
97+
5298
- name: Run python unit tests
99+
run: uv run pytest tests/unit --cov
100+
101+
- name: Prepare test data
53102
run: |
54-
uv run pytest tests/unit --cov
103+
uv run python tests/accuracy/download_models.py -d data -j tests/precommit/public_scope.json -l
104+
105+
- name: Run test
106+
run: |
107+
uv run pytest --data=./data tests/functional
108+
109+
pre-commit-result:
110+
runs-on: ubuntu-latest
111+
needs:
112+
- accuracy-tests
113+
- code_quality_checks
114+
- unit-functional-tests
115+
if: always()
116+
steps:
117+
- name: All tests ok
118+
if: ${{ !(contains(needs.*.result, 'failure')) }}
119+
run: exit 0
120+
121+
- name: Some tests failed
122+
if: ${{ contains(needs.*.result, 'failure') }}
123+
run: exit 1

.github/workflows/publish.yaml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,30 @@ jobs:
1212
name: Build
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Checkout
15+
- name: Checkout code
1616
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1717
with:
1818
persist-credentials: false
19+
1920
- name: Set up Python
2021
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
2122
with:
2223
python-version-file: ".python-version"
24+
2325
- name: Install pypa/build
24-
run: |
25-
uv sync --locked
26+
run: uv sync --locked
27+
2628
- name: Build sdist
27-
run: |
28-
uv build --sdist
29+
run: uv build --sdist
30+
2931
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
3032
with:
3133
name: artifact-sdist
3234
path: dist/*.tar.gz
35+
3336
- name: Build wheel
34-
run: |
35-
uv build --wheel
37+
run: uv build --wheel
38+
3639
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
3740
with:
3841
name: artifact-wheel
@@ -53,13 +56,19 @@ jobs:
5356
path: dist
5457
pattern: artifact-*
5558
merge-multiple: true
59+
5660
# to determine where to publish the package distribution to PyPI or TestPyPI
5761
- name: Check tag
5862
id: check-tag
59-
uses: actions-ecosystem/action-regex-match@9e6c4fb3d5e898f505be7a1fb6e7b0a278f6665b # v2.0.2
60-
with:
61-
text: ${{ github.ref }}
62-
regex: '^refs/tags/[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)+(\.[0-9]+rc[0-9]+|rc[0-9]+)?$'
63+
env:
64+
GITHUB_REF: ${{ github.ref }}
65+
run: |
66+
if [[ "${GITHUB_REF}" =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)+(\.[0-9]+rc[0-9]+|rc[0-9]+)?$ ]]; then
67+
echo "match=${GITHUB_REF}" >> $GITHUB_OUTPUT
68+
else
69+
echo "match=" >> $GITHUB_OUTPUT
70+
fi
71+
6372
- name: Upload package distributions to github
6473
if: ${{ steps.check-tag.outputs.match != '' }}
6574
uses: svenstaro/upload-release-action@6b7fa9f267e90b50a19fef07b3596790bb941741 # 2.11.3
@@ -69,9 +78,11 @@ jobs:
6978
tag: ${{ github.ref }}
7079
overwrite: true
7180
file_glob: true
81+
7282
- name: Publish package distributions to PyPI
7383
if: ${{ steps.check-tag.outputs.match != '' }}
7484
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
85+
7586
- name: Publish package distributions to TestPyPI
7687
if: ${{ steps.check-tag.outputs.match == '' }}
7788
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

.github/workflows/renovate-config-validator.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ on:
1717
paths:
1818
- ".github/renovate.json5"
1919

20-
permissions:
21-
contents: read
20+
permissions: {} # No permissions by default on workflow level
2221

2322
concurrency:
2423
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
@@ -27,8 +26,10 @@ concurrency:
2726
jobs:
2827
validate:
2928
runs-on: ubuntu-latest
29+
permissions:
30+
contents: read
3031
steps:
31-
- name: Checkout configuration
32+
- name: Checkout code
3233
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3334
with:
3435
persist-credentials: false

0 commit comments

Comments
 (0)