-
Notifications
You must be signed in to change notification settings - Fork 11
109 lines (95 loc) · 4.05 KB
/
Copy pathdevcontainer.yml
File metadata and controls
109 lines (95 loc) · 4.05 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
name: Devcontainer
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
smoke-test:
name: ${{ matrix.name }}
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- scenario: python
name: Python and React
- scenario: csharp
name: C# and Blazor
- scenario: typescript-no-dotnet
name: TypeScript without .NET SDK
env:
SCENARIO: ${{ matrix.scenario }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '24'
- name: Install Dev Containers CLI
run: npm install --global @devcontainers/cli@0.89.0
- name: Prepare test configuration
run: |
mkdir -p "$RUNNER_TEMP/devcontainer-diagnostics"
config="$RUNNER_TEMP/devcontainer-test/devcontainer.json"
args=(--output "$config")
if [ "$SCENARIO" = typescript-no-dotnet ]; then
args+=(--without-dotnet)
fi
node .github/scripts/prepare-config.mjs "${args[@]}"
echo "DEVCONTAINER_CONFIG=$config" >> "$GITHUB_ENV"
- name: Start devcontainer
id: container
run: |
devcontainer up --workspace-folder . --config "$DEVCONTAINER_CONFIG" --mount-workspace-git-root false --no-lockfile \
> "$RUNNER_TEMP/devcontainer-up.json" \
2> >(tee "$RUNNER_TEMP/devcontainer-diagnostics/startup.log" >&2)
container_id=$(jq --exit-status --raw-output '.containerId' "$RUNNER_TEMP/devcontainer-up.json")
echo "container_id=$container_id" >> "$GITHUB_OUTPUT"
- name: Test fresh container
run: |
devcontainer exec --workspace-folder . --config "$DEVCONTAINER_CONFIG" node .github/scripts/smoke-test.mjs "$SCENARIO" \
2>&1 | tee "$RUNNER_TEMP/devcontainer-diagnostics/fresh.log"
- name: Stop and reopen devcontainer
env:
CONTAINER_ID: ${{ steps.container.outputs.container_id }}
run: |
docker stop "$CONTAINER_ID"
devcontainer up --workspace-folder . --config "$DEVCONTAINER_CONFIG" --mount-workspace-git-root false --no-lockfile --expect-existing-container \
2> >(tee "$RUNNER_TEMP/devcontainer-diagnostics/restart.log" >&2)
- name: Test restarted container
run: |
devcontainer exec --workspace-folder . --config "$DEVCONTAINER_CONFIG" node .github/scripts/smoke-test.mjs "$SCENARIO" \
2>&1 | tee "$RUNNER_TEMP/devcontainer-diagnostics/restarted.log"
- name: Collect failure diagnostics
if: failure() && steps.container.outputs.container_id != ''
env:
CONTAINER_ID: ${{ steps.container.outputs.container_id }}
run: |
mkdir -p "$RUNNER_TEMP/devcontainer-diagnostics"
docker logs "$CONTAINER_ID" > "$RUNNER_TEMP/devcontainer-diagnostics/container.log" 2>&1
docker inspect --format '{{json .State}}' "$CONTAINER_ID" > "$RUNNER_TEMP/devcontainer-diagnostics/container-state.json"
docker cp "$CONTAINER_ID:/home/vscode/.aspire/logs" "$RUNNER_TEMP/devcontainer-diagnostics/aspire"
- name: Upload failure diagnostics
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: devcontainer-${{ matrix.scenario }}-diagnostics
path: ${{ runner.temp }}/devcontainer-diagnostics
if-no-files-found: ignore
retention-days: 7
- name: Remove test container
if: always() && steps.container.outputs.container_id != ''
env:
CONTAINER_ID: ${{ steps.container.outputs.container_id }}
run: docker rm --force --volumes "$CONTAINER_ID"