Skip to content

Commit 3baf872

Browse files
[PATCH] Lay initial groundwork for GHI #338
Additions with file .github/actions/checkout-and-rebuild/action.yml: * lays groundwork for GHI #338 Additions with file .github/workflows/CD-PyPi.yml: * related work Changes in file .github/tools/checkmake.bash: * related work Changes in file .github/tools/shlock_helper.sh: * related work Changes in file .github/workflows/CI-BUILD.yml: * lays groundwork for GHI #338 Changes in file .github/workflows/CI-MATs.yml: * lays groundwork for GHI #338 Changes in file Makefile: * sync from master Changes in file multicast/__init__.py: * sync from master
1 parent a100c21 commit 3baf872

File tree

8 files changed

+326
-52
lines changed

8 files changed

+326
-52
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
name: 'Checkout and use Build'
3+
description: 'checks-out the given commit and fetches the build artifact'
4+
author: 'Mr. Walls'
5+
branding:
6+
icon: 'chevron-down'
7+
color: 'blue'
8+
inputs:
9+
sha:
10+
description: |
11+
The commit to checkout and fetch build artifacts for. When running this action on github.com,
12+
the default value is sufficient.
13+
required: true
14+
default: ${{ github.server_url == 'https://github.com' && github.sha || 'HEAD' }}
15+
build-run-id:
16+
description: |
17+
The workflow run to fetch build artifacts from. When running this action on github.com,
18+
the default value is the calling workflow.
19+
required: true
20+
default: ${{ github.server_url == 'https://github.com' && github.run_id || '' }}
21+
path:
22+
description: |
23+
Path to setup. When running this action on github.com, the default value
24+
is sufficient.
25+
required: true
26+
default: ${{ github.server_url == 'https://github.com' && github.workspace || '' }}
27+
token:
28+
description: |
29+
The token used to authenticate when fetching Python distributions from
30+
https://github.com/actions/python-versions. When running this action on github.com,
31+
the default value is sufficient. When running on GHES, you can pass a personal access
32+
token for github.com if you are experiencing rate limiting.
33+
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
34+
required: true
35+
python-version:
36+
description: |
37+
The python version to setup. The default is to use the value of the environment
38+
variable 'PYTHON_VERSION'.
39+
default: '3.12'
40+
required: true
41+
outputs:
42+
branch-name:
43+
description: "The name of the branch that was checked-out"
44+
value: ${{ steps.output_branch_name.outputs.branch-name || '' }}
45+
sha:
46+
description: "The SHA of the commit checked-out"
47+
value: ${{ steps.output_sha.outputs.sha || 'HEAD' }}
48+
python-version:
49+
description: "The python version that was used in the run."
50+
value: ${{ steps.cp313.outputs.python-version || '' }}
51+
artifact-name:
52+
description: "The downloaded artifact-name"
53+
value: "multicast-build-${{ steps.output_sha.outputs.sha }}.zip"
54+
artifact-files:
55+
description: "The downloaded artifact-files"
56+
value: ${{ steps.output_artifact_files.outputs.files }}
57+
58+
runs:
59+
using: composite
60+
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
63+
with:
64+
persist-credentials: false
65+
fetch-depth: 0
66+
path: ${{ inputs.path }}
67+
repository: reactive-firewall/multicast
68+
token: ${{ inputs.token }}
69+
- name: "Checkout Target Commit by SHA"
70+
shell: bash
71+
run: |
72+
printf "%s\n" "::group::target-commit"
73+
git checkout --force --detach ${{ inputs.sha }} --
74+
printf "%s\n" "::endgroup::"
75+
if: ${{ (github.sha != inputs.sha) && success() }}
76+
- id: output_branch_name
77+
if: ${{ !cancelled() }}
78+
shell: bash
79+
run: |
80+
printf "branch-name=%s\n" $(git name-rev --name-only HEAD | cut -d~ -f1-1) >> "$GITHUB_OUTPUT"
81+
- id: output_sha
82+
shell: bash
83+
run: printf "sha=%s\n" $(git rev-parse --verify HEAD) >> "$GITHUB_OUTPUT"
84+
- name: "Setup Python"
85+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
86+
id: cp313
87+
with:
88+
python-version: ${{ inputs.python-version }}
89+
cache: 'pip' # caching pip dependencies
90+
if: ${{ !cancelled() }}
91+
- name: "Install Test Dependencies"
92+
shell: bash
93+
run: make -j1 -f Makefile test-reqs ;
94+
- id: output_artifact_name
95+
if: ${{ success() }}
96+
shell: bash
97+
run: printf "artifact-name=%s\n" multicast-build-${{ steps.output_sha.outputs.sha }}.zip >> "$GITHUB_OUTPUT"
98+
- name: "Fetch Build Files"
99+
if: ${{ (github.repository == 'reactive-firewall/multicast') && success() }}
100+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
101+
with:
102+
path: ${{ inputs.path }}/dist
103+
pattern: multicast-build-${{ steps.output_sha.outputs.sha }}.zip
104+
merge-multiple: true
105+
repository: reactive-firewall/multicast
106+
github-token: ${{ inputs.token }}
107+
run-id: ${{ inputs.build-run-id }}
108+
- name: "Enumerate Fetched Files"
109+
id: output_artifact_files
110+
env:
111+
BUILD_MATCH_PATTERN: "dist/multicast-*-*.whl dist/multicast-*.tar.gz"
112+
SCRIPT_NAME: ".github/actions/checkout-and-rebuild/action.yml"
113+
shell: bash
114+
run: |
115+
FILES=$(git ls-files -oi --exclude-standard -- ${{ env.BUILD_MATCH_PATTERN }} )
116+
if [ -z "$FILES" ]; then
117+
printf "::warning file=%s:: %s\n" "${SCRIPT_NAME}" "No Built files found."
118+
printf "%s\n" "files=" >> "$GITHUB_OUTPUT"
119+
else
120+
printf "%s\n" "Built files found:"
121+
printf "%s\n" "$FILES"
122+
# Replace line breaks with commas for GitHub Action Output
123+
FILES="${FILES//$'\n'/ }"
124+
printf "%s\n" "files=$FILES" >> "$GITHUB_OUTPUT"
125+
fi
126+
if: ${{ success() }}
File renamed without changes.
File renamed without changes.

.github/workflows/CD-PyPi.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: CD-PyPi
3+
description: "Continuous Deployment workflow for PyPi publishing."
4+
run-name: Build and publish ${{ github.ref_name }} by @${{ github.actor }}
5+
6+
on:
7+
release:
8+
types:
9+
- published
10+
11+
permissions: {}
12+
13+
jobs:
14+
pypi-publish:
15+
name: upload release to PyPI
16+
if: ${{ github.event_name == 'release' && (github.repository == 'reactive-firewall/multicast') && startsWith(github.ref, 'refs/tags/v') }}
17+
runs-on: ubuntu-latest
18+
# Specifying a GitHub environment is optional, but strongly encouraged
19+
# environment: pypi
20+
permissions:
21+
# IMPORTANT: this permission is mandatory for Trusted Publishing
22+
id-token: write
23+
statuses: write
24+
contents: read
25+
actions: read
26+
defaults:
27+
run:
28+
shell: bash
29+
env:
30+
LANG: "en_US.UTF-8"
31+
outputs:
32+
build_status: ${{ steps.build.outcome }}
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
36+
with:
37+
persist-credentials: false
38+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
39+
with:
40+
python-version: "${{ vars.PYTHON_DEFAULT }}"
41+
- name: Pre-Clean
42+
id: clean
43+
run: make -j1 -f Makefile purge 2>/dev/null || true
44+
- name: Build
45+
id: build
46+
run: make -j1 -f Makefile build
47+
- name: Publish package distributions to PyPI
48+
if ${{ success() }}
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
with:
51+
skip-existing: true
52+
packages-dir: dist/

.github/workflows/CI-BUILD.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: CI-BUILD
33
description: "Continuous Integration workflow for building, the project."
4-
run-name: Build ${{ github.ref_name }} by @${{ github.actor }}
4+
run-name: Build ${{ github.ref_name }}
55
#
66
# Jobs included:
77
# - BUILD: Ensures the project compiles correctly
@@ -33,8 +33,6 @@ jobs:
3333
statuses: write
3434
packages: none
3535
pull-requests: read
36-
id-token: write
37-
attestations: write
3836
security-events: none
3937
if: ${{ !cancelled() && (github.repository == 'reactive-firewall/multicast') }}
4038
runs-on: ubuntu-latest
@@ -44,7 +42,7 @@ jobs:
4442
shell: bash
4543
env:
4644
LANG: "en_US.UTF-8"
47-
GIT_MATCH_PATTERN: "dist/multicast-*-*.whl dist/multicast-*.tar.gz"
45+
BUILD_MATCH_PATTERN: "dist/multicast-*-*.whl dist/multicast-*.tar.gz"
4846
outputs:
4947
build_status: ${{ steps.build.outcome }}
5048
steps:
@@ -71,30 +69,27 @@ jobs:
7169
id: buildfiles
7270
shell: bash
7371
run: |
74-
FILES=$(git ls-files -oi --exclude-standard -- ${{ env.GIT_MATCH_PATTERN }} )
72+
FILES=$(git ls-files -oi --exclude-standard -- ${{ env.BUILD_MATCH_PATTERN }} )
7573
if [ -z "$FILES" ]; then
7674
printf "%s\n" "::warning file=.github/workflows/CI-BUILD.yml:: No Built files found."
7775
printf "%s\n" "files=" >> "$GITHUB_OUTPUT"
7876
else
7977
printf "%s\n" "Built files found:"
8078
printf "%s\n" "$FILES"
81-
# Replace line breaks with spaces for GitHub Action Output
79+
# Replace line breaks with commas for GitHub Action Output
8280
FILES="${FILES//$'\n'/ }"
8381
printf "%s\n" "files=$FILES" >> "$GITHUB_OUTPUT"
8482
fi
8583
if: ${{ success() }}
8684
- name: Upload build artifact
8785
id: upload
86+
if: ${{ !cancelled() && (steps.buildfiles.outputs.files != '') && (github.repository == 'reactive-firewall/multicast') }}
8887
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
8988
with:
90-
path: ${{ steps.buildfiles.outputs.files }}
89+
path: dist
9190
name: multicast-build-${{ github.sha }}.zip
92-
- name: Generate artifact attestation
93-
if: ${{ !cancelled() && steps.buildfiles.outputs.files != '' && (github.repository == 'reactive-firewall/multicast') }}
94-
uses: actions/attest-build-provenance@v2
95-
with:
96-
subject-name: multicast-build-${{ github.sha }}.zip
97-
subject-digest: sha256:${{ steps.upload.outputs.artifact-digest }}
91+
compression-level: 3
92+
overwrite: true
9893

9994
BOOTSTRAP:
10095
permissions:
@@ -195,11 +190,13 @@ jobs:
195190
pull-requests: read
196191
needs: [BUILD, BOOTSTRAP]
197192
runs-on: ubuntu-latest
193+
environment: ${{ needs.BUILD.environment }}
198194
if: ${{ !cancelled() }}
199195
outputs:
200196
didBUILD: ${{ steps.check_status.outputs.build_success }}
201197
build_ref: ${{ steps.check_status.outputs.build_ref }}
202198
build_ref_name: ${{ steps.check_status.outputs.build_ref_name }}
199+
environment: ${{ needs.BUILD.environment }}
203200
steps:
204201
- id: check_status
205202
run: |
@@ -213,6 +210,7 @@ jobs:
213210
- name: Download All Artifacts
214211
uses: actions/download-artifact@v4
215212
with:
216-
path: dist
217-
pattern: multicast-${{ github.sha }}
213+
path: ${{ github.workspace }}/dist
214+
pattern: multicast-build-${{ github.sha }}.zip
215+
merge-multiple: true
218216
- run: ls -R dist

0 commit comments

Comments
 (0)