Skip to content

Commit 6e22e6b

Browse files
committed
test: rename artifacts
1 parent ef6f1b4 commit 6e22e6b

File tree

3 files changed

+61
-18
lines changed

3 files changed

+61
-18
lines changed

.github/workflows/_build.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ jobs:
5050
matrix:
5151
# It is recommended to pin a Runner version specifically:
5252
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
53-
# os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
54-
# python: ['3.10', '3.11', '3.12', '3.13']
55-
os: [ubuntu-24.04-arm]
56-
python: ['3.13']
53+
# os: [ubuntu-24.04, ubuntu-24.04-arm, macos-latest, windows-latest]
54+
os: [ubuntu-24.04, ubuntu-24.04-arm]
55+
python: ['3.10', '3.11', '3.12', '3.13']
56+
5757
steps:
5858

5959
- name: Harden Runner
@@ -101,13 +101,13 @@ jobs:
101101
# Generate the requirements.txt that contains the hash digests of the dependencies and
102102
# generate the SBOM using CyclonDX SBOM generator.
103103
- name: Generate requirements.txt and SBOM
104-
if: matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
104+
if: matrix.python == env.ARTIFACT_PYTHON
105105
run: make requirements sbom
106106

107107
# Remove the old requirements.txt file (which includes _all_ packages) and generate a
108108
# new one for the package and its actual and required dependencies only.
109109
- name: Prune packages and generate required requirements.txt
110-
if: matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
110+
if: matrix.python == env.ARTIFACT_PYTHON
111111
run: |
112112
rm requirements.txt
113113
make prune requirements

.github/workflows/pr-change-set.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,33 @@ jobs:
2121
contents: read
2222
with:
2323
disable-pip-audit: ${{ vars.DISABLE_PIP_AUDIT == 'true' }}
24+
25+
test:
26+
needs: [build]
27+
name: test
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: read
31+
steps:
32+
33+
- name: Check out repository
34+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Download artifact
39+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
40+
with:
41+
path: dist
42+
43+
# Verify hashes by first computing hashes for the artifacts and then comparing them
44+
# against the hashes computed by the build job.
45+
- name: Verify the artifact hash
46+
env:
47+
ARTIFACT_HASH: ${{ needs.build.outputs.artifacts-sha256 }}
48+
run: |
49+
set -euo pipefail
50+
echo "Hash of package should be $ARTIFACT_HASH."
51+
echo "Decoding the artifact hash:"
52+
echo "$ARTIFACT_HASH" | base64 --decode
53+
echo "$ARTIFACT_HASH" | base64 --decode | sha256sum --strict --check --status || exit 1

Makefile

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@ SHELL := bash
55

66
# Set the package's name and version for use throughout the Makefile.
77
PACKAGE_NAME := package
8-
PACKAGE_VERSION := $(shell python -c $$'try: import $(PACKAGE_NAME); print($(PACKAGE_NAME).__version__);\nexcept: print("unknown");')
8+
PACKAGE_VERSION := $(shell python -c $$'try: import $(PACKAGE_NAME); print($(PACKAGE_NAME).__version__, end="");\nexcept: print("unknown");')
9+
10+
OS_NAME := "$(shell uname)"
11+
ifeq ($(OS_NAME), "Darwin")
12+
OS := darwin
13+
else
14+
ifeq ($(OS_NAME), "Linux")
15+
OS := linux
16+
endif
17+
endif
18+
19+
ARCH := $(shell echo `uname -m` | xargs)# E.g., arm64 or x86_64.
920

1021
# This variable contains the first goal that matches any of the listed goals
1122
# here, else it contains an empty string. The net effect is to filter out
@@ -107,7 +118,7 @@ upgrade-quiet:
107118
# Generate a Software Bill of Materials (SBOM).
108119
.PHONY: sbom
109120
sbom: requirements
110-
cyclonedx-py requirements --output-format json --outfile dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-sbom.json
121+
cyclonedx-py requirements --output-format json --outfile dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(OS)-$(ARCH)-sbom.json
111122

112123
# Generate a requirements.txt file containing version and integrity hashes for all
113124
# packages currently installed in the virtual environment. There's no easy way to
@@ -129,14 +140,14 @@ requirements.txt: pyproject.toml
129140
[[ $$pkg =~ (.*)==(.*) ]] && curl -s https://pypi.org/pypi/$${BASH_REMATCH[1]}/$${BASH_REMATCH[2]}/json | python -c "import json, sys; print(''.join(f''' \\\\\n --hash=sha256:{pkg['digests']['sha256']}''' for pkg in json.load(sys.stdin)['urls']));" >> requirements.txt; \
130141
done
131142
echo -e -n "$(PACKAGE_NAME)==$(PACKAGE_VERSION)" >> requirements.txt
132-
if [ -f dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz ]; then \
133-
echo -e -n " \\\\\n $$(python -m pip hash --algorithm sha256 dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz | grep '^\-\-hash')" >> requirements.txt; \
143+
if [ -f dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(OS)-$(ARCH).tar.gz ]; then \
144+
echo -e -n " \\\\\n $$(python -m pip hash --algorithm sha256 dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(OS)-$(ARCH).tar.gz | grep '^\-\-hash')" >> requirements.txt; \
134145
fi
135-
if [ -f dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl ]; then \
136-
echo -e -n " \\\\\n $$(python -m pip hash --algorithm sha256 dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl | grep '^\-\-hash')" >> requirements.txt; \
146+
if [ -f dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-$(OS)-$(ARCH).whl ]; then \
147+
echo -e -n " \\\\\n $$(python -m pip hash --algorithm sha256 dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-$(OS)-$(ARCH).whl | grep '^\-\-hash')" >> requirements.txt; \
137148
fi
138149
echo "" >> requirements.txt
139-
cp requirements.txt dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-requirements.txt
150+
cp requirements.txt dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(OS)-$(ARCH)-requirements.txt
140151

141152
# Audit the currently installed packages. Skip packages that are installed in
142153
# editable mode (like the one in development here) because they may not have
@@ -175,17 +186,19 @@ test:
175186
# When building these artifacts, we need the environment variable SOURCE_DATE_EPOCH
176187
# set to the build date/epoch. For more details, see: https://flit.pypa.io/en/latest/reproducible.html
177188
.PHONY: dist
178-
dist: dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-md.zip dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-build-epoch.txt
179-
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl: check test
189+
dist: dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-md.zip dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(OS)-$(ARCH)-build-epoch.txt
190+
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl:
180191
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) flit build --setup-py --format wheel
181-
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz: check test
192+
mv dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-none-any.whl dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-py3-$(OS)-$(ARCH).whl
193+
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz:
182194
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) flit build --setup-py --format sdist
195+
mv dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(OS)-$(ARCH).tar.gz
183196
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip: docs-html
184197
python -m zipfile -c dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-html.zip docs/_build/html/
185198
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-md.zip: docs-md
186199
python -m zipfile -c dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-docs-md.zip docs/_build/markdown/
187-
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-build-epoch.txt:
188-
echo $(SOURCE_DATE_EPOCH) > dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-build-epoch.txt
200+
dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(OS)-$(ARCH)-build-epoch.txt:
201+
echo $(SOURCE_DATE_EPOCH) > dist/$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$(OS)-$(ARCH)-build-epoch.txt
189202

190203
# Build the HTML and Markdown documentation from the package's source.
191204
DOCS_SOURCE := $(shell git ls-files docs/source)

0 commit comments

Comments
 (0)