Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI files for branch 1.5 #273

Merged
merged 1 commit into from
Jul 17, 2023
Merged
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
4 changes: 3 additions & 1 deletion .ci/scripts/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}


Expand Down
13 changes: 7 additions & 6 deletions .ci/scripts/check_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/template_gitref
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2021.08.26-219-g66afab8
2021.08.26-233-gd6a6b5f
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 }}
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/scripts/update_backport_labels.py
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions .github/workflows/update-labels.yml
Original file line number Diff line number Diff line change
@@ -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 }}
29 changes: 15 additions & 14 deletions .github/workflows/update_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@


---
name: CI Update
name: Certguard CI Update
on:
schedule:
# * is a special character in YAML so you have to quote this string
# runs at 2:30 UTC every Sunday
- cron: '30 2 * * 0'

workflow_dispatch:
inputs:
all_branches:
description: "Run on all branches"
default: 'no'
required: false

jobs:
update:
Expand All @@ -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:
Expand All @@ -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 <pulp-infra@redhat.com>
author: pulpbot <pulp-infra@redhat.com>
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

Expand Down
4 changes: 3 additions & 1 deletion template_config.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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: []
Expand All @@ -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
Expand Down
Loading