forked from devcontainers/cli
-
Notifications
You must be signed in to change notification settings - Fork 1
221 lines (214 loc) · 8.12 KB
/
dev-containers.yml
File metadata and controls
221 lines (214 loc) · 8.12 KB
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
214
215
216
217
218
219
220
221
name: Dev Containers CI
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
concurrency:
group: test-${{ github.event_name }}-from-${{ github.ref_name }}
cancel-in-progress: true
jobs:
changed:
name: Check for changed files
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changes.outputs.any_changed }}
any_deleted: ${{ steps.changes.outputs.any_deleted }}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Check if source files changed
id: changes
uses: tj-actions/[email protected]
with:
files: |
*.js
*.json
yarn.lock
package.json
.github/workflows/dev-containers.yml
src/**
build/**
scripts/**
- name: Report changes
shell: bash
run: |
echo '${{ toJSON(steps.changes.outputs) }}'
cli:
name: CLI
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-20.04, pkg: node, os-name: linux, node: 16 }
- { os: ubuntu-20.04, pkg: standalone, os-name: linux, node: 16 }
- { os: macos-11, pkg: standalone, os-name: macos, node: 16 }
- { os: windows-2019, pkg: standalone, os-name: win, node: 16, exe-suf: '.exe' }
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Env
shell: bash
run: |
VER=$(cat package.json | jq -r '.version');
TAG=${VER}-${GITHUB_SHA:0:8};
echo "VER=${VER}" >> $GITHUB_ENV;
echo "TAG=${TAG}" >> $GITHUB_ENV;
if [[ "${{ matrix.pkg }}" == "node" ]]; then
echo "PKG_NPM_SCRIPT=package" >> $GITHUB_ENV;
echo "ARTIFACT_SLUG=devcontainers-cli-${TAG}.tgz" >> $GITHUB_ENV;
echo "ARTIFACT_PATH=devcontainers-cli-${VER}.tgz" >> $GITHUB_ENV;
else
echo "PKG_NPM_SCRIPT=package-standalone-${{ matrix.os-name }}-x64" >> $GITHUB_ENV;
echo "ARTIFACT_SLUG=devcontainer-${{ matrix.os-name }}-x64-${TAG}${{ matrix.exe-suf }}" >> $GITHUB_ENV;
echo "ARTIFACT_PATH=dist/devcontainer-${{ matrix.os-name }}-x64${{ matrix.exe-suf }}" >> $GITHUB_ENV;
fi
- uses: actions/setup-node@v3
with:
scope: '@microsoft'
node-version: '${{ matrix.node }}.x'
registry-url: 'https://npm.pkg.github.com'
- name: Cache node_modules
uses: actions/cache@v3
with:
key: ${{ matrix.os }}-${{ env.VER }}-node${{ matrix.node }}-node_modules-${{ hashFiles('**/yarn.lock', '**/package.json') }}
path: node_modules
- name: Install Dependencies
shell: bash
run: yarn install --frozen-lockfile
- name: Type Check
if: matrix.pkg == 'node'
shell: bash
run: yarn type-check
- name: Lint
if: matrix.pkg == 'node'
shell: bash
run: yarn lint
- name: Package
shell: bash
run: yarn ${{ env.PKG_NPM_SCRIPT }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_SLUG }}
path: ${{ env.ARTIFACT_PATH }}
tests-matrix:
name: Test
needs: [changed, cli]
if: needs.changed.outputs.any_changed == 'true' || needs.changed.outputs.any_deleted == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
pkg: [node]
node: [16]
mocha-args:
- src/test/container-features/e2e.test.ts
- src/test/container-features/featuresCLICommands.test.ts
- src/test/container-features/containerFeaturesOrder.test.ts
- src/test/cli.build.test.ts
- src/test/cli.exec.buildKit.1.test.ts
- src/test/cli.exec.buildKit.2.test.ts
- src/test/cli.exec.nonBuildKit.1.test.ts
- src/test/cli.exec.nonBuildKit.2.test.ts
- src/test/cli.test.ts
- src/test/cli.up.test.ts
- src/test/container-features/containerFeaturesOCIPush.test.ts
- src/test/container-features/registryCompatibilityOCI.test.ts
# Run all except the above:
- "--exclude src/test/container-features/registryCompatibilityOCI.test.ts \
--exclude src/test/container-features/containerFeaturesOCIPush.test.ts \
--exclude src/test/container-features/e2e.test.ts \
--exclude src/test/container-features/featuresCLICommands.test.ts \
--exclude src/test/container-features/containerFeaturesOrder.test.ts \
--exclude src/test/cli.build.test.ts \
--exclude src/test/cli.exec.buildKit.1.test.ts \
--exclude src/test/cli.exec.buildKit.2.test.ts \
--exclude src/test/cli.exec.nonBuildKit.1.test.ts \
--exclude src/test/cli.exec.nonBuildKit.2.test.ts \
--exclude src/test/cli.test.ts \
--exclude src/test/cli.up.test.ts \
'src/test/**/*.test.ts'"
include:
- { os: ubuntu-20.04, pkg: standalone, node: 16, os-name: linux, mocha-args: 'src/test/cli.exec.{buildKit,nonBuildKit}.*.test.ts' }
- { os: ubuntu-20.04, pkg: standalone, node: 16, os-name: linux, mocha-args: 'src/test/container-features/{containerFeaturesOCI,generateFeaturesConfig}.test.ts' }
- { os: macos-11, pkg: standalone, node: 16, os-name: macos, mocha-args: 'src/test/container-features/{containerFeaturesOCI,generateFeaturesConfig}.test.ts' }
- { os: windows-2019, pkg: standalone, node: 16, os-name: win, mocha-args: 'src/test/container-features/{containerFeaturesOCI,generateFeaturesConfig}.test.ts', exe-suf: '.exe' }
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Env
shell: bash
run: |
VER=$(cat package.json | jq -r '.version');
TAG=${VER}-${GITHUB_SHA:0:8};
echo "VER=${VER}" >> $GITHUB_ENV;
echo "TAG=${TAG}" >> $GITHUB_ENV;
if [[ "${{ matrix.pkg }}" == "node" ]]; then
echo "TEST_STANDALONE_PKG=0" >> $GITHUB_ENV;
echo "ARTIFACT_PATH=." >> $GITHUB_ENV;
echo "ARTIFACT_NAME=devcontainers-cli-${VER}.tgz" >> $GITHUB_ENV;
echo "ARTIFACT_SLUG=devcontainers-cli-${TAG}.tgz" >> $GITHUB_ENV;
else
echo "TEST_STANDALONE_PKG=1" >> $GITHUB_ENV;
echo "ARTIFACT_PATH=dist" >> $GITHUB_ENV;
echo "ARTIFACT_NAME=devcontainer-${{ matrix.os-name }}-x64${{ matrix.exe-suf }}" >> $GITHUB_ENV;
echo "ARTIFACT_SLUG=devcontainer-${{ matrix.os-name }}-x64-${TAG}${{ matrix.exe-suf }}" >> $GITHUB_ENV;
fi
- name: Setup Node.js
uses: actions/setup-node@v3
with:
scope: '@microsoft'
node-version: '${{ matrix.node }}.x'
registry-url: 'https://npm.pkg.github.com'
- name: Cache node_modules
uses: actions/cache@v3
with:
key: ${{ matrix.os }}-${{ env.VER }}-node${{ matrix.node }}-node_modules-${{ hashFiles('**/yarn.lock', '**/package.json') }}
path: node_modules
- name: Install Dependencies
shell: bash
run: yarn install --frozen-lockfile
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_SLUG }}
path: ${{ env.ARTIFACT_PATH }}
- name: Install docker for macOS
if: startsWith(matrix.os, 'macos')
shell: bash
env:
HOMEBREW_ACCEPT_EULA: Y
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: Y
run: |
brew install docker;
colima start;
docker ps -a;
- name: Run Tests
shell: bash
env:
NODE_NO_WARNINGS: ${{ env.TEST_STANDALONE_PKG }}
run: |
if [[ "$TEST_STANDALONE_PKG" == "1" ]]; then
chmod +x ${ARTIFACT_PATH}/${ARTIFACT_NAME};
fi
yarn test-matrix --forbid-only ${{ matrix.mocha-args }};
tests:
name: Tests
needs: tests-matrix
runs-on: ubuntu-latest
steps:
- name: Done
shell: bash
run: echo "Test Matrix done."