Skip to content

Commit 30a9053

Browse files
committed
update to run in parallel
1 parent 27ba951 commit 30a9053

File tree

5 files changed

+177
-42
lines changed

5 files changed

+177
-42
lines changed

.gitallowed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
token: ?"?\$\{\{\s*secrets\.GITHUB_TOKEN\s*\}\}"?
22
.*\.gitallowed.*
33
id-token: write
4-
def __init__\(self, token: str, owner: str, repo: str\)
4+
def __init__\(self, token: str, owner: str, repo: str
55
token = os.environ\.get\("GH_TOKEN"\)
66
self\.token = token
77
password: \${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,3 @@ test:
3232

3333
build:
3434
echo "Not implemented"
35-
36-
run-all-release:
37-
./scripts/run_all_release.sh 2>&1 | tee release_$(shell date +%Y%m%d_%H%M%S).log

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,29 @@ repos:
214214
- 'docker run -v "$LOCAL_WORKSPACE_FOLDER:/src" git-secrets --pre_commit_hook'
215215
language: system
216216
```
217+
218+
## Run all releases
219+
220+
There are some scripts that can be used to trigger releases for all our repos.
221+
It is invoked by running `./scripts/run_all_release.sh`.
222+
This first authenticates to github using github cli tools to get a valid github token.
223+
224+
It then has an array of repos which it loops through asking for confirmation if you want to run deployment for it.
225+
226+
For any that you have answered yes to, it then calls the python script `scripts/trigger_release.py`.
227+
228+
The python script will trigger the release.yml workflow for that repo and monitor the the run for it.
229+
When it reaches one of the steps release_qa, release_ref, release_int it will approve release to that environment.
230+
Once the run reaches release_prod step, the python script will exit.
231+
The python script will also exit if the github run fails, or is cancelled at any step, or there is an unexpected response from github (eg user does not have permission to approve a deployment).
232+
When the python script finishes, it logs the run url, the tag and summary of what happened.
233+
Python logs go to the console, and to a timestamped file in the logs folder.
234+
235+
When all runs of the python script have finished then the shell script exits showing a summary of failed and successful runs.
236+
237+
238+
If a run fails on a step BEFORE the tag_release step, and the failure is transient (eg quality checks fails installing dependencies due to npm being down) then the whole release workflow can be rerun - either via this script or using the github website.
239+
240+
If a run fails on a step AFTER the tag_release step, and the failure is transient (eg regression tests failure) then that failing step can just be re-run manually via the github website.
241+
242+
If a run fails due to a code or cloudformation/cdk issue, then a new pull request should be created to fix this, merged to main, and a new release triggered.

scripts/run_all_release.sh

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env bash
22

3-
set -e
4-
53
# this script runs the python script to trigger releases for multiple repositories
64
# it uses gh cli to authenticate and get the token
75

@@ -18,14 +16,68 @@ repos=(
1816
"NHSDigital/prescriptionsforpatients"
1917
"NHSDigital/eps-prescription-status-update-api"
2018
"NHSDigital/eps-FHIR-validator-lambda"
21-
"NHSDigital/eps-aws-vpc-resources"
19+
"NHSDigital/eps-vpc-resources"
2220
"NHSDigital/eps-aws-dashboards"
2321
"NHSDigital/electronic-prescription-service-clinical-prescription-tracker"
2422
)
2523

24+
# Array to store repos that user wants to release
25+
selected_repos=()
26+
27+
# Ask user for each repo
2628
for repo in "${repos[@]}"; do
2729
read -r -p "Do you want to run the release for $repo? (y/n): " answer
2830
if [[ "$answer" == "y" || "$answer" == "Y" ]]; then
29-
poetry run python3 scripts/trigger_release.py "$repo"
31+
selected_repos+=("$repo")
3032
fi
3133
done
34+
35+
# Check if any repos were selected
36+
if [ ${#selected_repos[@]} -eq 0 ]; then
37+
echo "No repositories selected for release."
38+
exit 0
39+
fi
40+
41+
echo ""
42+
echo "Starting releases for ${#selected_repos[@]} repository(ies)..."
43+
echo ""
44+
45+
# Array to store background process IDs
46+
pids=()
47+
48+
# Launch releases in parallel
49+
for repo in "${selected_repos[@]}"; do
50+
echo "Starting release for $repo..."
51+
poetry run python3 scripts/trigger_release.py "$repo" &
52+
pids+=($!)
53+
done
54+
55+
echo ""
56+
echo "All releases triggered. Waiting for completion..."
57+
echo ""
58+
59+
# Wait for all background processes to complete and track their exit codes
60+
failed_count=0
61+
success_count=0
62+
63+
for pid in "${pids[@]}"; do
64+
if wait "$pid"; then
65+
((success_count++))
66+
else
67+
((failed_count++))
68+
fi
69+
done
70+
71+
echo ""
72+
echo "========================================"
73+
echo "All releases completed!"
74+
echo "Successful: $success_count"
75+
echo "Failed: $failed_count"
76+
echo "========================================"
77+
78+
# Exit with error if any releases failed
79+
if [ $failed_count -gt 0 ]; then
80+
exit 1
81+
fi
82+
83+
exit 0

0 commit comments

Comments
 (0)