-
Notifications
You must be signed in to change notification settings - Fork 5
184 lines (158 loc) · 5.83 KB
/
main.yaml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Create virtualenv
run: |
which python
python -m venv venv
source venv/bin/activate
python -m pip install --constraint=.github/workflows/constraints.txt --upgrade pip
which python
- name: Set up Poetry cache
uses: actions/[email protected]
with:
path: venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install Poetry and Python dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry --version
poetry config virtualenvs.in-project true
poetry config virtualenvs.create false
poetry config virtualenvs.path venv
source venv/bin/activate
which python
poetry install --no-root
- name: Compute pre-commit cache key
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]
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: pre-commit
run: |
source venv/bin/activate
pre-commit run --hook-stage=manual --show-diff-on-failure --all-files
# - name: mypy
# run: mypy .
- name: pytest
# run: pytest --junitxml=junit.xml --cov --cov-report=term-missing:skip-covered --cov-report=xml
run: |
source venv/bin/activate
pytest --ignore='{{cookiecutter.repo_name}}'
test:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: [3.12]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install cookiecutter
run: |
which python
python -m pip install --constraint=.github/workflows/constraints.txt --upgrade pip
python -m pip install --user cookiecutter
- name: Initialise cookiecutter repo
run: |
cd ~
pwd
cookiecutter $GITHUB_WORKSPACE --no-input
echo "cc_python_version=$(cat ~/coefficient-project/.python-version)"
echo "cc_python_version=$(cat ~/coefficient-project/.python-version)" >> $GITHUB_ENV
echo "cc_venv=$(cat ~/coefficient-project/.venv)"
echo "cc_venv=$(cat ~/coefficient-project/.venv)" >> $GITHUB_ENV
# TODO: This can be replaced I think with actions/setup-python?
- name: Install pyenv
uses: gabrielfalcao/pyenv-action@91f80eb59affae16a948d6ace29b1fada06d8e4c # https://github.com/gabrielfalcao/pyenv-action/pull/441
with:
default: ${{ env.cc_python_version }}
- name: Create cookiecuttered Python environment
run: |
cd ~/coefficient-project
pwd
pyenv local $(cat .python-version)
python -V
python -m venv $(cat .venv)
python -V
python -m pip install --upgrade pip
- name: Set up Poetry cache
uses: actions/[email protected]
with:
path: ${{ env.cc_venv }}
key: ${{ env.cc_venv }}-${{ matrix.python-version }}-${{ hashFiles('coefficient-project/poetry.lock') }}
- name: Install Poetry and Python dependencies
run: |
cd ~/coefficient-project
pyenv local $(cat .python-version)
source $(cat .venv)/bin/activate
curl -sSL https://install.python-poetry.org | python3 -
poetry --version
poetry config virtualenvs.in-project true
poetry config virtualenvs.create false
poetry config virtualenvs.path $(cat .venv)
which python
poetry install --no-root
- name: pytest
run: |
cd ~/coefficient-project
pyenv local $(cat .python-version)
source $(cat .venv)/bin/activate
pytest
- name: Towncrier
run: |
cd ~/coefficient-project
pyenv local $(cat .python-version)
source $(cat .venv)/bin/activate
git init
towncrier create 123.added --no-edit
towncrier build --version=999 --yes
less CHANGELOG.md
- name: pre-commit
run: |
cd ~/coefficient-project
pyenv local $(cat .python-version)
source $(cat .venv)/bin/activate
detect-secrets --verbose scan \
--exclude-files 'poetry\.lock' \
--exclude-files '\.secrets\.baseline' \
--exclude-files '\.env\.template' \
--exclude-secrets 'password|ENTER_PASSWORD_HERE|INSERT_API_KEY_HERE' \
--exclude-lines 'integrity=*sha' \
> .secrets.baseline
pre-commit run --hook-stage=manual --show-diff-on-failure --all-files