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 }}
3229 # Below this line we include the steps of the ci workflow of the generated plugin
3330 - name : " Install python dependencies"
3431 run : |
35- echo ::group::PYDEPS
36- pip install requests pygithub
37- echo ::endgroup::
32+ pip install requests pygithub pyyaml
3833 - name : " Check commit message"
3934 # This will fail for our fake plugin
4035 if : false
@@ -46,11 +41,38 @@ jobs:
4641 run : |
4742 .github/workflows/scripts/check_commit.sh
4843
44+ check-changes :
45+ runs-on : " ubuntu-latest"
46+ outputs :
47+ run_tests : " ${{ steps.check.outputs.run_tests }}"
48+ run_docs : " ${{ steps.check.outputs.run_docs }}"
49+ steps :
50+ - uses : " actions/checkout@v4"
51+ with :
52+ fetch-depth : 0
53+ path : " plugin_template"
54+
55+ - name : " Analyze changed files"
56+ id : " check"
57+ shell : " bash"
58+ working-directory : " plugin_template"
59+ run : |
60+ # This check is completely gutted here. It doesn't play nice with boostrapping.
61+ # We just assume we want to see all tests.
62+ echo "run_docs=1" >> $GITHUB_OUTPUT
63+ echo "run_tests=1" >> $GITHUB_OUTPUT
64+
4965 lint :
5066 uses : " ./.github/workflows/lint.yml"
5167
68+ sanity :
69+ uses : " ./.github/workflows/sanity.yml"
70+
5271 build :
53- needs : " lint"
72+ needs :
73+ - " check-changes"
74+ - " lint"
75+ if : " needs.check-changes.outputs.run_tests == '1'"
5476 uses : " ./.github/workflows/build.yml"
5577
5678 test :
@@ -62,15 +84,15 @@ jobs:
6284
6385 deprecations :
6486 runs-on : " ubuntu-latest"
65- if : github.base_ref == 'main'
87+ if : " github.base_ref == 'main'"
6688 needs : " test"
6789 steps :
6890 - name : " Create working directory"
6991 run : |
7092 mkdir -p "pulp_catdog"
7193 working-directory : " ."
7294 - name : " Download Deprecations"
73- uses : actions/download-artifact@v4
95+ uses : " actions/download-artifact@v4"
7496 with :
7597 pattern : " deprecations-*"
7698 path : " pulp_catdog"
@@ -84,14 +106,41 @@ jobs:
84106 # This is a dummy dependent task to have a single entry for the branch protection rules.
85107 runs-on : " ubuntu-latest"
86108 needs :
109+ - " check-changes"
87110 - " check-commits"
88111 - " lint"
89112 - " test"
113+ - " sanity"
90114 if : " always()"
91115 steps :
92116 - name : " Collect needed jobs results"
93117 working-directory : " ."
94118 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'
119+ RUN_TESTS=${{ needs.check-changes.outputs.run_tests }}
120+ RUN_DOCS=${{ needs.check-changes.outputs.run_docs }}
121+
122+ check_jobs() {
123+ local filter="$1"
124+ local needs_json='${{toJson(needs)}}'
125+ # output failed jobs after filter
126+ echo "$needs_json" | jq -r "to_entries[]|select($filter)|select(.value.result!=\"success\")|.key + \": \" + .value.result"
127+ # fails if not all selected jobs passed
128+ echo "$needs_json" | jq -e "to_entries|map(select($filter))|map(select(.value.result!=\"success\"))|length == 0"
129+ }
130+
131+ if [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "1" ]; then
132+ FILTERS="true" # check all jobs
133+ elif [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "0" ]; then
134+ echo "Skipping docs: running on non-default branch"
135+ FILTERS='.key != "docs"'
136+ elif [ "$RUN_TESTS" == "0" ] && [ "$RUN_DOCS" == "1" ]; then
137+ echo "Skipping tests: only doc changes"
138+ FILTERS='.key != "lint" and .key != "test"'
139+ else # RUN_TESTS=0, RUN_DOCS=0
140+ echo "What is this PR doing??"
141+ FILTERS='.key != "lint" and .key != "test" and .key != "docs"'
142+ fi
143+
144+ check_jobs "$FILTERS"
97145 echo "CI says: Looks good!"
146+ ...
0 commit comments