-
Notifications
You must be signed in to change notification settings - Fork 3
162 lines (142 loc) · 5.73 KB
/
main.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
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
name: "Tests"
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions: {}
jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Install poetry
run: pipx install poetry
- name: Linting
run: make lint
Tests:
name: ${{ matrix.os }} / py${{ matrix.python-version }} / poetry${{ matrix.poetry-version }}
runs-on: ${{ matrix.image }}
strategy:
matrix:
os: [Ubuntu, macOS, Windows]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
poetry-version: ["==1.7.0", "==1.7.1", "==1.8.0", "==1.8.1", "==1.8.2", "==1.8.3", "==1.8.4", "==1.8.5", "==2.0.0", "==2.0.1", ""]
exclude:
- python-version: "3.8"
poetry-version: "==2.0.0"
- python-version: "3.8"
poetry-version: "==2.0.1"
- python-version: "3.8"
poetry-version: ""
include:
- os: Ubuntu
image: ubuntu-latest
- os: Windows
image: windows-latest
- os: macOS
image: macos-latest
fail-fast: false
defaults:
run:
shell: bash
needs: Lint
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Get full Python version
id: full-python-version
run: echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT
- name: Install poetry
shell: bash
run: |
pipx install poetry${{ matrix.poetry-version }}
pipx ensurepath
# as the poetry version specification will modify the lock, need to calculate the hash once, to be able to correctly cache the result
- name: Get repo lock hash
id: repo-lock-hash
run: |
echo "hash=$(git hash-object poetry.lock)" >> $GITHUB_OUTPUT
- name: Set up cache
uses: actions/cache/restore@v4
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ matrix.poetry-version }}-${{ steps.repo-lock-hash.outputs.hash }}
- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s poetry run pip --version || rm -rf .venv
- name: Latest pip
run: |
python -m pip install --upgrade pip
- name: Specify python version (poetry>=2.0) (non-macOS)
# As poetry>=2.0 is incompatible with python==3.8 (which we want to allow to allow poetry<2.0), we also pin the python version
if: (startsWith(matrix.poetry-version, '==2') || matrix.poetry-version == '') && runner.os != 'macOS'
run: |
sed -i "s/^python = \".*\"/python = \"~${{ matrix.python-version }}.0\"/" pyproject.toml
- name: Specify python version (poetry>=2.0) (macOs)
# need different sed command because it is zsh
if: (startsWith(matrix.poetry-version, '==2') || matrix.poetry-version == '') && runner.os == 'macOS'
run: |
sed -i '' "s/^python = \".*\"/python = \"~${{ matrix.python-version }}.0\"/" pyproject.toml
- name: Specify poetry version (windows)
# Pinning to a specific poetry version, such that we can verify test suite with that specific version
# because $(which python) returns / paths, while poetry wants \ paths
if: runner.os == 'Windows'
run: |
poetry config virtualenvs.prefer-active-python true || echo "probably on Poetry>=2.0.0"
echo "Python version = $(python --version)"
echo "Poetry's Python version = $(poetry run python --version)"
echo "Poetry version = $(poetry --version)"
poetry remove poetry poetry-core
poetry add poetry${{ matrix.poetry-version }}
echo "Poetry's Python version = $(poetry run python --version)"
echo "Poetry version within poetry venv = $(poetry run poetry --version)"
- name: Specify poetry version (non-windows)
if: runner.os != 'Windows'
run: |
poetry env use $(which python)
echo "Python version = $(python --version)"
echo "Poetry's Python version = $(poetry run python --version)"
echo "Poetry version = $(poetry --version)"
poetry remove poetry poetry-core
poetry add poetry${{ matrix.poetry-version }}
echo "Poetry's Python version = $(poetry run python --version)"
echo "Poetry version within poetry venv = $(poetry run poetry --version)"
# because our poetry update modifies the cache
- name: Update cache
id: cache-save
uses: actions/cache/save@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ matrix.poetry-version }}-${{ steps.repo-lock-hash.outputs.hash }}
- name: Install dependencies
run: |
poetry install --sync --with github-actions
touch .venv/.touchfile
- name: Coverage for pytest
run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.3.0
with:
env_vars: OS,PYTHON
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
flags: unittests
files: ./coverage/coverage.xml
slug: gerbenoostra/poetry-plugin-mono-repo-deps