-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should help to keep the CI consistent across multiple cli plugin repositories. [noissue]
- Loading branch information
Showing
36 changed files
with
1,068 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
import toml | ||
from cookiecutter.main import cookiecutter | ||
|
||
if __name__ == "__main__": | ||
sections = [] | ||
overwrite = True | ||
|
||
with open("pyproject.toml") as fp: | ||
config = toml.load(fp)["tool"]["pulp_cli_template"] | ||
|
||
sections.append("ci") | ||
|
||
if config["docs"]: | ||
sections.append("docs") | ||
|
||
cutter_path = Path(__file__).parent.parent.parent / "cookiecutter" | ||
|
||
for section in sections: | ||
print(f"Apply {section} template") | ||
cookiecutter( | ||
str(cutter_path / section), | ||
no_input=True, | ||
extra_context=config, | ||
overwrite_if_exists=overwrite, | ||
output_dir="..", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
name: Collect changes | ||
name: "Collect changes" | ||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
collect-changes: | ||
runs-on: ubuntu-latest | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: "actions/checkout@v4" | ||
with: | ||
ref: "main" | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v5 | ||
- uses: "actions/setup-python@v5" | ||
with: | ||
python-version: "3.11" | ||
- name: Setup git | ||
- name: "Setup git" | ||
run: | | ||
git config user.name pulpbot | ||
git config user.email [email protected] | ||
- name: Collect changes | ||
- name: "Collect changes" | ||
run: | | ||
pip install GitPython packaging toml | ||
python3 .ci/scripts/collect_changes.py | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
- name: "Create Pull Request" | ||
uses: "peter-evans/create-pull-request@v5" | ||
with: | ||
token: ${{ secrets.RELEASE_TOKEN }} | ||
token: "${{ secrets.RELEASE_TOKEN }}" | ||
title: "Update Changelog" | ||
body: "" | ||
branch: "update_changes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"app_label": "noname", | ||
"glue": true, | ||
"docs": false, | ||
"translations": false, | ||
"test_matrix": "- python: \"3.11\"\nimage_tag: \"nightly\"\npulp_api_root: \"/relocated/djnd/\"\n- python: \"3.6\"\nimage_tag: \"latest\"\nlower_bounds: true", | ||
"__app_label_suffix": "{{ cookiecutter.app_label and '-' + cookiecutter.app_label }}", | ||
"__project_name": "pulp-cli{{ cookiecutter.__app_label_suffix }}", | ||
"__project_slug": "{{ cookiecutter.__project_name | lower | replace(' ', '_') }}", | ||
"_copy_without_render": [ | ||
".github/workflows/collect_changes.yml", | ||
".github/workflows/pr.yml", | ||
".github/workflows/release.yml", | ||
".github/workflows/release_branch.yml", | ||
".github/workflows/pr_checks.yml" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{%- raw %} | ||
- uses: "actions/cache@v4" | ||
with: | ||
path: "~/.cache/pip" | ||
key: "${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/*constraints.lock', '**/setup.py', '**/pyproject.toml') }}" | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
{%- endraw %} |
89 changes: 89 additions & 0 deletions
89
cookiecutter/ci/{{ cookiecutter.__project_slug }}/.ci/run_container.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/sh | ||
|
||
# This file is shared between some projects please keep all copies in sync | ||
# Known places: | ||
# - https://github.com/pulp/pulp-cli/blob/main/.ci/run_container.sh | ||
# - https://github.com/pulp/pulp-cli-deb/blob/main/.ci/run_container.sh | ||
# - https://github.com/pulp/pulp-cli-gem/blob/main/.ci/run_container.sh | ||
# - https://github.com/pulp/pulp-cli-maven/blob/main/.ci/run_container.sh | ||
# - https://github.com/pulp/pulp-cli-ostree/blob/main/.ci/run_container.sh | ||
# - https://github.com/pulp/squeezer/blob/develop/tests/run_container.sh | ||
|
||
set -eu | ||
|
||
BASEPATH="$(dirname "$(readlink -f "$0")")" | ||
export BASEPATH | ||
|
||
if [ -z "${CONTAINER_RUNTIME:+x}" ] | ||
then | ||
if ls /usr/bin/podman | ||
then | ||
CONTAINER_RUNTIME=podman | ||
else | ||
CONTAINER_RUNTIME=docker | ||
fi | ||
fi | ||
export CONTAINER_RUNTIME | ||
|
||
if [ -z "${KEEP_CONTAINER:+x}" ] | ||
then | ||
RM="yes" | ||
else | ||
RM="" | ||
fi | ||
|
||
IMAGE_TAG="${IMAGE_TAG:-latest}" | ||
FROM_TAG="${FROM_TAG:-latest}" | ||
|
||
if [ "${CONTAINER_FILE:+x}" ] | ||
then | ||
IMAGE_TAG="ephemeral-build" | ||
"${CONTAINER_RUNTIME}" build --file "${BASEPATH}/assets/${CONTAINER_FILE}" --build-arg FROM_TAG="${FROM_TAG}" --tag ghcr.io/pulp/pulp:"${IMAGE_TAG}" . | ||
fi | ||
|
||
if [ "$(getenforce)" = "Enforcing" ]; then | ||
SELINUX="yes" | ||
else | ||
SELINUX="" | ||
fi; | ||
|
||
"${CONTAINER_RUNTIME}" run ${RM:+--rm} --env S6_KEEP_ENV=1 ${PULP_API_ROOT:+--env PULP_API_ROOT} --detach --name "pulp-ephemeral" --volume "${BASEPATH}/settings:/etc/pulp${SELINUX:+:Z}" --publish "8080:80" "ghcr.io/pulp/pulp:${IMAGE_TAG}" | ||
|
||
# shellcheck disable=SC2064 | ||
trap "${CONTAINER_RUNTIME} stop pulp-ephemeral" EXIT | ||
# shellcheck disable=SC2064 | ||
trap "${CONTAINER_RUNTIME} stop pulp-ephemeral" INT | ||
|
||
echo "Wait for pulp to start." | ||
for counter in $(seq 40 -1 0) | ||
do | ||
if [ "$counter" = "0" ] | ||
then | ||
echo "FAIL." | ||
"${CONTAINER_RUNTIME}" images | ||
"${CONTAINER_RUNTIME}" ps -a | ||
"${CONTAINER_RUNTIME}" logs "pulp-ephemeral" | ||
exit 1 | ||
fi | ||
|
||
sleep 3 | ||
if curl --fail "http://localhost:8080${PULP_API_ROOT:-/pulp/}api/v3/status/" > /dev/null 2>&1 | ||
then | ||
echo "SUCCESS." | ||
break | ||
fi | ||
echo "." | ||
done | ||
|
||
# show pulpcore/plugin versions we're using | ||
curl -s "http://localhost:8080${PULP_API_ROOT:-/pulp/}api/v3/status/" | jq '.versions|map({key: .component, value: .version})|from_entries' | ||
|
||
# Set admin password | ||
"${CONTAINER_RUNTIME}" exec "pulp-ephemeral" pulpcore-manager reset-admin-password --password password | ||
|
||
if [ -d "${BASEPATH}/container_setup.d/" ] | ||
then | ||
run-parts --regex '^[0-9]+-[-_[:alnum:]]*\.sh$' "${BASEPATH}/container_setup.d/" | ||
fi | ||
|
||
PULP_LOGGING="${CONTAINER_RUNTIME}" "$@" |
11 changes: 11 additions & 0 deletions
11
cookiecutter/ci/{{ cookiecutter.__project_slug }}/.ci/scripts/check_click_for_mypy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/env python3 | ||
|
||
import sys | ||
|
||
import click | ||
from packaging.version import parse | ||
|
||
if parse(click.__version__) < parse("8.1.1") or parse(click.__version__) >= parse("8.2"): | ||
print("🚧 Linting with mypy is currently only supported with click~=8.1.1. 🚧") | ||
print("🔧 Please run `pip install click~=8.1.1` first. 🔨") | ||
sys.exit(1) |
Oops, something went wrong.