Remove duplicate. #718
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: Tests | |
on: | |
- push | |
- pull_request | |
jobs: | |
tests: | |
name: ${{ matrix.script }} ${{ matrix.python }} / ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- { python: "3.12", os: "ubuntu-latest", script: "pre-commit" } | |
- { python: "3.12", os: "ubuntu-latest", script: "safety" } | |
- { python: "3.12", os: "ubuntu-latest", script: "test" } | |
- { python: "3.12", os: "windows-latest", script: "test" } | |
- { python: "3.12", os: "macos-latest", script: "test" } | |
- { python: "3.12", os: "ubuntu-latest", script: "docs-build" } | |
env: | |
PRE_COMMIT_COLOR: "always" | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Create .script-cache.txt for pip cache | |
run: | | |
echo ${{ matrix.script }} > .script-cache.txt | |
shell: bash | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: pip | |
cache-dependency-path: .script-cache.txt | |
- name: Upgrade pip | |
run: | | |
pip install --constraint=.github/workflows/constraints.txt pip | |
pip --version | |
- name: Upgrade pip in virtual environments | |
shell: python | |
run: | | |
import os | |
import pip | |
with open(os.environ["GITHUB_ENV"], mode="a") as io: | |
print(f"VIRTUALENV_PIP={pip.__version__}", file=io) | |
- name: Install Hatch | |
run: | | |
pipx install hatch | |
hatch version | |
- name: Compute pre-commit cache key | |
if: matrix.script == 'pre-commit' | |
id: pre-commit-cache | |
shell: python | |
run: | | |
import hashlib | |
import sys | |
python = "py{}.{}".format(*sys.version_info[:2]) | |
payload = sys.version.encode() + sys.executable.encode() | |
digest = hashlib.sha256(payload).hexdigest() | |
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8]) | |
print("::set-output name=result::{}".format(result)) | |
- name: Restore pre-commit cache | |
uses: actions/[email protected] | |
if: matrix.script == 'pre-commit' | |
with: | |
path: ~/.cache/pre-commit | |
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }} | |
restore-keys: | | |
${{ steps.pre-commit-cache.outputs.result }}- | |
- name: Run `hatch run` | |
run: | | |
hatch run +py=${{ matrix.python }} ${{ matrix.script }}:run | |
- name: Upload coverage data | |
if: always() && matrix.script == 'test' | |
uses: "actions/upload-artifact@v3" | |
with: | |
name: coverage-data | |
path: ".coverage.*" | |
- name: Upload documentation | |
if: matrix.script == 'docs-build' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docs | |
path: docs/_build |