Skip to content

Commit f25e1cd

Browse files
authored
Merge pull request #221 from fairagro/feature/publish_pypi_packages
Feature/publish pypi packages
2 parents c73f49f + ae19be6 commit f25e1cd

18 files changed

Lines changed: 452 additions & 216 deletions

.github/workflows/feature-pull-request.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535
code-quality:
3636
name: Code Quality
3737
needs: detect-changes
38-
if: needs.detect-changes.outputs.code == 'true'
3938
uses: ./.github/workflows/reusable-code-quality.yml
4039
with:
4140
components: '["api"]'
41+
skip: ${{ needs.detect-changes.outputs.code != 'true' }}
4242
secrets: inherit
4343

4444
build:
@@ -52,10 +52,11 @@ jobs:
5252

5353
check:
5454
name: Check
55-
needs: build
56-
if: needs.build.result == 'success'
55+
needs: [detect-changes, build]
56+
if: always() && needs.detect-changes.result == 'success'
5757
uses: ./.github/workflows/reusable-check.yml
5858
with:
59-
version: ${{ needs.build.outputs.version }}
59+
version: ${{ needs.build.outputs.version || '' }}
6060
components: '["api"]'
61+
skip: ${{ needs.detect-changes.outputs.code != 'true' }}
6162
secrets: inherit

.github/workflows/pre-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
uses: ./.github/workflows/reusable-release.yml
4040
with:
4141
version: ${{ needs.build.outputs.version }}
42+
pep440_version: ${{ needs.build.outputs.pep440_version }}
4243
components: '["api"]'
4344
release_type: 'feature'
4445
create_github_release: false

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
uses: ./.github/workflows/reusable-release.yml
6363
with:
6464
version: ${{ needs.build.outputs.version }}
65+
pep440_version: ${{ needs.build.outputs.pep440_version }}
6566
components: '["api"]'
6667
release_type: 'final'
6768
tag_prefix: 'docker-v'

.github/workflows/reusable-build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,32 @@ jobs:
184184
name: sbom-${{ matrix.component }}-${{ needs.version.outputs.version }}
185185
path: sboms/sbom-${{ matrix.component }}.spdx.json
186186
retention-days: 1
187+
188+
python-build:
189+
name: Python Package Build
190+
needs: version
191+
runs-on: ubuntu-latest
192+
permissions:
193+
contents: read
194+
195+
steps:
196+
- uses: actions/checkout@v4
197+
with:
198+
fetch-depth: 0
199+
200+
- uses: astral-sh/setup-uv@v5
201+
202+
- name: Build Python packages (wheels + sdists)
203+
env:
204+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.version.outputs.pep440_version }}
205+
run: |
206+
mkdir -p dist
207+
uv build --package fairagro-middleware-shared --out-dir dist
208+
uv build --package fairagro-middleware-api-client --out-dir dist
209+
210+
- name: Upload Python packages artifact
211+
uses: actions/upload-artifact@v4
212+
with:
213+
name: python-packages-${{ needs.version.outputs.version }}
214+
path: dist/
215+
retention-days: 1

.github/workflows/reusable-check.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ permissions:
66
on:
77
workflow_call:
88
inputs:
9-
version:
9+
version: # required if skip is false, but allowing default to enable skipping both checks when no code changes
1010
description: 'Version calculated in Build phase'
11-
required: true
11+
required: false
1212
type: string
13+
default: ''
1314
components:
1415
description: 'A JSON string array of components to check'
1516
required: false
1617
type: string
1718
default: '["api"]'
19+
skip:
20+
description: 'Exit immediately with success without running any checks (for PRs with no code changes)'
21+
required: false
22+
type: boolean
23+
default: false
1824

1925
env:
2026
IMAGE_BASE_NAME: ${{ vars.IMAGE_BASE_NAME || 'fairagro-advanced-middleware' }}
@@ -23,6 +29,7 @@ env:
2329
jobs:
2430
licence-check:
2531
name: Licence Check
32+
if: ${{ !inputs.skip }}
2633
runs-on: ubuntu-latest
2734
strategy:
2835
matrix:
@@ -53,6 +60,7 @@ jobs:
5360

5461
security-check:
5562
name: Security Check
63+
if: ${{ !inputs.skip }}
5664
runs-on: ubuntu-latest
5765
strategy:
5866
matrix:
@@ -119,21 +127,29 @@ jobs:
119127
contents: read
120128

121129
steps:
130+
- name: No code changes — skipping checks
131+
if: ${{ inputs.skip }}
132+
run: echo "No code files changed. Exiting with success."
133+
122134
- name: Checkout code
135+
if: ${{ !inputs.skip }}
123136
uses: actions/checkout@v4
124137

125138
- name: Download Docker image artifact
139+
if: ${{ !inputs.skip }}
126140
uses: actions/download-artifact@v4
127141
with:
128142
name: docker-image-${{ matrix.component }}-${{ inputs.version }}
129143

130144
- name: Load Docker image
145+
if: ${{ !inputs.skip }}
131146
run: |
132147
docker load < docker-image-${{ matrix.component }}.tar.gz
133148
IMAGE_TAG="local/${{ env.IMAGE_BASE_NAME }}-${{ matrix.component }}:${{ inputs.version }}"
134149
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
135150
136151
- name: Run Container Structure Tests
152+
if: ${{ !inputs.skip }}
137153
uses: plexsystems/container-structure-test-action@v0.3.0
138154
with:
139155
image: ${{ env.IMAGE_TAG }}

.github/workflows/reusable-code-quality.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
required: false
1212
type: string
1313
default: '["api"]'
14+
skip:
15+
description: 'Exit immediately with success without running any checks (for PRs with no code changes)'
16+
required: false
17+
type: boolean
18+
default: false
1419

1520
env:
1621
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
@@ -26,28 +31,38 @@ jobs:
2631
contents: read
2732

2833
steps:
34+
- name: No code changes — skipping checks
35+
if: ${{ inputs.skip }}
36+
run: echo "No code files changed. Exiting with success."
37+
2938
- name: Checkout code
39+
if: ${{ !inputs.skip }}
3040
uses: actions/checkout@v4
3141

3242
- name: Install uv
43+
if: ${{ !inputs.skip }}
3344
uses: astral-sh/setup-uv@v4
3445
with:
3546
version: "latest"
3647

3748
- name: Set up Python ${{ matrix.python-version }}
49+
if: ${{ !inputs.skip }}
3850
run: uv python install ${{ matrix.python-version }}
3951

4052
- name: Install dependencies
53+
if: ${{ !inputs.skip }}
4154
run: uv sync --dev --all-packages
4255

4356
- name: Code formatting and linting
57+
if: ${{ !inputs.skip }}
4458
run: |
4559
uv run ruff format --check --diff middleware/
4660
uv run ruff check middleware/
4761
uv run pylint middleware/
4862
uv run mypy middleware/
4963
5064
- name: Security check with bandit
65+
if: ${{ !inputs.skip }}
5166
run: |
5267
uv run bandit -r middleware/ -c .bandit -f json -o bandit-report.json || true
5368
python3 -c "
@@ -67,4 +82,5 @@ jobs:
6782
"
6883
6984
- name: Run tests
85+
if: ${{ !inputs.skip }}
7086
run: uv run pytest middleware/ -v --junitxml=pytest-report.xml

0 commit comments

Comments
 (0)