Skip to content

Commit d22a13d

Browse files
feature<gh-actions>: Initial commit with most of the groundwork (#52)
* feature<gh-actions>: Initial commit with most of the groundwork Co-authored-by: Nico Rikken <[email protected]> Signed-off-by: Raoul Linnenbank <[email protected]>
1 parent 2848eea commit d22a13d

File tree

12 files changed

+825
-3051
lines changed

12 files changed

+825
-3051
lines changed

.github/dependabot.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip"
9+
reviewers:
10+
- "rflinnenbank"
11+
directory: "/"
12+
schedule:
13+
interval: "weekly"
14+
groups:
15+
package-updates:
16+
applies-to: version-updates
17+
patterns: [ "*" ]
18+
19+
- package-ecosystem: "github-actions"
20+
directory: "/"
21+
reviewers:
22+
- "rflinnenbank"
23+
schedule:
24+
interval: "weekly"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Check if PR source branch is allowed for development or release branches
2+
3+
on:
4+
pull_request:
5+
types: [ opened, reopened, synchronize, edited, ready_for_review ]
6+
branches:
7+
- development
8+
- release/**
9+
10+
jobs:
11+
enforce:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check PR source branch
15+
env:
16+
HEAD_REF: ${{ github.head_ref }}
17+
run: |
18+
echo "Head branch: $HEAD_REF"
19+
if [[ "$HEAD_REF" =~ ^feature/ || "$HEAD_REF" =~ ^dev/feature/ ]]; then
20+
echo "✔ Allowed source branch."
21+
exit 0
22+
else
23+
echo "❌ Disallowed source branch: $HEAD_REF"
24+
echo "Only 'feature/*' or 'dev/feature/*' may open PRs into 'development' or 'release/*'."
25+
exit 1
26+
fi
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check if PR source branch is allowed for main branch
2+
3+
on:
4+
pull_request:
5+
types: [ opened, reopened, synchronize, edited, ready_for_review ]
6+
branches:
7+
- main
8+
9+
jobs:
10+
enforce:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
pull-requests: read
15+
steps:
16+
- name: Check PR source branch
17+
env:
18+
HEAD_REF: ${{ github.head_ref }}
19+
run: |
20+
echo "Head branch: $HEAD_REF"
21+
if [[ "$HEAD_REF" == "development" || "$HEAD_REF" =~ ^release/ || "$HEAD_REF" =~ ^hotfix/ ]]; then
22+
echo "✔ Allowed source branch."
23+
exit 0
24+
else
25+
echo "❌ Disallowed source branch: $HEAD_REF"
26+
echo "Only 'development', 'release/*', or 'hotfix/*' may open PRs into 'main'."
27+
exit 1
28+
fi
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: GitHub Pages Deployment
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'docs/**'
8+
- 'gh-pages-deployment.yaml'
9+
- 'README.md'
10+
workflow_dispatch:
11+
permissions:
12+
contents: write
13+
pages: write
14+
jobs:
15+
deploy-gh-pages:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Configure Git user
20+
run: |
21+
git config user.name github-actions[bot]
22+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
23+
- uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
26+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
27+
- uses: actions/cache@v4
28+
with:
29+
key: mkdocs-material-${{ env.cache_id }}
30+
path: ~/.cache
31+
restore-keys: |
32+
mkdocs-material-
33+
- run: pip install mkdocs-material
34+
- run: mkdocs gh-deploy --force
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "PR Quality Gate: rc & main"
2+
3+
on:
4+
pull_request:
5+
branches: [ rc, main ]
6+
types: [ opened, synchronize, reopened, ready_for_review ]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
12+
concurrency:
13+
group: pr-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
precommit:
18+
name: pre-commit
19+
if: ${{ !github.event.pull_request.draft }}
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
# NOTE: point "uses:" to the DIRECTORY that contains action.yaml
24+
# If your composite is at ./pre-commit/action.yaml, use "./pre-commit"
25+
- name: Run pre-commit composite
26+
uses: ./.github/workflows/pre-commit
27+
with:
28+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
29+
30+
pytest:
31+
name: pytest
32+
if: ${{ !github.event.pull_request.draft }}
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
python-version: ${{ fromJSON(env.SUPPORTED_PYTHON_VERSIONS) }}
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Run pytest composite
40+
uses: ./.github/workflows/pytest
41+
with:
42+
python-version: ${{ matrix.python-version }}
43+
44+
pytest-windows:
45+
name: pytest (Windows, non-blocking)
46+
if: ${{ !github.event.pull_request.draft }}
47+
runs-on: windows-latest
48+
continue-on-error: true
49+
strategy:
50+
matrix:
51+
python-version: ${{ fromJSON(env.SUPPORTED_PYTHON_VERSIONS) }}
52+
steps:
53+
- uses: actions/checkout@v4
54+
- name: Run pytest composite
55+
uses: ./.github/workflows/pytest
56+
with:
57+
python-version: ${{ matrix.python-version }}
58+
59+
sonarqube:
60+
name: SonarQube
61+
if: ${{ !github.event.pull_request.draft }}
62+
runs-on: ubuntu-latest
63+
needs: [ pytest ] # starts only after pytest completes
64+
steps:
65+
- uses: actions/checkout@v4
66+
- name: Run SonarCloud composite
67+
uses: ./.github/workflows/sonar
68+
with:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Pre-commit
2+
description: Sets up Python and Poetry and runs pre-commit
3+
4+
inputs:
5+
python-version:
6+
required: true
7+
description: Python version used
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
15+
- name: Setup Python
16+
if: ${{ hashFiles('.pre-commit-config.yaml') != '' }}
17+
uses: actions/setup-python@v3
18+
with:
19+
python-version: ${{ inputs.python-version }}
20+
21+
- name: Install Poetry
22+
if: ${{ hashFiles('.pre-commit-config.yaml') != '' }}
23+
run: pipx install --python python${{ inputs.python-version }} poetry
24+
shell: bash
25+
26+
- name: Install pre-commit
27+
if: ${{ hashFiles('.pre-commit-config.yaml') != '' }}
28+
run: |
29+
pip install pre-commit
30+
pre-commit install
31+
shell: bash
32+
33+
- name: Run pre-commit
34+
if: ${{ hashFiles('.pre-commit-config.yaml') != '' }}
35+
run: pre-commit run -a
36+
shell: bash
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'PyTest'
2+
description: 'Run pytest with Poetry'
3+
inputs:
4+
python-version:
5+
required: true
6+
description: 'Python version used.'
7+
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v3
13+
- name: Set up Python
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: ${{ inputs.python-version }}
17+
- name: Install Poetry
18+
run: pipx install poetry
19+
- name: Install dependencies
20+
run: poetry install --with dev
21+
- name: Run tests
22+
run: poetry run pytest -m "not unstable and not online"
23+
- name: Upload coverage.xml as artifact
24+
uses: actions/upload-artifact@v3
25+
if: ${{ hashFiles('coverage.xml') != '' }}
26+
with:
27+
name: coverage.xml
28+
path: ./coverage.xml
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: SonarCloud Scan
2+
description: Runs SonarCloud scan with coverage artifact
3+
4+
inputs:
5+
GITHUB_TOKEN:
6+
required: true
7+
description: GitHub token
8+
SONAR_TOKEN:
9+
required: true
10+
description: SonarCloud token
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/download-artifact@v5
20+
with:
21+
name: coverage.xml
22+
path: ./
23+
24+
- name: SonarCloud Scan
25+
uses: SonarSource/sonarcloud-github-action@master
26+
env:
27+
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
28+
SONAR_TOKEN: ${{ inputs.SONAR_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,3 +666,4 @@ src/weather_provider_sources/
666666
# All of IDEA really
667667
.idea/
668668
!/htmlcov/
669+
/.act_secrets.ini

0 commit comments

Comments
 (0)