Skip to content

Commit 3c51ad4

Browse files
[MERGE] Close PR #402 and PR #404
3 parents 161dc6f + 57f5592 + 691eeeb commit 3c51ad4

File tree

10 files changed

+909
-100
lines changed

10 files changed

+909
-100
lines changed

.github/actions/run-minimal-acceptance-tests/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ runs:
9191
PYTHON_VERSION_INPUT: ${{ inputs.python-version }}
9292
shell: bash
9393
run: |
94-
if [[ -z $PYTHON_VERSION_INPUT ]]; then
94+
if [[ -n $PYTHON_VERSION_INPUT ]]; then
9595
printf "python-version=%s\n" "${PYTHON_VERSION_INPUT}" >> "$GITHUB_OUTPUT"
9696
PYTHON_VERSION=${PYTHON_VERSION_INPUT}
9797
else
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
---
2+
name: 'Manage and install requirements'
3+
description: 'Performs steps to install from various requirement.txt files for the Multicast Project.'
4+
author: 'Mr. Walls'
5+
branding:
6+
icon: 'download-cloud'
7+
color: 'purple'
8+
inputs:
9+
sha:
10+
description: |
11+
The commit to report dependencies for. Should already be cloned and checked-out beforehand.
12+
required: true
13+
default: ${{ github.server_url == 'https://github.com' && github.sha || 'HEAD' }}
14+
token:
15+
description: |
16+
The token used to authenticate when fetching results from GitHub repositories.
17+
When running this action on github.com, the default value is sufficient. When running on
18+
GHES, you can pass a personal access token for github.com if you are experiencing
19+
rate limiting.
20+
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
21+
required: true
22+
python-version:
23+
description: |
24+
The python version to use. The default is to use the value of the environment
25+
variable 'PYTHON_VERSION'.
26+
default: '3.12'
27+
required: true
28+
outputs:
29+
sha:
30+
description: "The SHA of the commit checked-out"
31+
value: ${{ steps.output_sha.outputs.sha || 'HEAD' }}
32+
python-version:
33+
description: "The python version that was used in the run"
34+
value: ${{ steps.output_python.outputs.python-version || '' }}
35+
deps_status:
36+
description: "The outcome of evaluating the DEPs steps"
37+
value: ${{ steps.deps_outcome.outcome || 'cancelled' }}
38+
deps_build_status:
39+
description: "The outcome of the requirements.txt install Group"
40+
value: ${{ steps.install_build_requirements.outcome || 'cancelled' }}
41+
deps_test_status:
42+
description: "The outcome of the tests/requirements.txt install Group"
43+
value: ${{ steps.install_test_requirements.outcome || 'cancelled' }}
44+
deps_doc_status:
45+
description: "The outcome of the docs/requirements.txt install Group"
46+
value: ${{ steps.install_docs_requirements.outcome || 'cancelled' }}
47+
artifact-name:
48+
description: "The uploaded artifact-name"
49+
value: ${{ steps.output_artifact_name.outputs.artifact-name }}
50+
artifact-files:
51+
description: "The uploaded artifact-files"
52+
value: ${{ steps.output_artifact_files.outputs.files }}
53+
artifact-id:
54+
description: "The uploaded artifact-id"
55+
value: ${{ steps.upload.outputs.artifact-id }}
56+
artifact-url:
57+
description: "The uploaded artifact-url"
58+
value: ${{ steps.upload.outputs.artifact-url }}
59+
artifact-digest:
60+
description: "The uploaded artifact-digest"
61+
value: ${{ steps.upload.outputs.artifact-digest }}
62+
63+
runs:
64+
using: composite
65+
steps:
66+
- name: "Calculate Commit SHA"
67+
id: output_sha
68+
shell: bash
69+
run: |
70+
printf "sha=%s\n" $(git rev-parse --verify '${{ inputs.sha }}') >> "$GITHUB_OUTPUT"
71+
printf "BUILD_SHA=%s\n" $(git rev-parse --verify '${{ inputs.sha }}') >> "$GITHUB_ENV"
72+
- name: "Setup Python"
73+
id: output_python
74+
if: ${{ !cancelled() }}
75+
env:
76+
PYTHON_VERSION_INPUT: ${{ inputs.python-version }}
77+
shell: bash
78+
run: |
79+
if [[ -n $PYTHON_VERSION_INPUT ]]; then
80+
printf "python-version=%s\n" "${PYTHON_VERSION_INPUT}" >> "$GITHUB_OUTPUT"
81+
PYTHON_VERSION=${PYTHON_VERSION_INPUT}
82+
else
83+
printf "python-version=%s\n" "${PYTHON_VERSION}" >> "$GITHUB_OUTPUT"
84+
fi
85+
printf "%s\n" "PYTHON_VERSION=${PYTHON_VERSION}" >> "$GITHUB_ENV"
86+
- name: "Prepare Artifact Name"
87+
id: output_artifact_name
88+
if: ${{ !cancelled() }}
89+
shell: bash
90+
run: |
91+
if [[ ${{ runner.os }} != 'Windows' ]] ; then
92+
printf "artifact-name=%s\n" multicast-integration-${BUILD_SHA}-part-$(uuidgen) >> "$GITHUB_OUTPUT"
93+
else
94+
printf "artifact-name=%s" multicast-integration-${BUILD_SHA}-part- >> "$GITHUB_OUTPUT"
95+
printf "%04x%04x-%04x-%04x-%04x-%04x%04x%04x\n" $RANDOM $RANDOM $RANDOM $(($RANDOM & 0x0fff | 0x4000)) $(($RANDOM & 0x3fff | 0x8000)) $RANDOM $RANDOM $RANDOM >> "$GITHUB_OUTPUT"
96+
fi
97+
printf "%s\n" "DEPS_STEP_SUMMARY=Dependencies-Summary-Artifact-${{ runner.os }}-${PYTHON_VERSION}.txt" >> "$GITHUB_ENV"
98+
- name: "Install Build Dependencies"
99+
id: install_build_requirements
100+
if: ${{ !cancelled() }}
101+
shell: bash
102+
run: |
103+
printf "%s\n" "::group::prep-build-reqs"
104+
make -j1 -f Makefile init || exit 1
105+
printf "%s\n" "::endgroup::"
106+
- name: "Install Test Dependencies"
107+
id: install_test_requirements
108+
if: ${{ !cancelled() }}
109+
shell: bash
110+
run: |
111+
printf "%s\n" "::group::prep-test-reqs"
112+
make -j1 -f Makefile test-reqs || exit 1
113+
printf "%s\n" "::endgroup::"
114+
- name: "Install Documentation Dependencies"
115+
id: install_docs_requirements
116+
if: ${{ !cancelled() }}
117+
shell: bash
118+
run: |
119+
printf "%s\n" "::group::prep-docs-reqs"
120+
make -j1 -f Makefile docs-reqs || exit 1
121+
printf "%s\n" "::endgroup::"
122+
- name: "Evaluate Dependencies"
123+
id: deps_outcome
124+
if: ${{ !cancelled() }}
125+
shell: bash
126+
run: |
127+
if [[ "${{ steps.install_build_requirements.outcome }}" != "failure" ]] ; then
128+
if [[ ( -r requirements.txt ) ]] ; then
129+
# Initialize result as success b/c nothing failed ... yet
130+
THE_RESULT="success"
131+
else
132+
# Initialize result as skipped b/c nothing could be done without requirements.txt
133+
THE_RESULT="skipped"
134+
fi
135+
else
136+
# Initialize result as failure right away
137+
THE_RESULT="failure"
138+
fi
139+
if [[ "${{ steps.install_test_requirements.outcome }}" == "success" && "${THE_RESULT}" == "success" ]] ; then
140+
# keep result as success b/c something succeeded and nothing failed ... yet
141+
THE_RESULT="success"
142+
else
143+
# check for actual failure
144+
if [[ "${{ steps.install_test_requirements.outcome }}" == "failure" ]] ; then
145+
# force result as failure b/c something failed
146+
THE_RESULT="failure"
147+
fi
148+
fi
149+
if [[ "${{ steps.install_docs_requirements.outcome }}" == "success" && "${THE_RESULT}" == "success" ]] ; then
150+
# keep result as success b/c something succeeded and nothing failed ... at all
151+
THE_RESULT="success"
152+
else
153+
# check for actual failure
154+
if [[ "${{ steps.install_docs_requirements.outcome }}" == "failure" ]] ; then
155+
# force result as failure b/c something failed
156+
THE_RESULT="failure"
157+
fi
158+
fi
159+
# hint to help with debugging
160+
printf "::debug:: %s\n" "The result of dependency evaluation: ${THE_RESULT}"
161+
if [[ "${THE_RESULT}" == "success" ]] ; then
162+
exit 0
163+
else
164+
# exit as failure b/c either a soft-fail (skip/cancelled/etc.) or actual failure
165+
exit 1
166+
fi
167+
- name: "Summarize DEPs"
168+
id: deps_report
169+
if: ${{ always() }}
170+
shell: bash
171+
run: |
172+
if [[ "${{ steps.deps_outcome.outcome }}" == "success" ]] ; then
173+
printf "%s\n" " * :ballot_box_with_check: Installing dependencies succeeded with python version \`${PYTHON_VERSION}\` for [${BUILD_SHA}](https://github.com/reactive-firewall/multicast/blob/${BUILD_SHA}/requirements.txt)" > "$DEPS_STEP_SUMMARY"
174+
printf "%s\n" " :ballot_box_with_check: Installing dependencies succeeded with python version \`${PYTHON_VERSION}\`" >> "$GITHUB_STEP_SUMMARY"
175+
else
176+
printf "%s\n" " * :x: ~Installing dependencies succeeded with python version \`${PYTHON_VERSION}\` for \`${BUILD_SHA}\`~" > "$DEPS_STEP_SUMMARY"
177+
printf "%s\n" " :x: ~Installing dependencies succeeded with python version \`${PYTHON_VERSION}\`~" >> "$GITHUB_STEP_SUMMARY"
178+
fi
179+
if [[ "${{ steps.install_build_requirements.outcome }}" == "success" ]] ; then
180+
printf "%s\n" " * :ballot_box_with_check: Installing from [requirements.txt](https://github.com/reactive-firewall/multicast/blob/${BUILD_SHA}/requirements.txt) succeeded" >> "$DEPS_STEP_SUMMARY"
181+
else
182+
printf "%s\n" " * :x: Installing from `requirements.txt` failed" >> "$DEPS_STEP_SUMMARY"
183+
fi
184+
if [[ "${{ steps.install_test_requirements.outcome }}" == "success" ]] ; then
185+
printf "%s\n" " * :ballot_box_with_check: Installing from [tests/requirements.txt](https://github.com/reactive-firewall/multicast/blob/${BUILD_SHA}/tests/requirements.txt) succeeded" >> "$DEPS_STEP_SUMMARY"
186+
else
187+
printf "%s\n" " * :x: Installing from `tests/requirements.txt` failed" >> "$DEPS_STEP_SUMMARY"
188+
fi
189+
if [[ "${{ steps.install_docs_requirements.outcome }}" == "success" ]] ; then
190+
printf "%s\n" " * :ballot_box_with_check: Installing from [docs/requirements.txt](https://github.com/reactive-firewall/multicast/blob/${BUILD_SHA}/docs/requirements.txt) succeeded" >> "$DEPS_STEP_SUMMARY"
191+
else
192+
printf "%s\n" " * :x: Installing from `docs/requirements.txt` failed" >> "$DEPS_STEP_SUMMARY"
193+
fi
194+
- name: "Collect and Enumerate Generated Files"
195+
id: output_artifact_files
196+
if: ${{ !cancelled() && (github.repository == 'reactive-firewall/multicast') }}
197+
env:
198+
DEPS_MATCH_PATTERN: "Dependencies-Summary-Artifact-*.txt"
199+
SCRIPT_NAME: ".github/actions/setup-py-reqs/action.yml"
200+
shell: bash
201+
run: |
202+
FILES=$(git ls-files -o --exclude-standard -- ${{ env.DEPS_MATCH_PATTERN }} )
203+
if [ -z "$FILES" ]; then
204+
printf "::warning file=%s:: %s\n" "${SCRIPT_NAME}" "No summary files found."
205+
printf "%s\n" "files=" >> "$GITHUB_OUTPUT"
206+
exit 1
207+
else
208+
printf "%s\n" "DEPS summary files found:"
209+
printf "%s\n" "$FILES"
210+
mkdir DEPS || :
211+
printf "%s\n" "$FILES" | xargs -I{} mv -f "{}" "DEPS/{}" || :
212+
# Replace line breaks with spaces for GitHub Action Output
213+
FILES="${FILES//$'\n'/ }"
214+
printf "%s\n" "files=$FILES" >> "$GITHUB_OUTPUT"
215+
exit 0
216+
fi
217+
- name: "Upload Details"
218+
id: upload
219+
if: ${{ !cancelled() && (github.repository == 'reactive-firewall/multicast') }}
220+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
221+
with:
222+
path: DEPS
223+
name: ${{ steps.output_artifact_name.outputs.artifact-name }}
224+
if-no-files-found: error
225+
compression-level: 9
226+
overwrite: true
227+
- name: "Cleanup from run"
228+
id: deps_cleanup_success
229+
if: ${{ success() }}
230+
shell: bash
231+
run: |
232+
rm -fRd ./DEPS 2>/dev/null || :
233+
- name: "Cleanup from failed run"
234+
id: deps_cleanup_failure
235+
if: ${{ failure() }}
236+
shell: bash
237+
run: |
238+
rm -fRd ./DEPS 2>/dev/null
239+
exit 1

0 commit comments

Comments
 (0)