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

Migrate CI pipeline to use hatch #574

Merged
merged 5 commits into from
Nov 25, 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
16 changes: 16 additions & 0 deletions .github/actions/initialize-hatch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Initialize Hatch"
description: "Install hatch & create an environment"
inputs:
environment-name:
description: "Which environment to create"
default: "default"
required: false
runs:
using: "composite"
steps:
- name: "Install hatch"
run: pip install -r requirements-bootstrap.txt
shell: "bash"
- name: "Create environment"
run: "hatch --verbose env create ${{ inputs.environment-name }}"
shell: "bash"
19 changes: 0 additions & 19 deletions .github/actions/install-dependencies/action.sh

This file was deleted.

25 changes: 0 additions & 25 deletions .github/actions/install-dependencies/action.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .github/actions/publish-docs-with-mike/action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -eo pipefail

hatch -e docs shell

echo "::group::Configure Git User"
"${GITHUB_ACTION_PATH}/configure_git_user.sh"
echo "::endgroup::"
Expand Down
76 changes: 29 additions & 47 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ jobs:
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
with:
test-requirements: "true"
- name: Initialize Hatch
uses: ./.github/actions/initialize-hatch

- name: Run bandit
run: bandit --ini .bandit -r .
run: hatch run bandit-ci

black:
runs-on: ubuntu-latest
Expand All @@ -35,13 +33,11 @@ jobs:
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
with:
test-requirements: "true"
- name: Initialize Hatch
uses: ./.github/actions/initialize-hatch

- name: Run black
run: black --check .
run: hatch run black-check

flake8:
runs-on: ubuntu-latest
Expand All @@ -51,13 +47,11 @@ jobs:
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
with:
test-requirements: "true"
- name: Initialize Hatch
uses: ./.github/actions/initialize-hatch

- name: Run flake8
run: flake8
run: hatch run flake8-check

isort:
runs-on: ubuntu-latest
Expand All @@ -67,14 +61,11 @@ jobs:
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
with:
requirements: "true"
test-requirements: "true"
- name: Initialize Hatch
uses: ./.github/actions/initialize-hatch

- name: Run isort
run: isort --check-only .
run: hatch run isort-check

mypy:
runs-on: ubuntu-latest
Expand All @@ -84,15 +75,11 @@ jobs:
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
with:
requirements: "true"
test-requirements: "true"
- name: Initialize Hatch
uses: ./.github/actions/initialize-hatch

- name: Run mypy
run: mypy

run: hatch run typing

renovate:
runs-on: ubuntu-latest
Expand All @@ -114,14 +101,11 @@ jobs:
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
uses: ./.github/actions/install-dependencies
with:
requirements: "true"
test-requirements: "true"
- name: Initialize Hatch
uses: ./.github/actions/initialize-hatch

- name: Run pytest
run: pytest --cov-report xml:coverage-${{ matrix.python-version }}.xml --junitxml=test-results-${{ matrix.python-version }}.xml
run: hatch run test-ci --cov-report xml:coverage-${{ matrix.python-version }}.xml --junitxml=test-results-${{ matrix.python-version }}.xml

- name: Upload pytest test results artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
Expand Down Expand Up @@ -177,9 +161,11 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Initialize Hatch
uses: ./.github/actions/initialize-hatch

- name: Validate docs
run: ./docker/validate_docs.sh
run: hatch run test-docs-examples

build-docs:
runs-on: ubuntu-latest
Expand All @@ -191,15 +177,13 @@ jobs:
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: Initialize Hatch
uses: ./.github/actions/initialize-hatch
with:
requirements: "true"
docs-requirements: "true"
environment-name: "docs"

- name: Build Docs
run: mkdocs build --strict
run: hatch run docs:build

- name: Upload coverage results artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
Expand All @@ -217,12 +201,10 @@ jobs:
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: Initialize Hatch
uses: ./.github/actions/initialize-hatch
with:
requirements: "true"
docs-requirements: "true"
environment-name: "docs"

- name: Push documentation changes
uses: ./.github/actions/publish-docs-with-mike
Expand Down
3 changes: 0 additions & 3 deletions docker/validate_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# this is set so that the script fails if one example fails to be executed properly
set -e

# install columbo
pip install . -q

for filename in docs/examples/*.py; do
printf "\n\n --- %s ---\n" "${filename}"
# provide default answers if example python file asks for input
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ _fmt = [
black-check = "black --check --diff ."
isort-check = "isort --check-only ."
flake8-check = "flake8"
bandit-check = "bandit --ini .bandit --quiet -r ."
bandit-ci = "bandit --ini .bandit -r ."
bandit-check = "bandit-ci --quiet"
check-strict = [
"black-check",
"isort-check",
Expand Down
12 changes: 0 additions & 12 deletions requirements-docs.txt

This file was deleted.

10 changes: 0 additions & 10 deletions requirements-test.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.