forked from libtcod/python-tcod
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (143 loc) · 4.75 KB
/
python-package.yml
File metadata and controls
150 lines (143 loc) · 4.75 KB
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Package
on:
push:
pull_request:
defaults:
run:
shell: bash
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-20.04", "windows-2019"]
python-version: ["3.6", "3.7", "3.8", "3.9", "pypy-3.7"]
architecture: ["x64"]
include:
- os: "windows-2019"
python-version: "3.6"
architecture: "x86"
- os: "windows-2019"
python-version: "pypy-3.6"
architecture: "x86"
fail-fast: false
steps:
# v2 breaks `git describe` so v1 is needed.
# https://github.com/actions/checkout/issues/272
- uses: actions/checkout@v1
- name: Checkout submodules
run: |
git submodule update --init --recursive --depth 1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: Install APT dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libsdl2-dev xvfb
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov pytest-benchmark wheel twine
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Initialize package
run: |
python setup.py check # Creates tcod/version.py.
- name: Build package.
run: |
python setup.py build sdist develop bdist_wheel --py-limited-api cp36 # Install the package in-place.
- name: Test with pytest
if: runner.os == 'Windows'
run: |
pytest --cov-report=xml
- name: Test with pytest
if: runner.os != 'Windows'
run: |
xvfb-run --auto-servernum pytest --cov-report=xml
- uses: codecov/codecov-action@v1
- name: Upload to PyPI
if: startsWith(github.ref, 'refs/tags/') && runner.os != 'Linux'
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload --skip-existing dist/*
- uses: actions/upload-artifact@v2
if: runner.os == 'Linux'
with:
name: sdist
path: dist/tcod-*.tar.gz
retention-days: 3
isolated: # Test installing the package from source.
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-20.04", "windows-2019"]
steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Install APT dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libsdl2-dev
- uses: actions/download-artifact@v2
with:
name: sdist
- name: Build package in isolation
run: |
pip install tcod-*.tar.gz
- name: Confirm package import
run: |
python -c "import tcod"
linux_wheels:
runs-on: "ubuntu-20.04"
steps:
- uses: actions/checkout@v1
- name: Checkout submodules
run: |
git submodule update --init --recursive --depth 1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install twine cibuildwheel==2.0.0
- name: Build wheels
run: |
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp36-* pp*
CIBW_ARCHS_LINUX: "x86_64"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: yum install -y SDL2-devel
CIBW_BEFORE_TEST: pip install numpy
CIBW_TEST_COMMAND: python -c "import tcod"
- name: Archive wheel
uses: actions/upload-artifact@v2
with:
name: wheel-linux
path: wheelhouse/*.whl
retention-days: 1
- name: Upload to PyPI
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload --skip-existing wheelhouse/*