-
Notifications
You must be signed in to change notification settings - Fork 178
190 lines (181 loc) · 6.17 KB
/
shared-data-test-lint-deploy.yaml
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
# This workflow runs tests and lint on branch pushes that touch the
# shared-data project or its CI configuration.
name: 'shared-data test/lint/deploy'
on:
push:
paths:
- 'Makefile'
- 'shared-data/*/**'
- 'scripts/**/*.mk'
- 'scripts/**/*.py'
- '.github/workflows/shared-data-test-lint-deploy.yaml'
- '.github/actions/python/**/*'
- '.github/workflows/utils.js'
branches:
- 'edge'
- 'release'
- '*hotfix*'
tags:
- 'v*'
pull_request:
paths:
- 'Makefile'
- 'shared-data/*/**'
- 'scripts/**/*.mk'
- 'scripts/**/*.py'
- '.github/workflows/shared-data-test-lint-deploy.yaml'
- '.github/actions/python/**/*'
- '.github/workflows/utils.js'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ github.ref_name != 'edge' || github.run_id}}-${{ github.ref_type != 'tag' || github.run_id }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
python-lint:
name: 'shared-data package python lint'
timeout-minutes: 10
runs-on: 'ubuntu-22.04'
steps:
- uses: 'actions/checkout@v3'
with:
fetch-depth: 0
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
- uses: 'actions/setup-python@v3'
with:
python-version: '3.7'
- uses: './.github/actions/python/setup'
with:
project: 'shared-data/python'
- name: Lint
run: make -C shared-data/python lint
python-test:
name: 'shared-data package python ${{ matrix.python }} tests on ${{ matrix.os }}'
timeout-minutes: 20
needs: [python-lint]
strategy:
matrix:
os: ['windows-2022', 'ubuntu-22.04', 'macos-latest']
# TODO(mc, 2022-02-24): expand this matrix to 3.8 and 3.9,
# preferably in a nightly cronjob on edge or something
python: ['3.7', '3.10']
exclude:
- os: 'macos-latest'
python: '3.10'
runs-on: '${{ matrix.os }}'
steps:
- uses: 'actions/checkout@v3'
with:
fetch-depth: 0
- name: 'install udev for usb-detection'
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get update && sudo apt-get install libudev-dev
- uses: 'actions/setup-node@v1'
with:
node-version: '16'
- uses: 'actions/setup-python@v4'
with:
python-version: ${{ matrix.python }}
- uses: './.github/actions/python/setup'
with:
project: 'shared-data/python'
python-version: ${{ matrix.python }}
- name: 'set complex environment variables'
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- name: Test
run: make -C shared-data/python test
- name: Ensure assets build
run: make -C shared-data/python sdist wheel
- name: 'Upload coverage report'
uses: codecov/codecov-action@v3
with:
files: ./shared-data/python/coverage.xml
flags: shared-data
js-test:
name: 'shared-data JS tests'
runs-on: 'ubuntu-22.04'
timeout-minutes: 30
steps:
- uses: 'actions/checkout@v3'
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
- name: 'install udev'
run: sudo apt-get update && sudo apt-get install libudev-dev
- name: 'cache yarn cache'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.yarn-cache
${{ github.workspace }}/.npm-cache
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-
- name: 'setup-js'
run: |
npm config set cache ./.npm-cache
yarn config set cache-folder ./.yarn-cache
make setup-js
- name: 'run shared-data JS unit tests'
run: |
yarn jest --coverage=true --ci=true --collectCoverageFrom="shared-data/js/**/*.(js|ts|tsx)" shared-data/js
- name: 'Upload coverage report'
uses: codecov/codecov-action@v3
with:
files: ./coverage/lcov.info
flags: shared-data
python-deploy:
name: 'shared-data package deploy'
needs: [python-test]
runs-on: 'ubuntu-22.04'
if: github.event_name == 'push'
steps:
- uses: 'actions/checkout@v3'
with:
fetch-depth: 0
# https://github.com/actions/checkout/issues/290
- name: 'Fix actions/checkout odd handling of tags'
if: startsWith(github.ref, 'refs/tags')
run: |
git fetch -f origin ${{ github.ref }}:${{ github.ref }}
git checkout ${{ github.ref }}
- uses: 'actions/setup-node@v3'
with:
node-version: '16'
- name: 'install udev for usb-detection'
run: sudo apt-get update && sudo apt-get install libudev-dev
- uses: 'actions/setup-python@v4'
with:
python-version: '3.7'
- uses: './.github/actions/python/setup'
with:
project: 'shared-data/python'
- name: 'set complex environment variables'
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars, } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
# creds and repository configuration for deploying python wheels
- if: ${{ !env.OT_TAG }}
name: 'upload to test pypi'
uses: './.github/actions/python/pypi-deploy'
with:
project: 'shared-data/python'
repository_url: 'https://test.pypi.org/legacy/'
password: '${{ secrets.OT_TEST_PYPI_PASSWORD }}'
- if: startsWith(env.OT_TAG, 'v')
name: 'upload to pypi'
uses: './.github/actions/python/pypi-deploy'
with:
project: 'shared-data/python'
repository_url: 'https://upload.pypi.org/legacy/'
password: '${{ secrets.OT_PYPI_PASSWORD }}'