Run tests on github #35
This file contains hidden or 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
| name: pre-commit | |
| on: | |
| pull_request: | |
| branches: | |
| - "main*" | |
| push: | |
| branches: | |
| - "main" | |
| jobs: | |
| pre-commit: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Get python version | |
| run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
| - name: Install pre-commit | |
| run: pip install pre-commit | |
| - name: Run pre-commit | |
| run: pre-commit run --all-files --show-diff-on-failure --color=always | |
| - name: Check that all files generated by pre-commit are in git | |
| run: | | |
| newfiles="$(git ls-files --others --exclude-from=.gitignore)" | |
| if [ "$newfiles" != "" ] ; then | |
| echo "Please check-in the following files:" | |
| echo "$newfiles" | |
| exit 1 | |
| fi | |
| - name: Install uv and sync dev dependencies | |
| run: | | |
| pip install uv | |
| uv venv | |
| echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV | |
| echo "$PWD/.venv/bin" >> $GITHUB_PATH | |
| uv sync --dev | |
| - name: Run tests with pytest | |
| run: pytest |