-
-
Notifications
You must be signed in to change notification settings - Fork 6
161 lines (152 loc) · 4.72 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
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
name: Tests
on: [push, pull_request]
jobs:
build_sdist:
name: Build source wheels
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/[email protected]
with:
python-version: 3.8
- name: Upgrade pip
run: |-
python -m pip install --upgrade pip
python -m pip install setuptools>=0.8 wheel build
- name: Build sdist
shell: bash
run: |-
python -m build --sdist --outdir wheelhouse
- name: Install sdist
run: |-
ls -al ./wheelhouse
pip install pytest pytest-cov
pip install Cython
pip install wheelhouse/*.tar.gz -v
- name: Test sdist
run: |-
pwd
ls -al
# Run in a sandboxed directory
WORKSPACE_DNAME="testsrcdir_minimal_${CI_PYTHON_VERSION}_${GITHUB_RUN_ID}_${RUNNER_OS}"
mkdir -p $WORKSPACE_DNAME
cd $WORKSPACE_DNAME
# Get path to installed package
MOD_NAME=lark_cython
MOD_DPATH=$(python -c "import $MOD_NAME, os; print(os.path.dirname($MOD_NAME.__file__))")
echo "MOD_DPATH = $MOD_DPATH"
# Run the tests
python -m pytest --cov=$MOD_NAME $MOD_DPATH ../tests
cd ..
- name: Upload sdist artifact
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.tar.gz
build_binary_wheels:
name: ${{ matrix.os }}, arch=${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["windows-latest", "ubuntu-latest", "macOS-latest"]
cibw_skip: ["*-win32"]
arch: [auto]
include:
- os: windows-latest
arch: auto
cibw_skip: '*-win_amd64'
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Enable MSVC 64bit
uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-latest' && matrix.cibw_skip == '*-win32'
- name: Enable MSVC 32bit
uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-latest' && matrix.cibw_skip == '*-win_amd64'
with:
arch: x86
- name: Build binary wheels
uses: pypa/[email protected]
with:
output-dir: wheelhouse
config-file: pyproject.toml
env:
CIBW_BUILD_VERBOSITY: 1
#CIBW_TEST_COMMAND: pytest
CIBW_SKIP: ${{ matrix.cibw_skip }}
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
- name: Show built files
shell: bash
run: ls -la wheelhouse
- name: Set up Python 3.8 to combine coverage Linux
uses: actions/[email protected]
if: runner.os == 'Linux'
with:
python-version: 3.8
- name: Combine coverage Linux
if: runner.os == 'Linux'
run: |-
echo '############ PWD'
pwd
cp .wheelhouse/.coverage* . || true
ls -al
python -m pip install coverage[toml]
echo '############ combine'
coverage combine . || true
echo '############ XML'
coverage xml -o ./tests/coverage.xml || true
echo '############ FIND'
find . -name .coverage.* || true
find . -name coverage.xml || true
- uses: codecov/codecov-action@v3
name: Codecov Upload
with:
file: ./tests/coverage.xml
- uses: actions/upload-artifact@v3
name: Upload wheels artifact
with:
name: wheels
path: ./wheelhouse/*.whl
publish_wheels:
name: Publish Wheels
runs-on: ubuntu-latest
needs:
- build_binary_wheels
- build_sdist
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Download wheels and sdist
uses: actions/download-artifact@v3
with:
name: wheels
path: wheelhouse
- name: Show files to upload
shell: bash
run: ls -la wheelhouse
### See github action page for details
# https://github.com/marketplace/actions/pypi-publish
# ----
- name: Publish to Live PyPI
# Only publish real wheels for new git tags.
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
#repository_url: https://upload.pypi.org/legacy/ # default url should be fine
packages_dir: wheelhouse
verbose: true
# ----
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'push' && ! startsWith(github.event.ref, 'refs/tags')
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
skip_existing: true
repository_url: https://test.pypi.org/legacy/
packages_dir: wheelhouse
verbose: true