Skip to content

Commit d54ca01

Browse files
Merge pull request #66 from modeseven-lfreleng-actions/update-action
Feat: Add artefact_name input to filter build artefact downloads
2 parents 9087397 + ea11ec0 commit d54ca01

File tree

3 files changed

+104
-18
lines changed

3 files changed

+104
-18
lines changed

.github/workflows/testing.yaml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
# Build sample Python project
4343
- name: "Build Python Project"
4444
# yamllint disable-line rule:line-length
45-
uses: lfreleng-actions/python-build-action@3552106f5c8bfedebe4c38116abf3b9c289359ea # v0.1.22
45+
uses: lfreleng-actions/python-build-action@e74a56d61b59b55516ee05037303528423d8ed5a # v1.0.0
4646
with:
4747
path_prefix: "test-python-project/"
4848
tox_build: false
@@ -72,7 +72,7 @@ jobs:
7272
# Rebuild sample Python project
7373
- name: "Rebuild Python Project"
7474
# yamllint disable-line rule:line-length
75-
uses: lfreleng-actions/python-build-action@3552106f5c8bfedebe4c38116abf3b9c289359ea # v0.1.22
75+
uses: lfreleng-actions/python-build-action@e74a56d61b59b55516ee05037303528423d8ed5a # v1.0.0
7676
with:
7777
path_prefix: "test-python-project/"
7878
tox_build: false
@@ -105,3 +105,39 @@ jobs:
105105
path_prefix: "test-python-project/"
106106
# Override failure
107107
permit_fail: true
108+
109+
### Test custom artefact_name support ###
110+
tests-custom-artefact-name:
111+
name: "Test Custom Artefact Name"
112+
runs-on: ubuntu-24.04
113+
permissions:
114+
contents: read
115+
timeout-minutes: 12
116+
steps:
117+
- name: "Checkout repository"
118+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
119+
120+
- name: "Checkout sample project repository"
121+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
122+
with:
123+
repository: "lfreleng-actions/test-python-project"
124+
path: "test-python-project"
125+
126+
# Build with custom artefact name
127+
- name: "Build Python project with custom artefact name"
128+
id: build-custom
129+
# yamllint disable-line rule:line-length
130+
uses: lfreleng-actions/python-build-action@e74a56d61b59b55516ee05037303528423d8ed5a # v1.0.0
131+
with:
132+
path_prefix: "test-python-project/"
133+
artefact_name: "test-python-project-x64"
134+
tox_build: false
135+
136+
# Audit with custom artefact name
137+
# Will fail if artefact download does not work
138+
- name: "Run action with custom artefact_name"
139+
uses: ./
140+
with:
141+
python_version: "${{ env.build_python }}"
142+
path_prefix: "test-python-project/"
143+
artefact_name: "test-python-project-x64"

README.md

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Below is a sample matrix job configuration for this action:
2121
runs-on: "ubuntu-24.04"
2222
needs:
2323
- python-build
24-
# Matrix job
24+
# Matrix job
2525
strategy:
2626
fail-fast: false
2727
matrix: ${{ fromJson(needs.python-build.outputs.matrix_json) }}
@@ -38,6 +38,45 @@ Below is a sample matrix job configuration for this action:
3838
3939
Before the audit shown above, a Python build job has run (not shown).
4040
41+
### Multi-Architecture Example
42+
43+
When auditing builds for different architectures, use the `artefact_name` input
44+
to download the correct architecture-specific artefacts:
45+
46+
<!-- markdownlint-disable MD046 -->
47+
48+
```yaml
49+
python-audit-x64:
50+
name: "Python Audit x64"
51+
runs-on: "ubuntu-latest"
52+
needs: python-build-x64
53+
strategy:
54+
fail-fast: false
55+
matrix: ${{ fromJson(needs.python-build-x64.outputs.matrix_json) }}
56+
steps:
57+
- name: "Audit project dependencies"
58+
uses: lfreleng-actions/python-audit-action@main
59+
with:
60+
python_version: ${{ matrix.python-version }}
61+
artefact_name: my-package-x64
62+
63+
python-audit-arm64:
64+
name: "Python Audit ARM64"
65+
runs-on: "ubuntu-24.04-arm"
66+
needs: python-build-arm64
67+
strategy:
68+
fail-fast: false
69+
matrix: ${{ fromJson(needs.python-build-arm64.outputs.matrix_json) }}
70+
steps:
71+
- name: "Audit project dependencies"
72+
uses: lfreleng-actions/python-audit-action@main
73+
with:
74+
python_version: ${{ matrix.python-version }}
75+
artefact_name: my-package-arm64
76+
```
77+
78+
<!-- markdownlint-enable MD046 -->
79+
4180
## Usage Examples
4281

4382
```yaml
@@ -75,14 +114,15 @@ To ignore specific vulnerabilities:
75114

76115
<!-- markdownlint-disable MD013 -->
77116

78-
| Variable Name | Required | Default | Description |
79-
| --------------- | -------- | --------- | ----------------------------------------------------------- |
80-
| python_versions | True | N/A | Matrix job Python version |
81-
| permit_fail | False | False | Continue/pass even when the audit fails |
82-
| artefact_path | False | "dist" | Stores the test coverage report bundle as an artefact |
83-
| summary | False | True | Whether pypa/gh-action-pip-audit generates summary output |
84-
| path_prefix | False | "" | Path/directory to Python project code |
85-
| ignore_vulns | False | See below | Vulnerability IDs to ignore (whitespace separated) |
117+
| Variable Name | Required | Default | Description |
118+
| -------------- | -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
119+
| python_version | True | N/A | Matrix job Python version |
120+
| artefact_name | False | | Custom name for downloaded artefacts (defaults to project name). Useful when building for different platforms/architectures to avoid artefact name conflicts |
121+
| permit_fail | False | False | Continue/pass even when the audit fails |
122+
| artefact_path | False | "dist" | Path/location to build artefacts |
123+
| summary | False | True | Whether pypa/gh-action-pip-audit generates summary output |
124+
| path_prefix | False | "" | Path/directory to Python project code |
125+
| ignore_vulns | False | See below | Vulnerability IDs to ignore (whitespace separated) |
86126

87127
<!-- markdownlint-enable MD013 -->
88128

action.yaml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ inputs:
1212
description: 'Python version used to perform audit'
1313
required: true
1414
# Optional
15+
artefact_name:
16+
# Useful when building for multiple platforms/architectures
17+
# Can be used to avoid downloading artefacts with conflicting names
18+
description: 'Artefact name to download (defaults to project name)'
19+
required: false
20+
# type: string
1521
permit_fail:
1622
description: 'Continue/pass even when the audit fails'
1723
required: false
@@ -52,7 +58,8 @@ runs:
5258
# yamllint disable-line rule:line-length
5359
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
5460
with:
55-
name: "${{ env.python_project_name }}"
61+
# yamllint disable-line rule:line-length
62+
name: "${{ inputs.artefact_name || env.python_project_name }}"
5663
path: "${{ inputs.artefact_path }}"
5764

5865
- name: "Setup Python ${{ inputs.python_version }}"
@@ -72,27 +79,30 @@ runs:
7279
.tox
7380
# yamllint disable rule:line-length
7481
key: >-
75-
python-${{ runner.os }}-${{ inputs.python_version }}-
82+
python-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python_version }}-
7683
${{ hashFiles('**/requirements*.txt', '**/pyproject.toml', '**/poetry.lock', '**/Pipfile*', '**/setup.py', '**/setup.cfg') }}
7784
restore-keys: |
78-
python-${{ runner.os }}-${{ inputs.python_version }}-
79-
python-${{ runner.os }}-
85+
python-${{ runner.os }}-${{ runner.arch }}-${{ inputs.python_version }}-
86+
python-${{ runner.os }}-${{ runner.arch }}-
8087
# yamllint enable rule:line-length
8188

8289
- name: 'Install build products/dependencies'
8390
shell: bash
8491
run: |
8592
# Install build products/dependencies
93+
path_prefix="${{ inputs.path_prefix }}"
8694
echo 'Upgrading: pip, setuptools'
8795
python -m pip install --disable-pip-version-check \
8896
-q --upgrade pip setuptools
8997
echo 'Installing built package(s) and dependencies'
9098
for wheel in ${{ inputs.artefact_path }}/*.whl; do
9199
pip install -q "$wheel"
92100
done
93-
if [ -f 'requirements.txt' ]; then
94-
echo 'Installing dependencies from: requirements.txt'
95-
pip install -q -r requirements.txt
101+
# Check for requirements.txt in path_prefix if provided
102+
req_file="${path_prefix:+$path_prefix/}requirements.txt"
103+
if [ -f "$req_file" ]; then
104+
echo "Installing dependencies from: $req_file"
105+
pip install -q -r "$req_file"
96106
fi
97107
98108
- name: 'Auditing with: pypa/gh-action-pip-audit'

0 commit comments

Comments
 (0)