Skip to content

Commit

Permalink
feat(ci): add helpful error when check-generated-code gha workflow fa…
Browse files Browse the repository at this point in the history
…ils (#627)

* feat(ci): add helpful error when check-generated-code gha workflow fails

* fixup from review, more explicit steps

* fixup from review, stop using .bash suffix and better handle GITHUB_ACTIONS env

* fixup further enhance error message for actionable instructions

* fixup more reasonable bash opts order, o pipefail belongs together

* fixup i'm glad for slow openshift-ci that helped me realize I forgot to finish the shell script renaming
  • Loading branch information
jiridanek committed Jul 19, 2024
1 parent cdbf086 commit a1154b4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-notebooks-TEMPLATE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
df -h
free -h
bash ./ci/cached-builds/gha_lvm_overlay.bash
bash ./ci/cached-builds/gha_lvm_overlay.sh
df -h
free -h
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ jobs:
- uses: actions/checkout@v4

- name: Rerun all code generators we have
run: python3 ci/cached-builds/gen_gha_matrix_jobs.py
run: bash ci/generate_code.sh

- name: Check there aren't any modified files present
run: |
clean=$(git status --porcelain)
if [[ -z "$clean" ]]; then
echo "Empty git status --porcelain: $clean"
else
echo "::error::Please run 'bash ci/generate_code.sh' (the command from the previous step), commit the changed files locally, and push again."
echo "Uncommitted file changes detected: $clean"
git diff
exit 1
Expand Down
10 changes: 7 additions & 3 deletions ci/cached-builds/gen_gha_matrix_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,13 @@ def main() -> None:

print("leafs", leafs)
print(*output, sep="\n")
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
for line in output:
print(line, file=f)

if "GITHUB_ACTIONS" in os.environ:
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
for line in output:
print(line, file=f)
else:
logging.info(f"Not running on Github Actions, won't produce GITHUB_OUTPUT")


if __name__ == '__main__':
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions ci/generate_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -Eeuxo pipefail

python3 ci/cached-builds/gen_gha_matrix_jobs.py

0 comments on commit a1154b4

Please sign in to comment.