Skip to content

Commit

Permalink
Switch app setup to pyproject.toml
Browse files Browse the repository at this point in the history
Update the CI files too.

[noissue]
  • Loading branch information
mdellweg committed Jan 18, 2024
1 parent 1397bf0 commit 817bb9c
Show file tree
Hide file tree
Showing 24 changed files with 332 additions and 193 deletions.
4 changes: 2 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ values =

[bumpversion:file:./pulpcore/cli/gem/__init__.py]

[bumpversion:file:./pulp-glue-gem/setup.py]
[bumpversion:file:./pulp-glue-gem/pyproject.toml]

[bumpversion:file:./setup.py]
[bumpversion:file:./pyproject.toml]
2 changes: 1 addition & 1 deletion .ci/scripts/collect_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import toml
from git import GitCommandError, Repo
from pkg_resources import parse_version
from packaging.version import parse as parse_version

# Read Towncrier settings
tc_settings = toml.load("pyproject.toml")["tool"]["towncrier"]
Expand Down
4 changes: 2 additions & 2 deletions .ci/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ then
fi

towncrier build --yes --version "${NEW_VERSION}"
bumpversion release --commit --message "Release {new_version}" --tag --tag-name "{new_version}" --tag-message "Release {new_version}" --allow-dirty
bumpversion patch --commit
bump2version release --commit --message "Release {new_version}" --tag --tag-name "{new_version}" --tag-message "Release {new_version}" --allow-dirty
bump2version patch --commit

git push origin "${BRANCH}" "${NEW_VERSION}"
2 changes: 1 addition & 1 deletion .ci/settings/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CONTENT_ORIGIN = "http://localhost:8080/"
ALLOWED_EXPORT_PATHS = ["/tmp"]
TELEMETRY = False
ANALYTICS = False
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Build"

on:
workflow_call:

jobs:
build:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- uses: "actions/cache@v3"
with:
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/*constraints.lock', '**/setup.py', '**/pyproject.toml') }}"
restore-keys: |
${{ runner.os }}-pip-
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.11"
- name: "Install python dependencies"
run: |
pip install build setuptools wheel
- name: "Build wheels"
run: |
make build
- name: "Upload wheels"
uses: "actions/upload-artifact@v4"
with:
name: "pulp_cli_packages"
path: |
pulp-glue-gem/dist/
dist/
if-no-files-found: "error"
retention-days: 5
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Manually install from sources
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/collect_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
ref: "main"
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Setup git
Expand All @@ -20,7 +20,7 @@ jobs:
git config user.email [email protected]
- name: Collect changes
run: |
pip install GitPython toml
pip install GitPython packaging toml
python3 .ci/scripts/collect_changes.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
Expand Down
32 changes: 19 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
name: Lint
name: "Lint"

on:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
python:
- "3.8"
- "3.11"
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
- uses: "actions/checkout@v4"
- uses: "actions/cache@v4"
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/*constraints.lock', '**/setup.py', '**/pyproject.toml') }}
path: "~/.cache/pip"
key: "${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/*constraints.lock', '**/setup.py', '**/pyproject.toml') }}"
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python
uses: actions/setup-python@v4
- name: "Download wheels"
uses: "actions/download-artifact@v4"
with:
python-version: ${{ matrix.python }}
- name: Install python dependencies
run: pip install -r lint_requirements.txt
- name: Lint code
run: make lint
name: "pulp_cli_packages"
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "${{ matrix.python }}"
- name: "Install python dependencies"
run: |
pip install dist/pulp_cli_gem-*.whl pulp-glue-gem/dist/pulp_glue_gem-*.whl -r lint_requirements.txt
- name: "Lint code"
run: |
make lint
8 changes: 6 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
name: pulp-cli Nightly
name: "pulp-cli Nightly"

on:
schedule:
- cron: "15 3 * * *"
workflow_dispatch:

jobs:
build:
uses: "./.github/workflows/build.yml"
test:
needs:
- "build"
uses: "./.github/workflows/test.yml"
codeql:
uses: "./.github/workflows/codeql.yml"
collect_changes:
uses: "./.github/workflows/collect_changes.yml"
secrets: inherit
secrets: "inherit"
55 changes: 32 additions & 23 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,66 @@
name: pulp-cli CI
name: "pulp-cli CI"

on:
pull_request:

concurrency:
group: main-${{ github.ref_name }}-${{ github.workflow }}
group: "main-${{ github.ref_name }}-${{ github.workflow }}"
cancel-in-progress: true

jobs:
build:
uses: "./.github/workflows/build.yml"
lint:
needs:
- "build"
uses: "./.github/workflows/lint.yml"
test:
needs:
- lint
- "lint"
uses: "./.github/workflows/test.yml"
codeql:
needs:
- lint
- "lint"
uses: "./.github/workflows/codeql.yml"
check-commits:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v4
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.11"
- name: Install python dependencies
run: pip install toml pygithub
- name: Check commit message
- name: "Install python dependencies"
run: |
pip install toml pygithub
- name: "Check commit message"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }}
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}"
run: |
for sha in $(curl -H "Authorization: token $GITHUB_TOKEN" $GITHUB_CONTEXT | jq '.[].sha' | sed 's/"//g')
for SHA in $(curl -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_CONTEXT" | jq -r '.[].sha')
do
python .ci/scripts/validate_commit_message.py $sha
python .ci/scripts/validate_commit_message.py "$SHA"
VALUE=$?
if [ "$VALUE" -gt 0 ]; then
exit "$VALUE"
fi
done
shell: bash
shell: "bash"
ready-to-ship:
# This is a dummy dependent task to have a single entry for the branch protection rules.
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
needs:
- check-commits
- lint
- test
- codeql
- "check-commits"
- "lint"
- "test"
- "codeql"
if: "always()"
steps:
- name: All set
- name: "Collect needed jobs results"
run: |
echo '${{toJson(needs)}}' | jq -r 'to_entries[]|select(.value.result!="success")|.key + ": " + .value.result'
echo '${{toJson(needs)}}' | jq -e 'to_entries|map(select(.value.result!="success"))|length == 0'
echo "CI says: Looks good!"
55 changes: 55 additions & 0 deletions .github/workflows/pr_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: "Pulp CLI PR static checks"
on:
pull_request_target:
types: ["opened", "synchronize", "reopened"]

# This workflow runs with elevated permissions.
# Do not even think about running a single bit of code from the PR.
# Static analysis should be fine however.

concurrency:
group: "${{ github.event.pull_request.number }}-${{ github.workflow }}"
cancel-in-progress: true

jobs:
single_commit:
runs-on: "ubuntu-latest"
name: "Label multiple commit PR"
permissions:
pull-requests: "write"
steps:
- uses: "actions/checkout@v4"
with:
fetch-depth: 0
- name: "Commit Count Check"
run: |
git fetch origin ${{ github.event.pull_request.head.sha }}
echo "COMMIT_COUNT=$(git log --oneline --no-merges origin/${{ github.base_ref }}..${{ github.event.pull_request.head.sha }} | wc -l)" >> "$GITHUB_ENV"
- uses: "actions/github-script@v7"
with:
script: |
const labelName = "multi-commit";
const { COMMIT_COUNT } = process.env;
if (COMMIT_COUNT == 1)
{
try {
await github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: labelName,
});
} catch(err) {
}
}
else
{
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [labelName],
});
}
17 changes: 11 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,35 @@ name: "pulp-cli Publish"
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]"
- "[0-9]+.[0-9]+.[0-9]+"

jobs:
build:
uses: "./.github/workflows/build.yml"
publish-pypi:
name: "Publish to PyPI"
needs: "build"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
- name: "Download wheels"
uses: "actions/download-artifact@v4"
with:
name: "pulp_cli_packages"
- name: "Set up Python"
uses: "actions/setup-python@v4"
uses: "actions/setup-python@v5"
with:
python-version: '3.x'
python-version: "3.x"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install twine
- name: "Build and publish"
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: "${{ secrets.PYPI_API_TOKEN }}"
run: |
cd pulp-glue-gem
python setup.py sdist bdist_wheel
twine upload dist/*
cd ..
python setup.py sdist bdist_wheel
twine upload dist/*
29 changes: 15 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
name: pulp-cli Release
name: "pulp-cli Release"

on:
workflow_dispatch
workflow_dispatch:

jobs:
release:
name: Release
runs-on: ubuntu-latest
name: "Release"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: "actions/checkout@v4"
with:
token: ${{ secrets.RELEASE_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
token: "${{ secrets.RELEASE_TOKEN }}"
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: '3.x'
- name: Install dependencies
python-version: "3.x"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install bump2version towncrier
- name: Setup git
pip install bump2version towncrier~=23.11.0
- name: "Setup git"
run: |
git config user.name pulpbot
git config user.email [email protected]
- name: Release
run: .ci/scripts/release.sh
- name: "Release"
run: |
.ci/scripts/release.sh
Loading

0 comments on commit 817bb9c

Please sign in to comment.