-
Notifications
You must be signed in to change notification settings - Fork 18
118 lines (117 loc) · 3.93 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
name: Run Python Tests and Publish to PyPI
on:
push:
branches:
- master
- develop
- citest
tags:
- '*'
pull_request:
branches:
- master
- develop
schedule:
# Run on Tuesdays at 5:59
- cron: '59 5 * * 2'
workflow_dispatch:
jobs:
build-n-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
requirements-file: ["requirements.txt"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest wheel
pip install -r ${{ matrix.requirements-file }}
python setup.py install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 opusfilter --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 opusfilter --count --exit-zero --statistics
- name: Run tests with pytest
run: pytest
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
needs: build-n-test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Check for main release tag
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
id: check-tag
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]*)?$ ]]; then
echo "match=true" >> $GITHUB_OUTPUT
fi
- name: Set up Python 3.8
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install pypa/build
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution 📦 to Test PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'push' && steps.check-tag.outputs.match == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
build-and-deploy-docs:
runs-on: ubuntu-latest
needs: [build-n-test]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies to build docs
run: |
python -m pip install --upgrade pip
python -m pip install wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install .[docs]
- name: Build docs
run: |
sphinx-build docs docs/build
- name: Deploy docs
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: docs/build
clean: true