Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/scripts/pr_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def main():
f".{item['directory']}" for item in PYPROJECT_TOML["tool"]["towncrier"]["type"]
}
except KeyError:
CHANGELOG_EXTS = {"feature", "bugfix", "doc", "removal", "misc"}
CHANGELOG_EXTS = {".feature", ".bugfix", ".doc", ".removal", ".misc"}

repo = Repo(".")

Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
path: "plugin_template"
# We need the full history for bootstrapping
fetch-depth: 0
- uses: actions/setup-python@v5
- uses: "actions/setup-python@v5"
with:
python-version: "3.11"
- name: "Bootstrap catdog plugin"
Expand All @@ -34,9 +34,7 @@ jobs:
path: "pulp-openapi-generator"
- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install build packaging twine wheel mkdocs jq
echo ::endgroup::
- name: "Build package"
run: |
python3 -m build
Expand Down
75 changes: 62 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
name: Test bootstrapping a plugin
on:
pull_request:
branches:
- '*'
name: "Test bootstrapping a plugin"
on: {pull_request: {branches: ['*']}}

concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
Expand Down Expand Up @@ -32,9 +29,7 @@ jobs:
# Below this line we include the steps of the ci workflow of the generated plugin
- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install requests pygithub
echo ::endgroup::
pip install requests pygithub pyyaml
- name: "Check commit message"
# This will fail for our fake plugin
if: false
Expand All @@ -46,11 +41,38 @@ jobs:
run: |
.github/workflows/scripts/check_commit.sh

check-changes:
runs-on: "ubuntu-latest"
outputs:
run_tests: "${{ steps.check.outputs.run_tests }}"
run_docs: "${{ steps.check.outputs.run_docs }}"
steps:
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
path: "plugin_template"

- name: "Analyze changed files"
id: "check"
shell: "bash"
working-directory: "plugin_template"
run: |
# This check is completely gutted here. It doesn't play nice with boostrapping.
# We just assume we want to see all tests.
echo "run_docs=1" >> $GITHUB_OUTPUT
echo "run_tests=1" >> $GITHUB_OUTPUT

lint:
uses: "./.github/workflows/lint.yml"

sanity:
uses: "./.github/workflows/sanity.yml"

build:
needs: "lint"
needs:
- "check-changes"
- "lint"
if: "needs.check-changes.outputs.run_tests == '1'"
uses: "./.github/workflows/build.yml"

test:
Expand All @@ -62,15 +84,15 @@ jobs:

deprecations:
runs-on: "ubuntu-latest"
if: github.base_ref == 'main'
if: "github.base_ref == 'main'"
needs: "test"
steps:
- name: "Create working directory"
run: |
mkdir -p "pulp_catdog"
working-directory: "."
- name: "Download Deprecations"
uses: actions/download-artifact@v4
uses: "actions/download-artifact@v4"
with:
pattern: "deprecations-*"
path: "pulp_catdog"
Expand All @@ -84,14 +106,41 @@ jobs:
# This is a dummy dependent task to have a single entry for the branch protection rules.
runs-on: "ubuntu-latest"
needs:
- "check-changes"
- "check-commits"
- "lint"
- "test"
- "sanity"
if: "always()"
steps:
- name: "Collect needed jobs results"
working-directory: "."
run: |
echo '${{toJson(needs)}}' | jq -r 'to_entries[]|select(.value.result!="success")|.key + ": " + .value.result'
echo '${{toJson(needs)}}' | jq -e 'to_entries|map(select(.value.result!="success"))|length == 0'
RUN_TESTS=${{ needs.check-changes.outputs.run_tests }}
RUN_DOCS=${{ needs.check-changes.outputs.run_docs }}

check_jobs() {
local filter="$1"
local needs_json='${{toJson(needs)}}'
# output failed jobs after filter
echo "$needs_json" | jq -r "to_entries[]|select($filter)|select(.value.result!=\"success\")|.key + \": \" + .value.result"
# fails if not all selected jobs passed
echo "$needs_json" | jq -e "to_entries|map(select($filter))|map(select(.value.result!=\"success\"))|length == 0"
}

if [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "1" ]; then
FILTERS="true" # check all jobs
elif [ "$RUN_TESTS" == "1" ] && [ "$RUN_DOCS" == "0" ]; then
echo "Skipping docs: running on non-default branch"
FILTERS='.key != "docs"'
elif [ "$RUN_TESTS" == "0" ] && [ "$RUN_DOCS" == "1" ]; then
echo "Skipping tests: only doc changes"
FILTERS='.key != "lint" and .key != "test"'
else # RUN_TESTS=0, RUN_DOCS=0
echo "What is this PR doing??"
FILTERS='.key != "lint" and .key != "test" and .key != "docs"'
fi

check_jobs "$FILTERS"
echo "CI says: Looks good!"
...
28 changes: 5 additions & 23 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,12 @@ jobs:

- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install -r lint_requirements.txt
echo ::endgroup::

- name: "Lint workflow files"
run: |
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows

- name: "Verify bump version config"
run: |
bump-my-version bump --dry-run release
bump-my-version show-bump

# run black separately from flake8 to get a diff
- name: "Run black"
run: |
Expand All @@ -67,22 +60,11 @@ jobs:
run: |
flake8

- name: "Run extra lint checks"
run: |
[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh

- name: "Check for any files unintentionally left out of MANIFEST.in"
run: |
check-manifest

- name: "Verify requirements files"
run: |
python .ci/scripts/check_requirements.py

- name: "Check for pulpcore imports outside of pulpcore.plugin"
run: |
sh .ci/scripts/check_pulpcore_imports.sh

- name: "Check for common gettext problems"
run: |
sh .ci/scripts/check_gettext.sh

- name: "Run extra lint checks"
run: |
[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh
...
61 changes: 61 additions & 0 deletions .github/workflows/sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_catdog' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template


# This file describes checks that should prevent a premature merge,
# but still let the tests run for demonstrations or experiments.
---
name: "Sanity"
on:
workflow_call:

defaults:
run:
working-directory: "pulp_catdog"

jobs:
sanity:
runs-on: "ubuntu-latest"

steps:
- uses: "actions/checkout@v4"
with:
path: "plugin_template"
# We need the full history for bootstrapping
fetch-depth: 0

- uses: "actions/setup-python@v5"
with:
python-version: "3.11"

- name: "Bootstrap catdog plugin"
working-directory: "plugin_template"
run: |
.ci/bootstrap_catdog.sh

# Below this line we include the steps of the ci workflow of the generated plugin
- name: "Install python dependencies"
run: |
pip install -r lint_requirements.txt

- name: "Verify bump version config"
run: |
bump-my-version bump --dry-run release
bump-my-version show-bump

- name: "Check for any files unintentionally left out of MANIFEST.in"
run: |
check-manifest

- name: "Verify requirements files"
run: |
python .ci/scripts/check_requirements.py

- name: "Check for pulpcore imports outside of pulpcore.plugin"
run: |
sh .ci/scripts/check_pulpcore_imports.sh
...
13 changes: 3 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,14 @@ jobs:

- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install towncrier twine wheel httpie docker netaddr boto3 ansible mkdocs jq jsonpatch bump-my-version
pip install build towncrier twine wheel httpie docker netaddr boto3 'ansible~=10.3.0' mkdocs jq jsonpatch bump-my-version
echo "HTTPIE_CONFIG_DIR=$GITHUB_WORKSPACE/pulp_catdog/.ci/assets/httpie/" >> $GITHUB_ENV
echo ::endgroup::

- name: "Set environment variables"
run: |
echo "TEST=${{ matrix.env.TEST }}" >> $GITHUB_ENV
if [ "${{ matrix.env.TEST }}" = "performance" ]
then
echo "PERFORMANCE_TEST=${{ matrix.env.PERFORMANCE_TEST }}" >> $GITHUB_ENV
fi

- name: "Before Install"
- name: "Prepare Scenario Definition"
run: |
.github/workflows/scripts/before_install.sh
shell: "bash"
Expand All @@ -111,7 +105,7 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}"

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

- name: "Script"
run: |
Expand Down
29 changes: 19 additions & 10 deletions templates/github/.github/workflows/ci.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,22 @@ jobs:
{%- endif %}

check-changes:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
outputs:
run_tests: {{ '${{ steps.check.outputs.run_tests }}' }}
run_docs: {{ '${{ steps.check.outputs.run_docs }}' }}
{%- raw %}
run_tests: "${{ steps.check.outputs.run_tests }}"
run_docs: "${{ steps.check.outputs.run_docs }}"
{%- endraw %}
steps:
{{ checkout(depth=0, path=plugin_name) | indent(6) }}

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

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

- name: Analyze changed files
shell: bash
id: check
- name: "Analyze changed files"
id: "check"
shell: "bash"
run: |
# We only test docs on the default branch (usually main)
if [[ "{{ '${{ github.base_ref }}' }}" == *"{{ plugin_default_branch }}" ]]; then
Expand All @@ -77,17 +79,22 @@ jobs:
needs: "check-changes"
uses: "./.github/workflows/docs.yml"
with:
run_docs: {{ '${{ needs.check-changes.outputs.run_docs }}' }}
{%- raw %}
run_docs: "${{ needs.check-changes.outputs.run_docs }}"
{%- endraw %}
{%- endif %}

lint:
uses: "./.github/workflows/lint.yml"

sanity:
uses: "./.github/workflows/sanity.yml"

build:
needs:
- "check-changes"
- "lint"
if: needs.check-changes.outputs.run_tests == '1'
if: "needs.check-changes.outputs.run_tests == '1'"
uses: "./.github/workflows/build.yml"

test:
Expand All @@ -100,15 +107,15 @@ jobs:

deprecations:
runs-on: "ubuntu-latest"
if: github.base_ref == '{{ plugin_default_branch }}'
if: "github.base_ref == '{{ plugin_default_branch }}'"
needs: "test"
steps:
- name: "Create working directory"
run: |
mkdir -p "{{ plugin_name }}"
working-directory: "."
- name: "Download Deprecations"
uses: actions/download-artifact@v4
uses: "actions/download-artifact@v4"
with:
pattern: "deprecations-*"
path: "{{ plugin_name }}"
Expand All @@ -132,6 +139,7 @@ jobs:
{%- if is_pulpdocs_member %}
- "docs"
{%- endif %}
- "sanity"
if: "always()"
steps:
- name: "Collect needed jobs results"
Expand Down Expand Up @@ -164,3 +172,4 @@ jobs:

check_jobs "$FILTERS"
echo "CI says: Looks good!"
...
Loading
Loading