diff --git a/.github/workflows/.python-version b/.github/workflows/.python-version index bd28b9c..2c07333 100644 --- a/.github/workflows/.python-version +++ b/.github/workflows/.python-version @@ -1 +1 @@ -3.9 +3.11 diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..9790e4f --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,41 @@ +name: Pytest + +on: + pull_request: + push: + branches: + - "main" + +jobs: + pytest: + runs-on: ubuntu-latest + permissions: + # Gives the action the necessary permissions for publishing new + # comments in pull requests. + pull-requests: write + # Gives the action the necessary permissions for pushing data to the + # python-coverage-comment-action branch, and for editing existing + # comments (to avoid publishing multiple comments in the same PR) + contents: write + steps: + - name: Check out code + uses: actions/checkout@v4 + + - uses: actions/setup-python@v4 + with: + python-version-file: .github/workflows/.python-version + cache: pip + cache-dependency-path: "**/pyproject.toml" + + - name: Install Python dependencies + run: pip install -e .[test] + + - name: Run tests + run: ./bin/coverage.sh + + - name: Coverage comment + uses: py-cov-action/python-coverage-comment-action@v3 + with: + GITHUB_TOKEN: ${{ github.token }} + MINIMUM_GREEN: 90 + MINIMUM_ORANGE: 80 diff --git a/.github/workflows/tests-pytest.yml b/.github/workflows/tests-pytest.yml deleted file mode 100644 index 5ac4556..0000000 --- a/.github/workflows/tests-pytest.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Pytest - -on: push - -jobs: - pytest: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v4 - - - name: Install system packages - run: | - sudo apt-get update -y - sudo apt-get install -y gettext - - - uses: actions/setup-python@v4 - with: - python-version-file: .github/workflows/.python-version - cache: pip - cache-dependency-path: '**/requirements.txt' - - - name: Install Python dependencies - run: pip install -r requirements.txt -r tests/requirements.txt - - - name: Run tests - run: ./tests/run.sh - - - name: Upload coverage report - uses: actions/upload-artifact@v3 - with: - name: coverage-report - path: coverage diff --git a/bin/coverage.sh b/bin/coverage.sh new file mode 100755 index 0000000..263c2f8 --- /dev/null +++ b/bin/coverage.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -eu + +# run normal pytests +coverage run -m pytest + +# clean out old coverage results +rm -rf ./tests/coverage + +# regenerate coverate report +coverage html --directory ./tests/coverage diff --git a/bin/web.sh b/bin/web.sh new file mode 100755 index 0000000..09d5854 --- /dev/null +++ b/bin/web.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -eu + +python -m http.server -d ./tests/coverage diff --git a/tests/run.sh b/tests/run.sh deleted file mode 100755 index a06e83a..0000000 --- a/tests/run.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -set -eu - -pytest --cov=eligibility_api --cov-branch - -# clean out old coverage results -rm -rf coverage -coverage html --directory coverage