-
Notifications
You must be signed in to change notification settings - Fork 339
140 lines (140 loc) · 4.73 KB
/
test-deploy.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
name: Test & Deploy
on:
pull_request_target:
workflow_dispatch:
workflow_call:
inputs:
release:
required: true
type: boolean
schedule:
- cron: '0 8 * * 1' # M H d m w (Mondays at 8:00)
jobs:
authorize:
environment:
${{ (github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository) &&
'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: echo ✓
check-lock:
needs: authorize
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: npm lock file is v2
run: jq --exit-status .lockfileVersion==2 < package-lock.json
lint:
needs: authorize
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- uses: actions/setup-node@v3
- run: npm ci
- run: npm run lint
test:
needs: authorize
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/setup-python@v2
with:
python-version: 3.9
- run: |
pip install tensorboard
pip install -I protobuf==3.20.1
- run: npm ci && npm install --global
- run: npm run test
env:
GITHUB_TOKEN: ${{ github.token }}
TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
TEST_GITHUB_REPOSITORY: ${{ vars.TEST_GITHUB_REPOSITORY }}
TEST_GITHUB_COMMIT: ${{ vars.TEST_GITHUB_COMMIT }}
TEST_GITHUB_ISSUE: ${{ vars.TEST_GITHUB_ISSUE }}
TEST_GITLAB_TOKEN: ${{ secrets.TEST_GITLAB_TOKEN }}
TEST_GITLAB_REPOSITORY: ${{ vars.TEST_GITLAB_REPOSITORY }}
TEST_GITLAB_COMMIT: ${{ vars.TEST_GITLAB_COMMIT }}
TEST_GITLAB_ISSUE: ${{ vars.TEST_GITLAB_ISSUE }}
TEST_BITBUCKET_TOKEN: ${{ secrets.TEST_BITBUCKET_TOKEN }}
TEST_BITBUCKET_REPOSITORY: ${{ vars.TEST_BITBUCKET_REPOSITORY }}
TEST_BITBUCKET_COMMIT: ${{ vars.TEST_BITBUCKET_COMMIT }}
TEST_BITBUCKET_ISSUE: ${{ vars.TEST_BITBUCKET_ISSUE }}
test-os:
needs: authorize
name: test-${{ matrix.system }}
strategy:
matrix:
system: [ubuntu, macos, windows]
runs-on: ${{ matrix.system }}-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- if: matrix.system == 'windows'
uses: actions/setup-node@v3
- name: install
shell: bash
run: |
# https://github.com/npm/npm/issues/18503#issuecomment-347579469
npm pack && npm install -g --no-save ./*cml*.tgz
for cmd in '' runner publish pr; do
cml $cmd --version
done
- if: matrix.system != 'windows'
run: |
for cmd in runner publish pr; do
cml-$cmd --version
done
packages:
needs: [lint, test, test-os]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.publish.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org
- run: npm install
- id: publish
run: |
VERSION=$(jq -r .version < package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
npm install --dry-run @dvcorg/cml@$VERSION ||
npm ${{ inputs.release && 'publish' || 'publish --dry-run' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Step required "thanks" to https://github.com/actions/runner-images/issues/6283
- uses: Homebrew/actions/setup-homebrew@3040c87fbdd10e6ec48d90bd23cb0abb6d66152d
- run: brew install ldid
- run: |
cp node_modules/@npcz/magic/dist/magic.mgc assets/magic.mgc
npx --yes pkg --no-bytecode --public-packages "*" --public package.json
for cmd in '' runner publish pr; do build/cml-linux-x64 $cmd --version; done
cp build/cml-linux{-x64,}
cp build/cml-macos{-x64,}
- if: inputs.release
run:
find build -type f | xargs gh release upload
"${GITHUB_HEAD_REF#bump/}"
env:
GITHUB_TOKEN: ${{ github.token }}
images:
needs: packages
secrets: inherit
uses: ./.github/workflows/images.yml
with:
release: ${{ inputs.release || false }}
version: ${{ needs.packages.outputs.version }}