-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add cookiecutter templates for CI #879
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,28 @@ | ||
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 was deleted.
Oops, something went wrong.
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remind me again what was the mypy issue with
click>=8.2
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they changed some annotations in incompatible ways. I found no way to lint with 8.1.1 and 8.2 simultaneously. Maybe it's time to try again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, the answer is much simpler: The latest version of click is 8.1.7.