From 61c864a1b712a0f2fc29fd8c690c69fd346e16d1 Mon Sep 17 00:00:00 2001 From: pulpbot Date: Mon, 17 Jul 2023 14:27:34 +0000 Subject: [PATCH] Update CI files [noissue] --- .ci/scripts/changelog.py | 4 +- .ci/scripts/check_requirements.py | 13 +++-- .flake8 | 2 + .github/template_gitref | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/nightly.yml | 2 +- .github/workflows/release.yml | 8 +-- .../scripts/update_backport_labels.py | 55 +++++++++++++++++++ .github/workflows/update-labels.yml | 39 +++++++++++++ .github/workflows/update_ci.yml | 29 +++++----- template_config.yml | 4 +- 11 files changed, 131 insertions(+), 29 deletions(-) create mode 100755 .github/workflows/scripts/update_backport_labels.py create mode 100644 .github/workflows/update-labels.yml diff --git a/.ci/scripts/changelog.py b/.ci/scripts/changelog.py index 971d2b7c..2a9e6d7b 100755 --- a/.ci/scripts/changelog.py +++ b/.ci/scripts/changelog.py @@ -25,7 +25,9 @@ def get_changelog_releases(changelog): Get all versions in changelog. """ - versions = re.findall(r"([0-9]+)\.([0-9]+)\.([0-9]+) \(", changelog) + versions = re.findall( + r"([0-9]+)\.([0-9]+)\.([0-9][0-9ab]*) \([0-9]{4}-[0-9]{2}-[0-9]{2}\)", changelog + ) return {".".join(v) for v in versions} diff --git a/.ci/scripts/check_requirements.py b/.ci/scripts/check_requirements.py index ba09fe2b..92ea52b5 100755 --- a/.ci/scripts/check_requirements.py +++ b/.ci/scripts/check_requirements.py @@ -42,12 +42,13 @@ else: errors.append(f"{filename}:{nr}: Unreadable requirement {line}") else: - if not line.startswith("opentelemetry"): - if check_prereleases and req.specifier.prereleases: - if req.name != "pulp-certguard-client": - errors.append( - f"{filename}:{nr}: Prerelease versions found in {line}." - ) + if check_prereleases and req.specifier.prereleases: + # Do not even think about begging for more exceptions! + if ( + not req.name.startswith("opentelemetry") + and req.name != "pulp-certguard-client" + ): + errors.append(f"{filename}:{nr}: Prerelease versions found in {line}.") ops = [op for op, ver in req.specs] spec = str(req.specs) if "~=" in ops: diff --git a/.flake8 b/.flake8 index 5efbc291..674833bf 100644 --- a/.flake8 +++ b/.flake8 @@ -6,6 +6,8 @@ # For more info visit https://github.com/pulp/plugin_template [flake8] exclude = ./docs/*,*/migrations/* +per-file-ignores = */__init__.py: F401 + ignore = E203,W503,Q000,Q003,D100,D104,D106,D200,D205,D400,D401,D402 max-line-length = 100 diff --git a/.github/template_gitref b/.github/template_gitref index 2e6867f0..086fca6b 100644 --- a/.github/template_gitref +++ b/.github/template_gitref @@ -1 +1 @@ -2021.08.26-219-g66afab8 +2021.08.26-233-gd6a6b5f diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2f45e7d2..6ca42af8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -4,7 +4,7 @@ # './plugin-template --github pulp_certguard' to update this file. # # For more info visit https://github.com/pulp/plugin_template -name: "CodeQL" +name: "Certguard CodeQL" on: workflow_dispatch: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e4c79e85..7d311652 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,7 +6,7 @@ # For more info visit https://github.com/pulp/plugin_template --- -name: Certguard Nightly CI/CD +name: Certguard Nightly CI on: schedule: # * is a special character in YAML so you have to quote this string diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 46580fb1..690f7e26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ # For more info visit https://github.com/pulp/plugin_template --- -name: Release Pipeline +name: Certguard Release Pipeline on: workflow_dispatch: inputs: @@ -164,8 +164,8 @@ jobs: path: ruby-client.tar - name: Build docs run: | - pip install towncrier==19.9.0 - towncrier --yes --version 4.0.0.ci + export DJANGO_SETTINGS_MODULE=pulpcore.app.settings + export PULP_SETTINGS=$PWD/.ci/ansible/settings/settings.py make -C docs/ PULP_URL="https://pulp" diagrams html tar -cvf docs/docs.tar docs/_build @@ -251,7 +251,7 @@ jobs: - name: Publish docs to pulpproject.org run: | - tar -xvf docs.tar -C ./docs + tar -xvf docs.tar .github/workflows/scripts/publish_docs.sh tag ${{ github.event.inputs.release }} - name: Deploy plugin to pypi run: bash .github/workflows/scripts/publish_plugin_pypi.sh ${{ github.event.inputs.release }} diff --git a/.github/workflows/scripts/update_backport_labels.py b/.github/workflows/scripts/update_backport_labels.py new file mode 100755 index 00000000..cad7e384 --- /dev/null +++ b/.github/workflows/scripts/update_backport_labels.py @@ -0,0 +1,55 @@ +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by it. Please use +# './plugin-template --github pulp_certguard' to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +import requests +import yaml +import random +import os + + +def random_color(): + """Generates a random 24-bit number in hex""" + color = random.randrange(0, 2**24) + return format(color, "06x") + + +session = requests.Session() +token = os.getenv("GITHUB_TOKEN") + +headers = { + "Authorization": f"token {token}", + "Accept": "application/vnd.github+json", + "X-GitHub-Api-Version": "2022-11-28", +} +session.headers.update(headers) + +# get all labels from the repository's current state +response = session.get("https://api.github.com/repos/pulp/pulp_certguard/labels", headers=headers) +assert response.status_code == 200 +old_labels = set([x["name"] for x in response.json() if x["name"].startswith("backport-")]) + +# get ci_update_branches from template_config.yml +with open("./template_config.yml", "r") as f: + plugin_template = yaml.safe_load(f) +new_labels = set(["backport-" + x for x in plugin_template["ci_update_branches"]]) + +# delete old labels that are not in new labels +for label in old_labels.difference(new_labels): + response = session.delete( + f"https://api.github.com/repos/pulp/pulp_certguard/labels/{label}", headers=headers + ) + assert response.status_code == 204 + +# create new labels that are not in old labels +for label in new_labels.difference(old_labels): + color = random_color() + response = session.post( + "https://api.github.com/repos/pulp/pulp_certguard/labels", + headers=headers, + json={"name": label, "color": color}, + ) + assert response.status_code == 201 diff --git a/.github/workflows/update-labels.yml b/.github/workflows/update-labels.yml new file mode 100644 index 00000000..489970fd --- /dev/null +++ b/.github/workflows/update-labels.yml @@ -0,0 +1,39 @@ +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by it. Please use +# './plugin-template --github pulp_certguard' to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + + +--- +name: Certguard Update Labels +on: + push: + branches: + - main + paths: + - 'template_config.yml' + +jobs: + update_backport_labels: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v3 + with: + python-version: "3.8" + - name: Configure Git with pulpbot name and email + run: | + git config --global user.name 'pulpbot' + git config --global user.email 'pulp-infra@redhat.com' + - name: Install python dependencies + run: | + echo ::group::PYDEPS + pip install requests pyyaml + echo ::endgroup:: + - uses: actions/checkout@v3 + - name: Update labels + run: | + python3 .github/workflows/scripts/update_backport_labels.py + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} diff --git a/.github/workflows/update_ci.yml b/.github/workflows/update_ci.yml index ffae38e7..d89fc0e8 100644 --- a/.github/workflows/update_ci.yml +++ b/.github/workflows/update_ci.yml @@ -7,7 +7,7 @@ --- -name: CI Update +name: Certguard CI Update on: schedule: # * is a special character in YAML so you have to quote this string @@ -15,11 +15,6 @@ on: - cron: '30 2 * * 0' workflow_dispatch: - inputs: - all_branches: - description: "Run on all branches" - default: 'no' - required: false jobs: update: @@ -31,7 +26,9 @@ jobs: steps: - uses: actions/checkout@v3 with: - fetch-depth: 1 + repository: pulp/plugin_template + path: plugin_template + fetch-depth: 0 - uses: actions/setup-python@v3 with: @@ -47,24 +44,28 @@ jobs: run: | git config --global user.name 'pulpbot' git config --global user.email 'pulp-infra@redhat.com' - - - name: Set short_ref - id: vars - run: echo short_ref=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT + - uses: actions/checkout@v3 + with: + path: pulp-certguard + ref: 'main' + fetch-depth: 0 - name: Run update + working-directory: pulp-certguard run: | - .github/workflows/scripts/update_ci.sh + ../plugin_template/scripts/update_ci.sh - name: Create Pull Request for CI files uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.RELEASE_TOKEN }} + path: pulp-certguard committer: pulpbot author: pulpbot - title: 'Update CI files from ${{ steps.vars.outputs.short_ref }} branch' + title: 'Update CI files for branch main' body: '[noissue]' - branch: 'create-pull-request/${{ steps.vars.outputs.short_ref }}/patch' + branch: 'update-ci/main' + base: 'main' commit-message: | Update CI files diff --git a/template_config.yml b/template_config.yml index 58680752..34ffd4fa 100644 --- a/template_config.yml +++ b/template_config.yml @@ -1,7 +1,7 @@ # This config represents the latest values used when running the plugin-template. Any settings that # were not present before running plugin-template have been added with their default values. -# generated with plugin_template@2021.08.26-212-g18b9346 +# generated with plugin_template@2021.08.26-233-gd6a6b5f additional_repos: - branch: '1.10' @@ -15,6 +15,7 @@ check_stray_pulpcore_imports: true ci_env: {} ci_trigger: '{pull_request: {branches: [''*'']}}' ci_update_branches: [] +ci_update_docs: false cli_package: pulp-cli cli_repo: https://github.com/pulp/pulp-cli.git core_import_allowed: [] @@ -25,6 +26,7 @@ disabled_redis_runners: [] doc_requirements_from_pulpcore: true docker_fixtures: false docs_test: true +extra_docs_requirements: [] flake8: true flake8_ignore: [] github_org: pulp