Skip to content

Commit e73ef90

Browse files
committed
Separate sanity checks
1 parent b93d917 commit e73ef90

File tree

10 files changed

+220
-83
lines changed

10 files changed

+220
-83
lines changed

.ci/scripts/pr_labels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main():
2323
f".{item['directory']}" for item in PYPROJECT_TOML["tool"]["towncrier"]["type"]
2424
}
2525
except KeyError:
26-
CHANGELOG_EXTS = {"feature", "bugfix", "doc", "removal", "misc"}
26+
CHANGELOG_EXTS = {".feature", ".bugfix", ".doc", ".removal", ".misc"}
2727

2828
repo = Repo(".")
2929

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
path: "plugin_template"
1818
# We need the full history for bootstrapping
1919
fetch-depth: 0
20-
- uses: actions/setup-python@v5
20+
- uses: "actions/setup-python@v5"
2121
with:
2222
python-version: "3.11"
2323
- name: "Bootstrap catdog plugin"

.github/workflows/ci.yml

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
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

85
concurrency:
96
group: ${{ github.ref_name }}-${{ github.workflow }}
@@ -33,7 +30,7 @@ jobs:
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+
...

.github/workflows/lint.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ jobs:
5151
run: |
5252
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows
5353
54-
- name: "Verify bump version config"
55-
run: |
56-
bump-my-version bump --dry-run release
57-
bump-my-version show-bump
58-
5954
# run black separately from flake8 to get a diff
6055
- name: "Run black"
6156
run: |
@@ -70,19 +65,4 @@ jobs:
7065
- name: "Run extra lint checks"
7166
run: |
7267
[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh
73-
74-
- name: "Check for any files unintentionally left out of MANIFEST.in"
75-
run: |
76-
check-manifest
77-
78-
- name: "Verify requirements files"
79-
run: |
80-
python .ci/scripts/check_requirements.py
81-
82-
- name: "Check for pulpcore imports outside of pulpcore.plugin"
83-
run: |
84-
sh .ci/scripts/check_pulpcore_imports.sh
85-
86-
- name: "Check for common gettext problems"
87-
run: |
88-
sh .ci/scripts/check_gettext.sh
68+
...

.github/workflows/sanity.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# WARNING: DO NOT EDIT!
2+
#
3+
# This file was generated by plugin_template, and is managed by it. Please use
4+
# './plugin-template --github pulp_catdog' to update this file.
5+
#
6+
# For more info visit https://github.com/pulp/plugin_template
7+
8+
9+
# This file describes checks that should prevent a premature merge,
10+
# but still let the tests run for demonstrations or experiments.
11+
---
12+
name: "Sanity"
13+
on:
14+
workflow_call:
15+
16+
defaults:
17+
run:
18+
working-directory: "pulp_catdog"
19+
20+
jobs:
21+
sanity:
22+
runs-on: "ubuntu-latest"
23+
24+
steps:
25+
- uses: "actions/checkout@v4"
26+
with:
27+
path: "plugin_template"
28+
# We need the full history for bootstrapping
29+
fetch-depth: 0
30+
31+
- uses: "actions/setup-python@v5"
32+
with:
33+
python-version: "3.11"
34+
35+
- name: "Bootstrap catdog plugin"
36+
working-directory: "plugin_template"
37+
run: |
38+
.ci/bootstrap_catdog.sh
39+
40+
# Below this line we include the steps of the ci workflow of the generated plugin
41+
- name: "Install python dependencies"
42+
run: |
43+
echo ::group::PYDEPS
44+
pip install -r lint_requirements.txt
45+
echo ::endgroup::
46+
47+
- name: "Lint workflow files"
48+
run: |
49+
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows
50+
51+
- name: "Verify bump version config"
52+
run: |
53+
bump-my-version bump --dry-run release
54+
bump-my-version show-bump
55+
56+
- name: "Check for any files unintentionally left out of MANIFEST.in"
57+
run: |
58+
check-manifest
59+
60+
- name: "Verify requirements files"
61+
run: |
62+
python .ci/scripts/check_requirements.py
63+
64+
- name: "Check for pulpcore imports outside of pulpcore.plugin"
65+
run: |
66+
sh .ci/scripts/check_pulpcore_imports.sh
67+
68+
- name: "Check for common gettext problems"
69+
run: |
70+
sh .ci/scripts/check_gettext.sh
71+
...

.github/workflows/test.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,15 @@ jobs:
7979
- name: "Install python dependencies"
8080
run: |
8181
echo ::group::PYDEPS
82-
pip install towncrier twine wheel httpie docker netaddr boto3 ansible mkdocs jq jsonpatch bump-my-version
82+
pip install build towncrier twine wheel httpie docker netaddr boto3 'ansible~=10.3.0' mkdocs jq jsonpatch bump-my-version
8383
echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_catdog/.ci/assets/httpie/" >> $GITHUB_ENV
8484
echo ::endgroup::
8585
8686
- name: "Set environment variables"
8787
run: |
8888
echo "TEST=${{ matrix.env.TEST }}" >> $GITHUB_ENV
89-
if [ "${{ matrix.env.TEST }}" = "performance" ]
90-
then
91-
echo "PERFORMANCE_TEST=${{ matrix.env.PERFORMANCE_TEST }}" >> $GITHUB_ENV
92-
fi
9389
94-
- name: "Before Install"
90+
- name: "Prepare Scenario Definition"
9591
run: |
9692
.github/workflows/scripts/before_install.sh
9793
shell: "bash"
@@ -111,7 +107,7 @@ jobs:
111107
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
112108
GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}"
113109

114-
- name: "Before Script"
110+
- name: "Dump CI Metadata"
115111
run: |
116112
.github/workflows/scripts/before_script.sh
117113
shell: "bash"
@@ -120,7 +116,6 @@ jobs:
120116
ANSIBLE_FORCE_COLOR: "1"
121117
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
122118
GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}"
123-
REDIS_DISABLED: "${{ contains('s3', matrix.env.TEST) }}"
124119

125120
- name: "Script"
126121
run: |

templates/github/.github/workflows/ci.yml.j2

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,22 @@ jobs:
3737
{%- endif %}
3838

3939
check-changes:
40-
runs-on: ubuntu-latest
40+
runs-on: "ubuntu-latest"
4141
outputs:
42-
run_tests: {{ '${{ steps.check.outputs.run_tests }}' }}
43-
run_docs: {{ '${{ steps.check.outputs.run_docs }}' }}
42+
{%- raw %}
43+
run_tests: "${{ steps.check.outputs.run_tests }}"
44+
run_docs: "${{ steps.check.outputs.run_docs }}"
45+
{%- endraw %}
4446
steps:
4547
{{ checkout(depth=0, path=plugin_name) | indent(6) }}
4648

4749
{{ setup_python("3.12") | indent(6) }}
4850

4951
{{ install_python_deps(["gitpython"]) | indent(6) }}
5052

51-
- name: Analyze changed files
52-
shell: bash
53-
id: check
53+
- name: "Analyze changed files"
54+
shell: "bash"
55+
id: "check"
5456
run: |
5557
# We only test docs on the default branch (usually main)
5658
if [[ "{{ '${{ github.base_ref }}' }}" == *"{{ plugin_default_branch }}" ]]; then
@@ -77,17 +79,22 @@ jobs:
7779
needs: "check-changes"
7880
uses: "./.github/workflows/docs.yml"
7981
with:
80-
run_docs: {{ '${{ needs.check-changes.outputs.run_docs }}' }}
82+
{%- raw %}
83+
run_docs: "${{ needs.check-changes.outputs.run_docs }}"
84+
{%- endraw %}
8185
{%- endif %}
8286

8387
lint:
8488
uses: "./.github/workflows/lint.yml"
8589

90+
sanity:
91+
uses: "./.github/workflows/sanity.yml"
92+
8693
build:
8794
needs:
8895
- "check-changes"
8996
- "lint"
90-
if: needs.check-changes.outputs.run_tests == '1'
97+
if: "needs.check-changes.outputs.run_tests == '1'"
9198
uses: "./.github/workflows/build.yml"
9299

93100
test:
@@ -100,15 +107,15 @@ jobs:
100107

101108
deprecations:
102109
runs-on: "ubuntu-latest"
103-
if: github.base_ref == '{{ plugin_default_branch }}'
110+
if: "github.base_ref == '{{ plugin_default_branch }}'"
104111
needs: "test"
105112
steps:
106113
- name: "Create working directory"
107114
run: |
108115
mkdir -p "{{ plugin_name }}"
109116
working-directory: "."
110117
- name: "Download Deprecations"
111-
uses: actions/download-artifact@v4
118+
uses: "actions/download-artifact@v4"
112119
with:
113120
pattern: "deprecations-*"
114121
path: "{{ plugin_name }}"
@@ -132,6 +139,7 @@ jobs:
132139
{%- if is_pulpdocs_member %}
133140
- "docs"
134141
{%- endif %}
142+
- "sanity"
135143
if: "always()"
136144
steps:
137145
- name: "Collect needed jobs results"
@@ -164,3 +172,4 @@ jobs:
164172

165173
check_jobs "$FILTERS"
166174
echo "CI says: Looks good!"
175+
...

0 commit comments

Comments
 (0)