Skip to content

Commit 60557ee

Browse files
committed
Separate sanity checks
1 parent b93d917 commit 60557ee

10 files changed

Lines changed: 211 additions & 91 deletions

File tree

.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 & 3 deletions
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"
@@ -34,9 +34,7 @@ jobs:
3434
path: "pulp-openapi-generator"
3535
- name: "Install python dependencies"
3636
run: |
37-
echo ::group::PYDEPS
3837
pip install build packaging twine wheel mkdocs jq
39-
echo ::endgroup::
4038
- name: "Build package"
4139
run: |
4240
python3 -m build

.github/workflows/ci.yml

Lines changed: 62 additions & 13 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 }}
@@ -32,9 +29,7 @@ jobs:
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+
...

.github/workflows/lint.yml

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,12 @@ jobs:
4343

4444
- name: "Install python dependencies"
4545
run: |
46-
echo ::group::PYDEPS
4746
pip install -r lint_requirements.txt
48-
echo ::endgroup::
4947
5048
- name: "Lint workflow files"
5149
run: |
5250
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows
5351
54-
- name: "Verify bump version config"
55-
run: |
56-
bump-my-version bump --dry-run release
57-
bump-my-version show-bump
58-
5952
# run black separately from flake8 to get a diff
6053
- name: "Run black"
6154
run: |
@@ -67,22 +60,11 @@ jobs:
6760
run: |
6861
flake8
6962
70-
- name: "Run extra lint checks"
71-
run: |
72-
[ ! -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-
8663
- name: "Check for common gettext problems"
8764
run: |
8865
sh .ci/scripts/check_gettext.sh
66+
67+
- name: "Run extra lint checks"
68+
run: |
69+
[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh
70+
...

.github/workflows/sanity.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
pip install -r lint_requirements.txt
44+
45+
- name: "Verify bump version config"
46+
run: |
47+
bump-my-version bump --dry-run release
48+
bump-my-version show-bump
49+
50+
- name: "Check for any files unintentionally left out of MANIFEST.in"
51+
run: |
52+
check-manifest
53+
54+
- name: "Verify requirements files"
55+
run: |
56+
python .ci/scripts/check_requirements.py
57+
58+
- name: "Check for pulpcore imports outside of pulpcore.plugin"
59+
run: |
60+
sh .ci/scripts/check_pulpcore_imports.sh
61+
...

.github/workflows/test.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,14 @@ jobs:
7878
7979
- name: "Install python dependencies"
8080
run: |
81-
echo ::group::PYDEPS
82-
pip install towncrier twine wheel httpie docker netaddr boto3 ansible mkdocs jq jsonpatch bump-my-version
81+
pip install build towncrier twine wheel httpie docker netaddr boto3 'ansible~=10.3.0' mkdocs jq jsonpatch bump-my-version
8382
echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_catdog/.ci/assets/httpie/" >> $GITHUB_ENV
84-
echo ::endgroup::
8583
8684
- name: "Set environment variables"
8785
run: |
8886
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
9387
94-
- name: "Before Install"
88+
- name: "Prepare Scenario Definition"
9589
run: |
9690
.github/workflows/scripts/before_install.sh
9791
shell: "bash"
@@ -111,7 +105,7 @@ jobs:
111105
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
112106
GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}"
113107

114-
- name: "Before Script"
108+
- name: "Dump CI Metadata"
115109
run: |
116110
.github/workflows/scripts/before_script.sh
117111
shell: "bash"
@@ -120,7 +114,6 @@ jobs:
120114
ANSIBLE_FORCE_COLOR: "1"
121115
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
122116
GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}"
123-
REDIS_DISABLED: "${{ contains('s3', matrix.env.TEST) }}"
124117

125118
- name: "Script"
126119
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+
id: "check"
55+
shell: "bash"
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)