Skip to content

Commit

Permalink
Merge pull request #143 from jond01/xil-139
Browse files Browse the repository at this point in the history
Split the pre-commit job from the tests workflow
  • Loading branch information
jond01 authored Oct 28, 2023
2 parents ac6ec20 + 8bbfaca commit 9db1519
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 33 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Pre-commit

on:
push:
branches:
- main
- "releases/**"
pull_request:
branches:
- main
- "releases/**"
workflow_dispatch:

jobs:
pre-commit:
runs-on: ubuntu-latest
env:
CACHE_DIR: /opt/.cache
PRE_COMMIT_HOME: /opt/.cache/pre-commit
BLACK_CACHE_DIR: /opt/.cache/black
RUFF_CACHE_DIR: /opt/.cache/ruff
MYPY_CACHE_DIR: /opt/.cache/mypy
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install --pip-args="-c .github/workflows/poetry-constraint.txt" poetry
- uses: actions/setup-python@v4
with:
python-version-file: .python-version
cache: poetry
cache-dependency-path: |
poetry.lock
.github/workflows/env-markers/poetry-install.txt
- name: Install dependencies
run: poetry install
- name: Set PY
id: set-py
run: echo "PY=$(python -VV | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ env.CACHE_DIR }}
key: pre-commit-${{ runner.os }}-python-${{ steps.set-py.outputs.PY }}-config-and-deps-${{ hashFiles('.pre-commit-config.yaml', 'poetry.lock') }}
- name: Run pre-commit
env:
PRE_COMMIT_COLOR: always
run: poetry run pre-commit run --all-files
47 changes: 14 additions & 33 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@ name: Tests

on:
push:
paths:
- "**.py"
- pyproject.toml
- poetry.lock
- .github/workflows/poetry-constraint.txt
- .github/workflows/env-markers/poetry-install-only-main-test.txt
- .github/workflows/tests.yml
branches:
- main
- "releases/**"
pull_request:
paths:
- "**.py"
- pyproject.toml
- poetry.lock
- .github/workflows/poetry-constraint.txt
- .github/workflows/env-markers/poetry-install-only-main-test.txt
- .github/workflows/tests.yml
branches:
- main
- "releases/**"
Expand All @@ -14,39 +28,6 @@ on:
- cron: "0 15 * * *" # Daily at 6pm Israel standard time

jobs:
pre-commit:
runs-on: ubuntu-latest
env:
CACHE_DIR: /opt/.cache
PRE_COMMIT_HOME: /opt/.cache/pre-commit
BLACK_CACHE_DIR: /opt/.cache/black
RUFF_CACHE_DIR: /opt/.cache/ruff
MYPY_CACHE_DIR: /opt/.cache/mypy
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install --pip-args="-c .github/workflows/poetry-constraint.txt" poetry
- uses: actions/setup-python@v4
with:
python-version-file: .python-version
cache: poetry
cache-dependency-path: |
poetry.lock
.github/workflows/env-markers/poetry-install.txt
- name: Install dependencies
run: poetry install
- name: Set PY
id: set-py
run: echo "PY=$(python -VV | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ env.CACHE_DIR }}
key: pre-commit-${{ runner.os }}-python-${{ steps.set-py.outputs.PY }}-config-and-deps-${{ hashFiles('.pre-commit-config.yaml', 'poetry.lock') }}
- name: Run pre-commit
env:
PRE_COMMIT_COLOR: always
run: poetry run pre-commit run --all-files

tests:
strategy:
fail-fast: false
Expand Down

0 comments on commit 9db1519

Please sign in to comment.