-
Notifications
You must be signed in to change notification settings - Fork 13
141 lines (118 loc) · 4.44 KB
/
ci.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
# Workflow label
name: CI
# Workflow trigger
on: [push, pull_request]
# Workflow tasks
jobs:
# Apply lint, check formatting
lint:
name: "Lint (Python ${{ matrix.python-version }})"
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache Python
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{matrix.os}}-${{matrix.python-version}}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}
- name: Install Python requirements
run: |
pip install --upgrade --upgrade-strategy eager .[dev]
pip install flake8
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Cancelling pipeline (failed)
if: failure()
uses: andymckay/[email protected]
- name: Check formatting with black
run: black --check .
# Execute pytest to check PyonFX's functionalities
test:
name: "Test (${{matrix.os}}, Python ${{ matrix.python-version }})"
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install platform-specific requirements (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 python3-gi python3-gi-cairo
- name: Install platform-specific requirements (macOS) # Note: brew is very slow sometimes. TODO: speedup brew by using caching.
if: matrix.os == 'macos-latest'
run: brew install python py3cairo pygobject3 pango
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Install fonts (non-Windows)
if: matrix.os != 'windows-latest'
run: |
go install github.com/Crosse/font-install@latest
font-install "https://github.com/itouhiro/mixfont-mplus-ipa/releases/download/v2020.0307/migu-1p-20200307.zip"
shell: bash
- name: Install fonts (Windows)
if: matrix.os == 'windows-latest'
run: ./.github/scripts/install-fonts.ps1 'https://github.com/itouhiro/mixfont-mplus-ipa/releases/download/v2020.0307/migu-1p-20200307.zip'
shell: pwsh
- name: Cache Python
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{matrix.os}}-${{matrix.python-version}}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}
- name: Install Python requirements
run: pip install --upgrade --upgrade-strategy eager .[dev]
- name: Test
run: PANGOCAIRO_BACKEND=fc pytest
shell: bash
# Build the package and publish it on PyPi
build-n-publish:
needs: [lint, test]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
name: "Build and publish distributions to PyPI and TestPyPI"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: 3.12
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1.9
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.9
with:
password: ${{ secrets.PYPI_API_TOKEN }}