forked from cjolowicz/cookiecutter-hypermodern-python
-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (81 loc) · 3.3 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Tests
on: [push, pull_request]
jobs:
tests:
strategy:
fail-fast: false
matrix:
include:
- { python-version: "3.11", os: ubuntu-latest }
- { python-version: "3.11", os: windows-latest }
- { python-version: "3.11", os: macos-latest }
- { python-version: "3.10", os: ubuntu-latest }
- { python-version: "3.9", os: ubuntu-latest }
name: Python ${{ matrix.python-version }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
path: ssb-pypitemplate
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install tools using pip
working-directory: ssb-pypitemplate
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pipx install --pip-args=--constraint=.github/workflows/constraints.txt cookiecutter
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
- name: Generate project using Cookiecutter
run: cookiecutter --no-input ssb-pypitemplate
- name: Create git repository
if: matrix.os != 'windows-latest'
run: |
git init
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
git add .
git commit --message="Initial import"
working-directory: ssb-library
- name: Create git repository (Windows)
if: matrix.os == 'windows-latest'
run: |
git init
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
# https://github.com/cookiecutter/cookiecutter/issues/405
$ErrorActionPreference = "Continue"
git add .
$ErrorActionPreference = "Stop"
git add --renormalize .
git commit --message="Initial import"
working-directory: ssb-library
- name: Compute cache key for pre-commit
if: matrix.os != 'windows-latest'
id: cache_key
shell: python
run: |
import hashlib
import subprocess
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])
cmd = f'echo "result={result}" >> $GITHUB_OUTPUT'
subprocess.run(cmd, shell=True)
- uses: actions/cache@v3
if: matrix.os != 'windows-latest'
with:
path: ~/.cache/pre-commit
key: ${{ steps.cache_key.outputs.result }}-${{ hashFiles('ssb-library/.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.cache_key.outputs.result }}-
- name: Run test suite using Nox
run: nox --force-color --python=${{ matrix.python-version }}
working-directory: ssb-library
- name: Install dependencies using Poetry
run: poetry install --ansi
working-directory: ssb-library