-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (137 loc) · 4.9 KB
/
test-n-publish.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
name: Publish specified tags of Spine packages
on:
workflow_dispatch:
inputs:
Spine-Toolbox:
description: Git tag to use for 'Spine-Toolbox'
type: string
default: 'skip'
spine-items:
description: Git tag to use for 'spine-items'
type: string
default: 'skip'
spine-engine:
description: Git tag to use for 'spine-engine'
type: string
default: 'skip'
Spine-Database-API:
description: Git tag to use for 'Spine-Database-API'
type: string
default: 'skip'
jobs:
build:
strategy:
matrix:
pkg: ['Spine-Database-API', 'spine-engine', 'spine-items', 'Spine-Toolbox']
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ matrix.pkg }}
uses: actions/checkout@v3
with:
repository: 'spine-tools/${{ matrix.pkg }}'
path: ${{ matrix.pkg }}
ref: ${{ inputs[matrix.pkg] != 'skip' && inputs[matrix.pkg] || 'master' }}
fetch-tags: ${{ inputs[matrix.pkg == 'skip' }}
- name: Ensure Git checkout is not dirty
run: cd ${{ matrix.pkg }} && git describe --tags --dirty | grep -vE '[-]dirty$'
- name: Ensure Git checkout does not have additional commits
run: cd ${{ matrix.pkg }} && git describe --tags | grep -vE '[-]g[a-z0-9]{8}$'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build
if: ${{ inputs[matrix.pkg] != 'skip' }}
run: |
python -m build ${{ matrix.pkg }}
- name: Download wheels for packages excluded from build
if: ${{ inputs[matrix.pkg] == 'skip' }}
run: |
mkdir -p ${{ matrix.pkg }}/dist/
sed -nEe 's/name[ ]*=[ ]*"?([a-z0-9_-]+)"?/\1/p' ${{ matrix.pkg }}/pyproject.toml > pkgname
python -m pip download --no-deps --python-version 3.8 \
--dest ${{ matrix.pkg }}/dist/ $(cat pkgname)
- name: Save ${{ matrix.pkg }} wheel
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.pkg }}
path: ${{ matrix.pkg }}/dist/*
retention-days: 7
test:
needs: build
strategy:
matrix:
pkg: ['Spine-Database-API', 'spine-engine', 'spine-items', 'Spine-Toolbox']
os: [ubuntu-latest, windows-latest]
python: ["3.8", "3.9", "3.10", "3.11"]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Make dist directory
run: mkdir -p dist
- name: Download all wheels
uses: actions/download-artifact@v3
with:
path: dist
- name: Checkout ${{ matrix.pkg }}
uses: actions/checkout@v3
with:
repository: 'spine-tools/${{ matrix.pkg }}'
path: ${{ matrix.pkg }}
ref: ${{ inputs[matrix.pkg] }}
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install pytest and built wheels on *NIX
if: runner.os != 'Windows'
run: |
python -m pip install --upgrade pip
python -m pip install dist/*/*.whl
python -m pip install pytest
- name: Install pytest and built wheels on Windows
if: runner.os == 'Windows'
run: |
python -m pip install --upgrade pip
Get-ChildItem ./dist/*.whl -Recurse | ForEach-Object {python -m pip install $_}
python -m pip install pytest
- name: Install additional packages for Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y libegl1
- name: Remove source from checkouts for *NIX
if: runner.os != 'Windows'
run: |
rm -rf Spine-Toolbox/spinetoolbox* spine-items/spine_items \
spine-engine/spine_engine Spine-Database-API/spinedb_api
- name: Remove source from checkouts for Windows
if: runner.os == 'Windows'
run: |
Remove-Item Spine-Toolbox\spinetoolbox* -Recurse -Force -ErrorAction Ignore
Remove-Item spine-items\spine_items -Recurse -Force -ErrorAction Ignore
Remove-Item spine-engine\spine_engine -Recurse -Force -ErrorAction Ignore
Remove-Item Spine-Database-API\spinedb_api -Recurse -Force -ErrorAction Ignore
- name: Test wheels
env:
QT_QPA_PLATFORM: offscreen
run: |
python -m unittest discover -s ${{ matrix.pkg }} --verbose
- name: Execution tests
if: matrix.pkg == 'Spine-Toolbox'
run: |
python -m unittest discover -s ${{ matrix.pkg }} --pattern execution_test.py --verbose
publish:
# isolate from test, to prevent partial uploads
needs: test
strategy:
matrix:
pkg: ['Spine-Database-API', 'spine-engine', 'spine-items', 'Spine-Toolbox']
uses: ./.github/workflows/publish-wheel.yml
with:
pkg: ${{ matrix.pkg }}
ver: ${{ inputs[matrix.pkg] }}