diff --git a/.github/TEST_FAILURE_REPORT_TEMPLATE.md b/.github/TEST_FAILURE_REPORT_TEMPLATE.md new file mode 100644 index 0000000..59b7701 --- /dev/null +++ b/.github/TEST_FAILURE_REPORT_TEMPLATE.md @@ -0,0 +1,8 @@ +--- +title: '{{ env.TITLE }} ({{ date | date("YYYY-MM-DD") }})' +labels: ['type::bug', 'type::testing', 'source::auto'] +--- + +The {{ workflow }} workflow failed on {{ date | date("YYYY-MM-DD HH:mm") }} UTC + +Full run: {{ repo.html_url }}/actions/runs/{{ env.RUN_ID }} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b18791a..600b009 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -16,3 +16,7 @@ updates: directory: /set-commit-status schedule: interval: weekly + - package-ecosystem: pip + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 99f46dd..d6779d3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ concurrency: cancel-in-progress: true jobs: - tests: + pytest: runs-on: ubuntu-latest steps: - name: Checkout Source @@ -34,7 +34,7 @@ jobs: - name: Setup Python uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: - python-version: '3.11' + python-version: '>=3.9' - name: Install Dependencies run: pip install --quiet -r requirements.txt -r combine-durations/requirements.txt -r template-files/requirements.txt @@ -46,3 +46,30 @@ jobs: uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2 with: token: ${{ secrets.CODECOV_TOKEN }} + + # required check + analyze: + needs: [pytest] + if: '!cancelled()' + runs-on: ubuntu-latest + steps: + - name: Determine Success + uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 + id: alls-green + with: + jobs: ${{ toJSON(needs) }} + + - name: Checkout our source + if: always() && github.event_name != 'pull_request' && steps.alls-green.outputs.result == 'failure' + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Report failures + if: always() && github.event_name != 'pull_request' && steps.alls-green.outputs.result == 'failure' + uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2 + env: + GITHUB_TOKEN: ${{ secrets.AUTO_REPORT_TEST_FAILURE }} + RUN_ID: ${{ github.run_id }} + TITLE: 🤖 Tests Failed + with: + filename: .github/TEST_FAILURE_REPORT_TEMPLATE.md + update_existing: true diff --git a/combine-durations/action.yml b/combine-durations/action.yml index 912a4c8..ddf8c84 100644 --- a/combine-durations/action.yml +++ b/combine-durations/action.yml @@ -53,26 +53,31 @@ runs: env: GITHUB_TOKEN: ${{ github.token }} - - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + # `hashFiles` only works on files within the working directory, since `requirements.txt` + # is not in the working directory we need to manually compute the SHA256 hash + - name: Compute Hash + id: hash + shell: bash + run: echo hash=$(sha256sum ${{ github.action_path }}/requirements.txt | awk '{print $1}') >> $GITHUB_OUTPUT + + - name: Pip Cache + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/.cache/pip - # invalidate the cache anytime a workflow changes - key: ${{ hashFiles('.github/workflows/*') }} + key: ${{ github.workflow }}-combine-durations-${{ steps.hash.outputs.hash }} - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + - name: Setup Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: - python-version: '3.11' + python-version: '>=3.9' - - name: Install Dependencies + - name: Pip Install shell: bash run: pip install --quiet -r ${{ github.action_path }}/requirements.txt - name: Pip List shell: bash - run: | - echo ::group::Pip List - pip list - echo ::endgroup:: + run: pip list - name: Combine Recent Durations id: combine diff --git a/pyproject.toml b/pyproject.toml index 7ae8e48..44406e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,10 @@ skip = '.git' exclude_also = ["if TYPE_CHECKING:"] [tool.coverage.run] -omit = ["**/test_*.py"] +omit = [ + "**/test_*.py", + 'if __name__ == "__main__":', +] [tool.pytest.ini_options] addopts = [ @@ -21,7 +24,6 @@ addopts = [ "--tb=native", "-vv", ] -testpaths = ["**/"] [tool.ruff] target-version = "py39" @@ -42,4 +44,7 @@ select = [ ] [tool.ruff.lint.isort] -known-first-party = ["combine_durations", "template_files"] +known-first-party = [ + "combine_durations", + "template_files", +] diff --git a/template-files/action.yml b/template-files/action.yml index 1c9296e..d1ce5f7 100644 --- a/template-files/action.yml +++ b/template-files/action.yml @@ -26,26 +26,31 @@ outputs: runs: using: composite steps: - - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + # `hashFiles` only works on files within the working directory, since `requirements.txt` + # is not in the working directory we need to manually compute the SHA256 hash + - name: Compute Hash + id: hash + shell: bash + run: echo hash=$(sha256sum ${{ github.action_path }}/requirements.txt | awk '{print $1}') >> $GITHUB_OUTPUT + + - name: Pip Cache + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ~/.cache/pip - # invalidate the cache anytime a workflow changes - key: ${{ hashFiles('.github/workflows/*') }} + key: ${{ github.workflow }}-template-files-${{ steps.hash.outputs.hash }} - - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + - name: Setup Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: - python-version: '3.11' + python-version: '>=3.9' - - name: Install Dependencies + - name: Pip Install shell: bash run: pip install --quiet -r ${{ github.action_path }}/requirements.txt - name: Pip List shell: bash - run: | - echo ::group::Pip List - pip list - echo ::endgroup:: + run: pip list - name: Template Files id: template