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,37 @@ 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+ shell : " bash"
59+ id : " check"
60+ run : |
61+ # This check is completely gutted here. It doesn't play nice with boostrapping.
62+ # We just assume we want to see all tests.
63+ echo "run_docs=1" >> $GITHUB_OUTPUT
64+ echo "run_tests=1" >> $GITHUB_OUTPUT
65+
4966 lint :
5067 uses : " ./.github/workflows/lint.yml"
5168
69+ sanity :
70+ uses : " ./.github/workflows/sanity.yml"
71+
5272 build :
53- needs : " lint"
73+ needs :
74+ - " check-changes"
75+ - " lint"
76+ if : " needs.check-changes.outputs.run_tests == '1'"
5477 uses : " ./.github/workflows/build.yml"
5578
5679 test :
@@ -62,15 +85,15 @@ jobs:
6285
6386 deprecations :
6487 runs-on : " ubuntu-latest"
65- if : github.base_ref == 'main'
88+ if : " github.base_ref == 'main'"
6689 needs : " test"
6790 steps :
6891 - name : " Create working directory"
6992 run : |
7093 mkdir -p "pulp_catdog"
7194 working-directory : " ."
7295 - name : " Download Deprecations"
73- uses : actions/download-artifact@v4
96+ uses : " actions/download-artifact@v4"
7497 with :
7598 pattern : " deprecations-*"
7699 path : " pulp_catdog"
@@ -84,14 +107,41 @@ jobs:
84107 # This is a dummy dependent task to have a single entry for the branch protection rules.
85108 runs-on : " ubuntu-latest"
86109 needs :
110+ - " check-changes"
87111 - " check-commits"
88112 - " lint"
89113 - " test"
114+ - " sanity"
90115 if : " always()"
91116 steps :
92117 - name : " Collect needed jobs results"
93118 working-directory : " ."
94119 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'
120+ RUN_TESTS=${{ needs.check-changes.outputs.run_tests }}
121+ RUN_DOCS=${{ needs.check-changes.outputs.run_docs }}
122+
123+ check_jobs() {
124+ local filter="$1"
125+ local needs_json='${{toJson(needs)}}'
126+ # output failed jobs after filter
127+ echo "$needs_json" | jq -r "to_entries[]|select($filter)|select(.value.result!=\"success\")|.key + \": \" + .value.result"
128+ # fails if not all selected jobs passed
129+ echo "$needs_json" | jq -e "to_entries|map(select($filter))|map(select(.value.result!=\"success\"))|length == 0"
130+ }
131+
132+ if [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "1" ]; then
133+ FILTERS="true" # check all jobs
134+ elif [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "0" ]; then
135+ echo "Skipping docs: running on non-default branch"
136+ FILTERS='.key != "docs"'
137+ elif [ "$RUN_TESTS" == "0" ] && [ "$RUN_DOCS" == "1" ]; then
138+ echo "Skipping tests: only doc changes"
139+ FILTERS='.key != "lint" and .key != "test"'
140+ else # RUN_TESTS=0, RUN_DOCS=0
141+ echo "What is this PR doing??"
142+ FILTERS='.key != "lint" and .key != "test" and .key != "docs"'
143+ fi
144+
145+ check_jobs "$FILTERS"
97146 echo "CI says: Looks good!"
147+ ...
0 commit comments