Skip to content

Commit 42b2dfb

Browse files
committed
Refactor Github Actions workflow
1 parent 48fa6c4 commit 42b2dfb

File tree

5 files changed

+141
-56
lines changed

5 files changed

+141
-56
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Backend Test Coverage CI
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
required: true
8+
type: string
9+
plone-version:
10+
required: true
11+
type: string
12+
13+
defaults:
14+
run:
15+
working-directory: backend
16+
17+
jobs:
18+
19+
coverage:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Install the latest version of uv
26+
uses: astral-sh/setup-uv@v5
27+
with:
28+
python-version: ${{ inputs.python-version }}
29+
enable-cache: false
30+
31+
- name: Restore uv cache
32+
uses: actions/cache@v4
33+
with:
34+
path: /tmp/.uv-cache
35+
key: uv-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.plone-version }}-${{ hashFiles('pyproject.toml') }}
36+
restore-keys: |
37+
uv-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.plone-version }}-${{ hashFiles('pyproject.toml') }}
38+
uv-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.plone-version }}
39+
40+
- name: Install Plone and package
41+
run: make install
42+
43+
- name: Run tests
44+
run: make test-coverage
45+
46+
- name: Report Coverage
47+
run: |
48+
echo "# Coverage Report" >> $GITHUB_STEP_SUMMARY
49+
echo "$(uv run coverage report --format markdown)" >> $GITHUB_STEP_SUMMARY

.github/workflows/backend-lint.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Backend CI
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
required: true
8+
type: string
9+
plone-version:
10+
required: true
11+
type: string
12+
13+
defaults:
14+
run:
15+
working-directory: backend
16+
17+
jobs:
18+
19+
lint:
20+
runs-on: ubuntu-latest
21+
steps:
22+
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Install the latest version of uv
27+
uses: astral-sh/setup-uv@v5
28+
with:
29+
python-version: ${{ inputs.python-version }}
30+
31+
- name: Check formatting
32+
if: ${{ success() || failure() }}
33+
id: ruff-format
34+
run: uvx ruff@latest format --diff
35+
36+
- name: Check lint
37+
if: ${{ success() || failure() }}
38+
id: ruff-lint
39+
run: uvx ruff@latest check --diff
40+
41+
- name: Check XML / ZCML
42+
if: ${{ success() || failure() }}
43+
id: zpretty
44+
run: uvx zpretty@latest --check src
45+
46+
- name: Check Package Metadata
47+
if: ${{ success() || failure() }}
48+
id: pyroma
49+
run: uvx pyroma@latest -d .
50+
51+
- name: Check Python Versions
52+
if: ${{ success() || failure() }}
53+
id: py-versions
54+
run: uvx check-python-versions@latest .
55+
56+
- name: Report
57+
if: ${{ success() || failure() }}
58+
run: |
59+
echo '# Code Analysis' >> $GITHUB_STEP_SUMMARY
60+
echo '| Test | Status |' >> $GITHUB_STEP_SUMMARY
61+
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
62+
echo '| Format | ${{ steps.ruff-format.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
63+
echo '| Lint | ${{ steps.ruff-lint.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
64+
echo '| XML / ZCML | ${{ steps.zpretty.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
65+
echo '| Package Metadata | ${{ steps.pyroma.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
66+
echo '| Python Versions | ${{ steps.py-versions.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY

.github/workflows/backend-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Backend CI
1+
name: Backend Image Generation
22

33
on:
44
workflow_call:
Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Backend CI
1+
name: Backend Tests CI
22

33
on:
44
workflow_call:
@@ -16,55 +16,6 @@ defaults:
1616

1717
jobs:
1818

19-
lint:
20-
runs-on: ubuntu-latest
21-
steps:
22-
23-
- name: Checkout
24-
uses: actions/checkout@v4
25-
26-
- name: Install the latest version of uv
27-
uses: astral-sh/setup-uv@v5
28-
with:
29-
python-version: ${{ inputs.python-version }}
30-
31-
- name: Check formatting
32-
if: ${{ success() || failure() }}
33-
id: ruff-format
34-
run: uvx ruff@latest format --diff
35-
36-
- name: Check lint
37-
if: ${{ success() || failure() }}
38-
id: ruff-lint
39-
run: uvx ruff@latest check --diff
40-
41-
- name: Check XML / ZCML
42-
if: ${{ success() || failure() }}
43-
id: zpretty
44-
run: uvx zpretty@latest --check src
45-
46-
- name: Check Package Metadata
47-
if: ${{ success() || failure() }}
48-
id: pyroma
49-
run: uvx pyroma@latest -d .
50-
51-
- name: Check Python Versions
52-
if: ${{ success() || failure() }}
53-
id: py-versions
54-
run: uvx check-python-versions@latest .
55-
56-
- name: Report
57-
if: ${{ success() || failure() }}
58-
run: |
59-
echo '# Code Analysis' >> $GITHUB_STEP_SUMMARY
60-
echo '| Test | Status |' >> $GITHUB_STEP_SUMMARY
61-
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
62-
echo '| Format | ${{ steps.ruff-format.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
63-
echo '| Lint | ${{ steps.ruff-lint.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
64-
echo '| XML / ZCML | ${{ steps.zpretty.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
65-
echo '| Package Metadata | ${{ steps.pyroma.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
66-
echo '| Python Versions | ${{ steps.py-versions.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
67-
6819
test:
6920
runs-on: ubuntu-latest
7021
env:

.github/workflows/main.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,22 @@ jobs:
5050
filters: |
5151
backend:
5252
- 'backend/**'
53-
- '.github/workflows/backend.yml'
54-
- '.github/workflows/backend-release.yml'
53+
- '.github/workflows/backend*'
5554
frontend:
5655
- 'frontend/**'
5756
- '.github/workflows/frontend.yml'
5857
59-
backend:
60-
uses: ./.github/workflows/backend.yml
58+
backend-lint:
59+
uses: ./.github/workflows/backend-lint.yml
60+
needs:
61+
- config
62+
with:
63+
python-version: ${{ needs.config.outputs.PYTHON_VERSION }}
64+
plone-version: ${{ needs.config.outputs.PLONE_VERSION }}
65+
if: ${{ needs.config.outputs.backend == 'true' }}
66+
67+
backend-test:
68+
uses: ./.github/workflows/backend-test.yml
6169
needs:
6270
- config
6371
strategy:
@@ -69,11 +77,22 @@ jobs:
6977
plone-version: ${{ matrix.plone-version }}
7078
if: ${{ needs.config.outputs.backend == 'true' }}
7179

80+
backend-coverage:
81+
uses: ./.github/workflows/backend-coverage.yml
82+
needs:
83+
- config
84+
- backend-test
85+
with:
86+
python-version: ${{ needs.config.outputs.PYTHON_VERSION }}
87+
plone-version: ${{ needs.config.outputs.PLONE_VERSION }}
88+
if: ${{ needs.config.outputs.backend == 'true' }}
89+
7290
backend-release:
7391
uses: ./.github/workflows/backend-release.yml
7492
needs:
7593
- config
76-
- backend
94+
- backend-lint
95+
- backend-coverage
7796
with:
7897
base-tag: ${{ needs.config.outputs.BASE_TAG }}
7998
image-name-prefix: ${{ needs.config.outputs.IMAGE_NAME_PREFIX }}

0 commit comments

Comments
 (0)