-
Notifications
You must be signed in to change notification settings - Fork 1
186 lines (162 loc) · 6.39 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
name: Deepstream Docker
on:
push:
tags:
- 'v?[0-9]+.[0-9]+.[0-9]+*'
pull_request:
jobs:
build-test-report-publish:
if: ${{ github.repository == 'rmclabs-io/pythiags' }}
strategy:
matrix:
runner:
- {tags: [self-hosted, xavier, jetpack-5.0], buildx: '', platform: 'jetson'}
- {tags: [self-hosted, silverstone, gpu], buildx: '--buildx', platform: 'gpu'}
runs-on: ${{ matrix.runner.tags }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build docker development image
id: build-docker-dev
run: |
./scripts/docker.py build --target=dev ${{ matrix.runner.buildx }} --dry-run \
&& ./scripts/docker.py build ${{ matrix.runner.buildx }} --target=dev \
&& echo "CURRENT_TAG=$(cat .CURRENT_TAG)" >> $GITHUB_ENV
- name: Run Container detached
run: |
xhost +local:root \
&& docker network create pythia-network &> /tmp/nw-c || grep -q 'already exists' /tmp/nw-c \
&& docker run \
--rm \
--detach \
--ipc=host \
--gpus=all \
--network=pythia-network \
--cidfile=./current-container \
-e DISPLAY \
-e DBUS_FATAL_WARNINGS=0 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /var/run/docker.sock:/var/run/docker.sock \
--entrypoint tail \
${{ env.CURRENT_TAG }} \
-f /dev/null \
&& export CONTAINER_NAME=`cat ./current-container` \
&& echo "CONTAINER_NAME=$CONTAINER_NAME" >> $GITHUB_ENV
env:
DISPLAY: :0
- name: Run Code Style - Lint
if: ${{ matrix.runner.platform == 'gpu' }}
id: lint
run: |
docker exec ${{ env.CONTAINER_NAME }} ./scripts/lint
- name: Run Pyest
id: pytest
run: |
docker exec ${{ env.CONTAINER_NAME }} ./scripts/test
- name: Build Documentation
id: docs
run: |
docker exec ${{ env.CONTAINER_NAME }} ./scripts/docs
- name: Build python package - poetry build sdist and wheels
run: |
docker exec ${{ env.CONTAINER_NAME }} poetry build --format wheel
- name: Export package, Documentation and testing artifacts
id: docs-export
run: |
mkdir -p docs
rm -rf docs
docker cp ${{ env.CONTAINER_NAME }}:/opt/rmclabs/pythia/docs docs
touch docs/_build/html/.nojekyll
rm docs/_build/html/development/coverage/.gitignore
docker cp ${{ env.CONTAINER_NAME }}:/opt/rmclabs/pythia/reports reports
docker cp ${{ env.CONTAINER_NAME }}:/opt/rmclabs/pythia/dist dist
export WHEEL=`ls dist | grep whl | tail -n1` \
&& echo "WHEEL=$WHEEL" >> $GITHUB_ENV
- name: Upload pytest test results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: pytest-results-${{ matrix.runner.platform }}
path: ./reports/pytest.xml
- name: Upload coverage test results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: coverage-results-${{ matrix.runner.platform }}
path: ./reports/coverage.xml
- name: Comment coverage Results
if: github.event_name == 'pull_request' && (matrix.runner.platform == 'gpu')
uses: 5monkeys/cobertura-action@master
with:
path: reports/coverage.xml
repo_token: ${{ secrets.GITHUB_TOKEN }}
minimum_coverage: 41
fail_below_threshold: true
- name: Deploy Staging Docs
if: ${{ !startsWith(github.ref, 'refs/tags') && (matrix.runner.platform == 'gpu')}}
uses: JamesIves/[email protected]
with:
branch: staging
folder: docs/_build/html
repository-name: rmclabs-io/pythia-docs
token: ${{ secrets.CR_PAT }}
- name: Ensure git tag and poetry version are aligned
if: ${{ startsWith(github.ref, 'refs/tags') }}
run: |
export V1=`docker exec ${{ env.CONTAINER_NAME }} poetry version --short` \
&& export V2=${{ github.ref }} \
&& python3 -c "import os;e=os.environ;ref=e['V2'].lstrip('refs/tags/');assert e['V1'] == ref;open('ref','w').write(ref)" \
cat ref
- name: Deploy Production Docs
if: ${{ startsWith(github.ref, 'refs/tags') && (matrix.runner.platform == 'gpu')}}
uses: JamesIves/[email protected]
with:
branch: master
folder: docs/_build/html
repository-name: rmclabs-io/pythia-docs
token: ${{ secrets.CR_PAT }}
- name: Build docker prod
if: ${{ startsWith(github.ref, 'refs/tags') }}
id: build-docker-prod
run: |
./scripts/docker.py build --target=prod \
&& echo "CURRENT_TAG_PROD=$(cat .CURRENT_TAG)" >> $GITHUB_ENV
- name: Docker meta
if: ${{ startsWith(github.ref, 'refs/tags') }}
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.CURRENT_TAG }}
${{ env.CURRENT_TAG_PROD }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset
if: ${{ startsWith(github.ref, 'refs/tags') && (matrix.runner.platform == 'gpu') }}
uses: AButler/[email protected]
with:
files: 'dist/*'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ github.ref_name }}
- name: Publish package to PyPI
if: ${{ startsWith(github.ref, 'refs/tags') && (matrix.runner.platform == 'gpu') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
- name: Push tagged Docker image to GitHub Packages
if: ${{ startsWith(github.ref, 'refs/tags') }}
run: |
docker push ${{ env.CURRENT_TAG }}
docker push ${{ env.CURRENT_TAG_PROD }}
- name: Stop docker container
if: always()
id: stop-docker-container
run: |
docker container rm --force ${{ env.CONTAINER_NAME }}