11---
2- name : Test bootstrapping a plugin
3- on :
4- pull_request :
5- branches :
6- - ' *'
2+ name : " Test bootstrapping a plugin"
3+ on : {pull_request: {branches: ['*']}}
74
85concurrency :
96 group : ${{ github.ref_name }}-${{ github.workflow }}
3330 - name : " Install python dependencies"
3431 run : |
3532 echo ::group::PYDEPS
36- pip install requests pygithub
33+ pip install requests pygithub pyyaml
3734 echo ::endgroup::
3835 - name : " Check commit message"
3936 # This will fail for our fake plugin
@@ -46,11 +43,38 @@ jobs:
4643 run : |
4744 .github/workflows/scripts/check_commit.sh
4845
46+ check-changes :
47+ runs-on : " ubuntu-latest"
48+ outputs :
49+ run_tests : " ${{ steps.check.outputs.run_tests }}"
50+ run_docs : " ${{ steps.check.outputs.run_docs }}"
51+ steps :
52+ - uses : " actions/checkout@v4"
53+ with :
54+ fetch-depth : 0
55+ path : " plugin_template"
56+
57+ - name : " Analyze changed files"
58+ id : " check"
59+ shell : " bash"
60+ working-directory : " plugin_template"
61+ run : |
62+ # This check is completely gutted here. It doesn't play nice with boostrapping.
63+ # We just assume we want to see all tests.
64+ echo "run_docs=1" >> $GITHUB_OUTPUT
65+ echo "run_tests=1" >> $GITHUB_OUTPUT
66+
4967 lint :
5068 uses : " ./.github/workflows/lint.yml"
5169
70+ sanity :
71+ uses : " ./.github/workflows/sanity.yml"
72+
5273 build :
53- needs : " lint"
74+ needs :
75+ - " check-changes"
76+ - " lint"
77+ if : " needs.check-changes.outputs.run_tests == '1'"
5478 uses : " ./.github/workflows/build.yml"
5579
5680 test :
@@ -62,15 +86,15 @@ jobs:
6286
6387 deprecations :
6488 runs-on : " ubuntu-latest"
65- if : github.base_ref == 'main'
89+ if : " github.base_ref == 'main'"
6690 needs : " test"
6791 steps :
6892 - name : " Create working directory"
6993 run : |
7094 mkdir -p "pulp_catdog"
7195 working-directory : " ."
7296 - name : " Download Deprecations"
73- uses : actions/download-artifact@v4
97+ uses : " actions/download-artifact@v4"
7498 with :
7599 pattern : " deprecations-*"
76100 path : " pulp_catdog"
@@ -84,14 +108,41 @@ jobs:
84108 # This is a dummy dependent task to have a single entry for the branch protection rules.
85109 runs-on : " ubuntu-latest"
86110 needs :
111+ - " check-changes"
87112 - " check-commits"
88113 - " lint"
89114 - " test"
115+ - " sanity"
90116 if : " always()"
91117 steps :
92118 - name : " Collect needed jobs results"
93119 working-directory : " ."
94120 run : |
95- echo '${{toJson(needs)}}' | jq -r 'to_entries[]|select(.value.result!="success")|.key + ": " + .value.result'
96- echo '${{toJson(needs)}}' | jq -e 'to_entries|map(select(.value.result!="success"))|length == 0'
121+ RUN_TESTS=${{ needs.check-changes.outputs.run_tests }}
122+ RUN_DOCS=${{ needs.check-changes.outputs.run_docs }}
123+
124+ check_jobs() {
125+ local filter="$1"
126+ local needs_json='${{toJson(needs)}}'
127+ # output failed jobs after filter
128+ echo "$needs_json" | jq -r "to_entries[]|select($filter)|select(.value.result!=\"success\")|.key + \": \" + .value.result"
129+ # fails if not all selected jobs passed
130+ echo "$needs_json" | jq -e "to_entries|map(select($filter))|map(select(.value.result!=\"success\"))|length == 0"
131+ }
132+
133+ if [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "1" ]; then
134+ FILTERS="true" # check all jobs
135+ elif [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "0" ]; then
136+ echo "Skipping docs: running on non-default branch"
137+ FILTERS='.key != "docs"'
138+ elif [ "$RUN_TESTS" == "0" ] && [ "$RUN_DOCS" == "1" ]; then
139+ echo "Skipping tests: only doc changes"
140+ FILTERS='.key != "lint" and .key != "test"'
141+ else # RUN_TESTS=0, RUN_DOCS=0
142+ echo "What is this PR doing??"
143+ FILTERS='.key != "lint" and .key != "test" and .key != "docs"'
144+ fi
145+
146+ check_jobs "$FILTERS"
97147 echo "CI says: Looks good!"
148+ ...
0 commit comments