1
+ name : ' VSCDC smoke test'
2
+ inputs :
3
+ definition :
4
+ description : ' Definition to test'
5
+ required : true
6
+ default : ' debian'
7
+ image :
8
+ description : ' Image to run smoke test in'
9
+ required : true
10
+ default : ' none'
11
+
12
+ runs :
13
+ using : composite
14
+ steps :
15
+ - name : Build image
16
+ id : build_image
17
+ shell : bash
18
+ run : |
19
+ set -e
20
+
21
+ # Run test build
22
+ yarn install
23
+ GIT_BRANCH=$(echo "${{ github.ref }}" | grep -oP 'refs/(heads|tags)/\K(.+)')
24
+ if [ "$GIT_BRANCH" == "" ]; then
25
+ GIT_BRANCH=main
26
+ fi
27
+ chmod +x build/vscdc
28
+ build/vscdc push ${{ inputs.definition }} \
29
+ --no-push \
30
+ --release $GIT_BRANCH \
31
+ --github-repo "microsoft/vscode-dev-containers" \
32
+ --registry "mcr.microsoft.com" \
33
+ --registry-path "vscode/devcontainers" \
34
+ --stub-registry "mcr.microsoft.com" \
35
+ --stub-registry-path "vscode/devcontainers"
36
+
37
+ - name : Test image
38
+ id : test_image
39
+ shell : bash
40
+ run : |
41
+ if [ "${{ inputs.image }}" = "none" ]; then
42
+ echo "Image not specified. Skipping test."
43
+ exit 0
44
+ fi
45
+
46
+ set -e
47
+
48
+ # Fake out existance of extensions, VS Code server
49
+ dev_container_relative_path="/containers/${{ inputs.definition }}/.devcontainer"
50
+ mkdir -p "/tmp/${dev_container_relative_path}"
51
+ cp -f $(pwd)/${dev_container_relative_path}/devcontainer.json "/tmp/${dev_container_relative_path}/"
52
+ dev_container_tmp="/tmp/${dev_container_relative_path}/devcontainer.json"
53
+ sed -i'.bak' -e "s/\\/\\/.*/ /g" "${dev_container_tmp}"
54
+ extensions="$(jq '.extensions' --compact-output "${dev_container_tmp}" | tr -d '[' | tr -d ']' | tr ',' ' ') 2>/dev/null || echo ''"
55
+ docker run --rm --init --privileged -u "${{ inputs.user }}" "${{ inputs.image }}" /bin/sh -c "\
56
+ mkdir -p \"\$HOME/.vscode-test-server/extensions\" \
57
+ cd \"\$HOME/.vscode-test-server/extensions\" \
58
+ if [ \"${extensions}\" != '' ]; then echo \"${extensions}\" | xargs -n 1 mkdir -p; fi"
59
+
60
+ # Run actual test
61
+ docker run --rm --init --privileged -u "${{ inputs.user }}" -v "$(pwd)/containers/${{ inputs.definition }}:/workspace" "${{ inputs.image }}" /bin/sh -c '\
62
+ set -e
63
+ cd /workspace \
64
+ && if [ -f "test-project/test.sh" ]; then \
65
+ cd test-project \
66
+ && if [ "$(id -u)" = "0" ]; then \
67
+ chmod +x test.sh; \
68
+ else \
69
+ sudo chmod +x test.sh; \
70
+ fi \
71
+ && ./test.sh; \
72
+ else \
73
+ ls -a;
74
+ fi'
0 commit comments