]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
gh actions: simplified collector job in build-and-test-all.yml 12623/head
authorAlexis Romero <alexis.romero@open-xchange.com>
Thu, 16 Feb 2023 05:54:23 +0000 (06:54 +0100)
committerAlexis Romero <alexis.romero@open-xchange.com>
Mon, 6 Mar 2023 17:13:29 +0000 (18:13 +0100)
.github/workflows/build-and-test-all.yml

index faf81a61c6045d086cc3186b5b4762229b5de675..3156b001034787107f5a9052c2d3a55e1afb2551 100644 (file)
@@ -148,19 +148,22 @@ jobs:
       - test-recursor-api
       - test-recursor-regression
       - test-recursor-bulk
+    if: success() || failure()
     runs-on: ubuntu-20.04
     steps:
+      - name: Install jq and yq
+        run: "sudo snap install jq yq"
+      - name: Fail job if any of the previous jobs failed
+        run: "for i in `echo '${{ toJSON(needs) }}' | jq '.[].result' | tr -d '\"'`; do if [[ $i == 'failure' ]]; then echo '${{ toJSON(needs) }}'; exit 1; fi; done;"
       - uses: actions/checkout@v3.1.0
         with:
           fetch-depth: 5
           submodules: recursive
-      - name: Install yq
-        run: sudo wget https://github.com/mikefarah/yq/releases/download/v4.9.6/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq
-      - name: Get full list of jobs for this workflow
-        run: yq e '.jobs | keys' .github/workflows/build-and-test-all.yml | grep -v '^- collect' | sort | tee /tmp/workflow-jobs-list.yml
-      - name: Get list of jobs the collect job depends on
-        run: yq e '.jobs.collect.needs | ... comments=""' .github/workflows/build-and-test-all.yml | sort | tee /tmp/workflow-collect-dependencies.yml
-      - name: Diff them
-        run: diff -u /tmp/workflow-jobs-list.yml /tmp/workflow-collect-dependencies.yml
+      - name: Get list of jobs in the workflow
+        run: "yq e '.jobs | keys' .github/workflows/build-and-test-all.yml | awk '{print $2}' | grep -v collect | sort | tee /tmp/workflow-jobs-list.yml"
+      - name: Get list of prerequisite jobs
+        run: "echo '${{ toJSON(needs) }}' | jq 'keys | .[]' | tr -d '\"' | sort | tee /tmp/workflow-needs-list.yml"
+      - name: Fail if there is a job missing on the needs list
+        run: "if ! diff -q /tmp/workflow-jobs-list.yml /tmp/workflow-needs-list.yml; then exit 1; fi"
 
 # FIXME: if we can make upload/download-artifact fasts, running unit tests outside of build can let regression tests start earlier