Skip to content

Commit

Permalink
Add analyze step (#245)
Browse files Browse the repository at this point in the history
* Standardize Python

* Enable dependabot updates for pip

* Add analyze step with automated error reports

* Minor cleanup

* Update existing failures

* Compute hash
  • Loading branch information
kenodegard authored Jan 10, 2025
1 parent 3cf0d52 commit aedec25
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .github/TEST_FAILURE_REPORT_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ updates:
directory: /set-commit-status
schedule:
interval: weekly
- package-ecosystem: pip
directory: /
schedule:
interval: weekly
31 changes: 29 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:
cancel-in-progress: true

jobs:
tests:
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
Expand All @@ -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
Expand All @@ -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
25 changes: 15 additions & 10 deletions combine-durations/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -21,7 +24,6 @@ addopts = [
"--tb=native",
"-vv",
]
testpaths = ["**/"]

[tool.ruff]
target-version = "py39"
Expand All @@ -42,4 +44,7 @@ select = [
]

[tool.ruff.lint.isort]
known-first-party = ["combine_durations", "template_files"]
known-first-party = [
"combine_durations",
"template_files",
]
25 changes: 15 additions & 10 deletions template-files/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aedec25

Please sign in to comment.