generated from JacksonBurns/blank-python-project
-
Notifications
You must be signed in to change notification settings - Fork 4
131 lines (121 loc) · 3.79 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
name: Continuous Integration
on:
schedule:
- cron: "0 8 * * 1-5"
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: actions-id-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
check-formatting:
name: Check Formatting Errors
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: |
python -m pip install pycodestyle autopep8
python -m pip install .
- name: Run pycodestyle
run: |
pycodestyle --statistics --count --max-line-length=150 --show-source .
build-and-test:
needs: check-formatting
continue-on-error: true
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-latest]
exclude:
- python-version: "3.12"
- python-version: "3.11"
os: windows-latest
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}
name: ${{ matrix.os }} Python ${{ matrix.python-version }} Subtest
steps:
- uses: actions/checkout@v3
- uses: mamba-org/setup-micromamba@main
with:
environment-name: temp
condarc: |
channels:
- defaults
- conda-forge
channel_priority: flexible
create-args: |
python=${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install ".[dev,hopt,bmark,shap]"
python -m pip install coverage pytest
- name: Run Tests
run: |
coverage run --source=. -m pytest -vs
- name: Show Coverage
run: |
coverage report -m
ci-report-status:
if: ${{ always() }}
name: report CI status
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- run: exit 1
# see https://stackoverflow.com/a/67532120/4907315
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}
check-for-new-release:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- uses: actions/checkout@v3
- name: Check PyPI version
uses: maybe-hello-world/pyproject-check-version@v3
id: versioncheck
with:
pyproject-path: "./pyproject.toml"
- name: Report Results
run: |
echo "New Release found? ${{ steps.versioncheck.outputs.local_version_is_higher }}"
echo "Local version: ${{ steps.versioncheck.outputs.local_version }}"
echo "Public version: ${{ steps.versioncheck.outputs.public_version }}"
outputs:
do_publish: ${{ steps.versioncheck.outputs.local_version_is_higher }}
pypi-package:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-latest
needs: [check-for-new-release, ci-report-status]
if: ${{ needs.check-for-new-release.outputs.do_publish == 'true' && github.ref == 'refs/heads/main' && github.repository == 'JacksonBurns/fastprop'}}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- 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 PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
verbose: true