-
Notifications
You must be signed in to change notification settings - Fork 10
214 lines (180 loc) · 5.88 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- main
tags:
- v*.*.*
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
name: Run Python lint and type checks
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
# Semantic version range syntax or exact version of a Python version
python-version: 3.9
cache: pip
cache-dependency-path: |
packages/chassisml/pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ./packages/chassisml[test]
- name: Lint
run: tox -e lint
- name: Verify Types
run: tox -e type
tests:
name: Run tests for ${{ matrix.os }}/${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
include:
- python-version: "3.8"
tox-name: py38
- python-version: "3.9"
tox-name: py39
- python-version: "3.10"
tox-name: py310
- python-version: "3.11"
tox-name: py311
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"
cache: pip
cache-dependency-path: |
packages/chassisml/pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ./packages/chassisml[test]
- name: Run tests
run: |
tox -e ${{ matrix.tox-name }}
pip:
name: Build and publish SDK to PyPI
needs: [lint, tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
cache: pip
cache-dependency-path: |
packages/chassisml/pyproject.toml
- name: Install pypa/build
run: |
pip install build
- name: Build distribution
run: |
python3 -m build --sdist --wheel --outdir dist/ packages/chassisml
# - name: Publish distribution to PyPI
# if: startsWith(github.ref, 'refs/tags')
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
docs:
name: Update docs
needs: [lint, tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
cache-dependency-path: |
packages/chassisml/pyproject.toml
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install ./packages/chassisml[docs]
- name: Build docs
run: |
tox -e docs
# - name: Publish docs
# if: startsWith(github.ref, 'refs/tags')
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: /home/runner/work/chassis/build/docs
container-images:
name: Build container images
needs: [lint, tests]
runs-on: ubuntu-latest
steps:
- name: Set tag value
run: |
if [ '${{github.ref_type}}' = 'tag' ]; then
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=build-$GITHUB_SHA" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push remote build server
uses: docker/build-push-action@v4
with:
context: ./servers/remote-build
push: true
tags: |
ghcr.io/${{ github.repository }}-build-server:${{ env.RELEASE_VERSION }}
ghcr.io/${{ github.repository }}-build-server:latest
cache-from: type=gha
cache-to: type=gha,mode=max
helm:
name: Publish Helm chart
needs: [container-images]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# Fetch all branches/tags. This is needed to so that it can commit
# to the `gh-pages` branch.
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3
# When we don't pass a token, we get a warning annotation in the build
# result about missing a token but it still works by downloading the
# latest hard-coded version. This should be fine, but if at any point
# we want that warning annotation to go away, then simply uncomment the
# following two lines.
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"