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 #160

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
25 changes: 0 additions & 25 deletions .ci/scripts/update_ci_branches.py

This file was deleted.

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-225-gbfce9ef
2021.08.26-232-g10acbaa
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ jobs:
path: ruby-client.tar
- name: Build docs
run: |
pip install towncrier==19.9.0
towncrier --yes
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
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_maven' 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_maven/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_maven/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_maven/labels",
headers=headers,
json={"name": label, "color": color},
)
assert response.status_code == 201
33 changes: 0 additions & 33 deletions .github/workflows/scripts/update_ci.sh

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/update-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulp_maven' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template


---
name: 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 '[email protected]'
- 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 }}

30 changes: 13 additions & 17 deletions .github/workflows/update_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -29,14 +24,11 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1

- uses: actions/checkout@v3
with:
repository: pulp/plugin_template
path: ../plugin_template
path: plugin_template
fetch-depth: 0

- uses: actions/setup-python@v3
with:
Expand All @@ -52,24 +44,28 @@ jobs:
run: |
git config --global user.name 'pulpbot'
git config --global user.email '[email protected]'

- name: Set short_ref
id: vars
run: echo short_ref=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
path: pulp_maven
ref: 'main'
fetch-depth: 0

- name: Run update
working-directory: pulp_maven
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_maven
committer: pulpbot <[email protected]>
author: pulpbot <[email protected]>
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
Loading