-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from shaiu/shaiu/fix-tests
add lint step
- Loading branch information
Showing
2 changed files
with
117 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,125 @@ on: | |
- dev | ||
- master | ||
|
||
env: | ||
CACHE_VERSION: 1 | ||
DEFAULT_PYTHON: "3.12" | ||
PRE_COMMIT_CACHE: ~/.cache/pre-commit | ||
UV_CACHE_DIR: /tmp/uv-cache | ||
|
||
jobs: | ||
info: | ||
name: Collect information & changes data | ||
outputs: | ||
pre-commit_cache_key: ${{ steps.generate_pre-commit_cache_key.outputs.key }} | ||
python_cache_key: ${{ steps.generate_python_cache_key.outputs.key }} | ||
requirements: ${{ steps.core.outputs.requirements }} | ||
python_versions: ${{ steps.info.outputs.python_versions }} | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/[email protected] | ||
- name: Generate partial Python venv restore key | ||
id: generate_python_cache_key | ||
run: | | ||
echo key=venv-${{ env.CACHE_VERSION }}-${{ | ||
hashFiles('requirements_test.txt') }} >> $GITHUB_OUTPUT | ||
- name: Generate partial pre-commit restore key | ||
id: generate_pre-commit_cache_key | ||
run: >- | ||
echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{ | ||
hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT | ||
pre-commit: | ||
name: Prepare pre-commit base | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- info | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/[email protected] | ||
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | ||
id: python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON }} | ||
check-latest: true | ||
- name: Restore base Python virtual environment | ||
id: cache-venv | ||
uses: actions/[email protected] | ||
with: | ||
path: venv | ||
key: >- | ||
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ | ||
needs.info.outputs.pre-commit_cache_key }} | ||
- name: Create Python virtual environment | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
run: | | ||
python -m venv venv | ||
. venv/bin/activate | ||
python --version | ||
pip install "$(grep '^uv' < requirements_test.txt)" | ||
uv pip install "$(cat requirements_test.txt | grep pre-commit)" | ||
- name: Restore pre-commit environment from cache | ||
id: cache-precommit | ||
uses: actions/[email protected] | ||
with: | ||
path: ${{ env.PRE_COMMIT_CACHE }} | ||
lookup-only: true | ||
key: >- | ||
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | ||
needs.info.outputs.pre-commit_cache_key }} | ||
- name: Install pre-commit dependencies | ||
if: steps.cache-precommit.outputs.cache-hit != 'true' | ||
run: | | ||
. venv/bin/activate | ||
pre-commit install-hooks | ||
lint-ruff-format: | ||
name: Check ruff-format | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- info | ||
- pre-commit | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/[email protected] | ||
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | ||
uses: actions/[email protected] | ||
id: python | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON }} | ||
check-latest: true | ||
- name: Restore base Python virtual environment | ||
id: cache-venv | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: venv | ||
fail-on-cache-miss: true | ||
key: >- | ||
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ | ||
needs.info.outputs.pre-commit_cache_key }} | ||
- name: Restore pre-commit environment from cache | ||
id: cache-precommit | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: ${{ env.PRE_COMMIT_CACHE }} | ||
fail-on-cache-miss: true | ||
key: >- | ||
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ | ||
needs.info.outputs.pre-commit_cache_key }} | ||
- name: Run ruff-format | ||
run: | | ||
. venv/bin/activate | ||
pre-commit run --hook-stage manual ruff-format --all-files --show-diff-on-failure | ||
env: | ||
RUFF_OUTPUT_FORMAT: github | ||
test: | ||
name: Tests | ||
|
||
runs-on: ubuntu-latest | ||
needs: | ||
- lint-ruff-format | ||
|
||
strategy: | ||
matrix: | ||
|
@@ -43,6 +157,8 @@ jobs: | |
name: Test Coverage | ||
|
||
runs-on: ubuntu-latest | ||
needs: | ||
- test | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
@@ -65,21 +181,3 @@ jobs: | |
- uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
lint: | ||
|
||
name: "Linting & Static Analysis" | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
architecture: x64 | ||
|
||
- uses: pre-commit/[email protected] | ||
env: | ||
SKIP: no-commit-to-branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters