-
Notifications
You must be signed in to change notification settings - Fork 1
154 lines (129 loc) · 3.94 KB
/
test-build-and-publish.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
name: Test build and publish Cobramod to PyPI
on:
workflow_dispatch:
schedule:
- cron: "0 5 * * 1"
pull_request:
types: [ opened, synchronize, reopened, closed ]
branches:
- master
jobs:
lint-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: python -m pip install tox
- name: Linter
run: python -m tox -e lint
- name: Format
run: python -m tox -e format
types:
needs: [ lint-format ]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install tox
- name: Run type-checking
run: python -m tox -e types
build:
needs: [ types ]
runs-on: ubuntu-latest
outputs:
file-path: ${{ steps.path.outputs.file-path }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
- name: Set up JS & build js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel build
yarn install
- name: Build JS
run: yarn run vite build
- name: Build package
run: python -m build
- name: Get file name
id: path
run: echo "file-path=$(cd dist && find . -type f -name cobramod-*.whl)" >> "$GITHUB_OUTPUT"
- name: Archive package as artifact
uses: actions/upload-artifact@v4
with:
name: cobramod-dist
path: |
dist
unittest:
needs: [build]
strategy:
max-parallel: 1
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ "3.10", "3.11", "3.12" ]
runs-on: ${{ matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Download package as artifact
uses: actions/download-artifact@v4
with:
name: cobramod-dist
- name: Install tox
run: python -m pip install tox-gh>=1.2
- name: Credentials
run: echo "${{ secrets.BIOCYC_USER }}\n${{ secrets.BIOCYC_PASS }}" >> credentials.txt
- name: Setup test suite
run: tox -vv --notest --installpkg ${{ needs.build.outputs.file-path }}
- name: Run test suite
run: tox --skip-pkg-install
- name: Upload coverage reports to Codecov
if: ${{ ( matrix.python-version == '3.12' ) && ( runner.os == 'Linux' ) }}
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
publish-to-pypi:
needs: [unittest]
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: github.event.pull_request.merged == true && github.event_name != 'schedule'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/cobramod
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: cobramod-dist
path: |
dist
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine build
- name: Check the package
run: twine check dist/*
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1