Skip to content

Commit dfe0edb

Browse files
authored
Merge pull request #278 from geotribu/ci/update-workflows
update(ci): modernize workflows setting GH token scopes and reporting improvements from templater
2 parents ca2b473 + 9a4e2fe commit dfe0edb

File tree

4 files changed

+44
-24
lines changed

4 files changed

+44
-24
lines changed

.github/workflows/documentation.yml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
name: "📚 Documentation"
22

3+
# Global environment variables
4+
env:
5+
CONDITION_IS_PUSH: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') }}
6+
CONDITION_IS_WORKFLOW_RUN: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }}
7+
PROJECT_FOLDER: qtribu
8+
PYTHON_VERSION: 3.12
9+
10+
# Allow one concurrent deployment per branch/pr
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
315
on:
416
push:
517
branches:
@@ -24,20 +36,13 @@ on:
2436
workflow_dispatch:
2537

2638
workflow_run:
39+
branches:
40+
- main
2741
workflows:
2842
- "📦 Packaging & 🚀 Release"
2943
types:
3044
- completed
3145

32-
# Allow one concurrent deployment per branch/pr
33-
concurrency:
34-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
35-
cancel-in-progress: true
36-
37-
env:
38-
PROJECT_FOLDER: "qtribu"
39-
PYTHON_VERSION: 3.9
40-
4146
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
4247
permissions:
4348
contents: read
@@ -59,6 +64,14 @@ jobs:
5964
cache-dependency-path: "requirements/documentation.txt"
6065
python-version: ${{ env.PYTHON_VERSION }}
6166

67+
- name: Cache Sphinx cache
68+
uses: actions/cache@v4
69+
with:
70+
path: docs/_build/cache
71+
key: ${{ runner.os }}-sphinx-${{ hashFiles('docs/**/*') }}
72+
restore-keys: |
73+
${{ runner.os }}-sphinx-
74+
6275
- name: Install dependencies
6376
run: |
6477
python -m pip install --upgrade pip setuptools wheel
@@ -70,13 +83,13 @@ jobs:
7083
- name: Save build doc as artifact
7184
uses: actions/upload-artifact@v6
7285
with:
86+
if-no-files-found: error
7387
name: documentation
7488
path: docs/_build/html/*
75-
if-no-files-found: error
7689
retention-days: 30
7790

7891
- name: Download artifact from build workflow
79-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
92+
if: ${{ env.CONDITION_IS_PUSH || env.CONDITION_IS_WORKFLOW_RUN }}
8093
uses: dawidd6/action-download-artifact@v12
8194
with:
8295
allow_forks: false
@@ -91,15 +104,15 @@ jobs:
91104

92105
- name: Setup Pages
93106
uses: actions/configure-pages@v5
94-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
107+
if: ${{ env.CONDITION_IS_PUSH || env.CONDITION_IS_WORKFLOW_RUN }}
95108

96109
- name: Upload artifact
97110
uses: actions/upload-pages-artifact@v4
98-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
111+
if: ${{ env.CONDITION_IS_PUSH || env.CONDITION_IS_WORKFLOW_RUN }}
99112
with:
100113
path: docs/_build/html/
101114

102115
- name: Deploy to GitHub Pages
103116
id: deployment
104-
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
117+
if: ${{ env.CONDITION_IS_PUSH || env.CONDITION_IS_WORKFLOW_RUN }}
105118
uses: actions/deploy-pages@v4

.github/workflows/linter.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
name: Python 🐍
2323

2424
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
2527

2628
steps:
2729
- name: Get source code

.github/workflows/packager.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ jobs:
3939
python-version: ${{ env.PYTHON_VERSION }}
4040
cache: "pip"
4141

42-
- name: Install system requirements
42+
- name: Install translation requirements
4343
run: |
4444
sudo apt update
4545
sudo apt install qt5-qmake qttools5-dev-tools
4646
python3 -m pip install -U pyqt5-tools
4747
4848
- name: Update translations
49-
run: pylupdate5 -noobsolete -verbose ${{ env.PROJECT_FOLDER }}/resources/i18n/plugin_translation.pro
49+
run: |
50+
python3 scripts/generate_translation_profile.py
51+
pylupdate5 -noobsolete -verbose ${{ env.PROJECT_FOLDER }}/resources/i18n/plugin_translation.pro
5052
5153
- name: Compile translations
5254
run: lrelease ${{ env.PROJECT_FOLDER }}/resources/i18n/*.ts
@@ -73,9 +75,9 @@ jobs:
7375
- name: Setup Python
7476
uses: actions/setup-python@v6
7577
with:
76-
python-version: ${{ env.PYTHON_VERSION }}
7778
cache: "pip"
7879
cache-dependency-path: "requirements/packaging.txt"
80+
python-version: ${{ env.PYTHON_VERSION }}
7981

8082
- name: Install project requirements
8183
run: |
@@ -88,9 +90,6 @@ jobs:
8890
name: translations-build
8991
path: ${{ env.PROJECT_FOLDER }}
9092

91-
- name: List files
92-
run: tree ${{ env.PROJECT_FOLDER }}
93-
9493
- name: Amend gitignore to include compiled translations and add it to tracked files
9594
run: |
9695
# include compiled translations
@@ -123,6 +122,8 @@ jobs:
123122
release:
124123
name: "🚀 Release on tag"
125124
runs-on: ubuntu-latest
125+
permissions:
126+
contents: write
126127
needs:
127128
- translation
128129

@@ -135,9 +136,9 @@ jobs:
135136
- name: Setup Python
136137
uses: actions/setup-python@v6
137138
with:
138-
python-version: ${{ env.PYTHON_VERSION }}
139139
cache: "pip"
140140
cache-dependency-path: "requirements/packaging.txt"
141+
python-version: ${{ env.PYTHON_VERSION }}
141142

142143
- name: Install project requirements
143144
run: |

.github/workflows/tester.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,24 @@ jobs:
3232
- name: Set up Python
3333
uses: actions/setup-python@v6
3434
with:
35-
python-version: ${{ env.PYTHON_VERSION }}
3635
cache: "pip"
3736
cache-dependency-path: "requirements/testing.txt"
37+
python-version: ${{ env.PYTHON_VERSION }}
3838

3939
- name: Install Python requirements
4040
run: |
4141
python -m pip install -U pip setuptools wheel
4242
python -m pip install -U -r requirements/testing.txt
4343
4444
- name: Run Unit tests
45-
run: pytest tests/unit/
45+
run: pytest -p no:qgis tests/unit/
4646

4747
- name: Upload coverage to Codecov
4848
uses: codecov/codecov-action@v5
49+
with:
50+
env_vars: PYTHON
51+
flags: unittests
52+
name: Code Coverage for unittests on Ubuntu.python-${{ env.PYTHON_VERSION }}]
4953

5054
test-qgis:
5155
runs-on: ubuntu-latest
@@ -81,7 +85,7 @@ jobs:
8185
python3 -m pip install -U -r requirements/testing.txt
8286
8387
- name: Run Unit tests
84-
run: pytest tests/qgis/
88+
run: pytest tests/qgis --junitxml=junit/test-results-qgis.xml --cov-report=xml:coverage-reports/coverage-qgis.xml
8589

8690
- name: Upload coverage to Codecov
8791
uses: codecov/codecov-action@v5

0 commit comments

Comments
 (0)