diff --git a/.github/actions/initialize-hatch/action.yml b/.github/actions/initialize-hatch/action.yml new file mode 100644 index 00000000..559264b6 --- /dev/null +++ b/.github/actions/initialize-hatch/action.yml @@ -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" diff --git a/.github/actions/install-dependencies/action.sh b/.github/actions/install-dependencies/action.sh deleted file mode 100755 index 2426cb1d..00000000 --- a/.github/actions/install-dependencies/action.sh +++ /dev/null @@ -1,19 +0,0 @@ -set -euo pipefail - -echo "Ensuring pip is up to date" -python -m pip install --upgrade pip - -if [[ "${INSTALL_REQUIREMENTS}" == "true" ]]; then - echo "Installing code requirements" - pip install -r requirements.txt -fi - -if [[ "${INSTALL_TEST_REQUIREMENTS}" == "true" ]]; then - echo "Installing test requirements" - pip install -r requirements-test.txt -fi - -if [[ "${INSTALL_DOCS_REQUIREMENTS}" == "true" ]]; then - echo "Installing docs requirements" - pip install -r requirements-docs.txt -fi diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml deleted file mode 100644 index 2e751577..00000000 --- a/.github/actions/install-dependencies/action.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "Install Dependencies" -description: "Install Python dependencies" -inputs: - requirements: - description: "Should requirements.txt be installed" - default: "false" - required: false - test-requirements: - description: "Should requirements-test.txt be installed" - default: "false" - required: false - docs-requirements: - description: "Should requirements-docs.txt be installed" - default: "false" - required: false -runs: - using: "composite" - steps: - - name: "Install Python dependencies" - run: "$GITHUB_ACTION_PATH/action.sh" - shell: "bash" - env: - INSTALL_REQUIREMENTS: ${{ inputs.requirements }} - INSTALL_TEST_REQUIREMENTS: ${{ inputs.test-requirements }} - INSTALL_DOCS_REQUIREMENTS: ${{ inputs.docs-requirements }} diff --git a/.github/actions/publish-docs-with-mike/action.sh b/.github/actions/publish-docs-with-mike/action.sh index 96e1d579..642357fb 100755 --- a/.github/actions/publish-docs-with-mike/action.sh +++ b/.github/actions/publish-docs-with-mike/action.sh @@ -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::" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2f3238f..19de525a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/docker/validate_docs.sh b/docker/validate_docs.sh index 95867895..e946bc35 100755 --- a/docker/validate_docs.sh +++ b/docker/validate_docs.sh @@ -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 diff --git a/pyproject.toml b/pyproject.toml index b1285056..a8d098da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/requirements-docs.txt b/requirements-docs.txt deleted file mode 100644 index 87f9225b..00000000 --- a/requirements-docs.txt +++ /dev/null @@ -1,12 +0,0 @@ -mike==1.1.2 -# mike implicitly depends on pkg_resources from setuptools. -# It has been addressed as part of the work towards 2.0, but that has not been released yet -# https://github.com/jimporter/mike/issues/148 -setuptools==68.2.2 - -markdown-include==0.8.1 -mkdocs==1.5.3 -mkdocs-material==9.4.9 -mkdocs-minify-plugin==0.7.1 -mkdocs-redirects==1.2.1 -mkdocstrings[python]==0.24.0 \ No newline at end of file diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index 55283f36..00000000 --- a/requirements-test.txt +++ /dev/null @@ -1,10 +0,0 @@ -bandit==1.7.5 -black==23.11.0 -flake8==6.1.0 -isort==5.12.0 -hyper-bump-it==0.5.2; python_version >= '3.9' -mypy==1.7.0 -pytest==7.4.3 -pytest-cov==4.1.0 -pytest-mock==3.12.0 -pdbpp diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9ee07a81..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -prompt-toolkit==3.0.41