Skip to content

Commit 39f728a

Browse files
Merge pull request #27 from eitsupi/separate-tests
Separate test jobs
2 parents ea254a2 + 7ca0043 commit 39f728a

File tree

6 files changed

+98
-2
lines changed

6 files changed

+98
-2
lines changed

.github/workflows/test.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
test:
10+
test-autogenerated:
1111
runs-on: ubuntu-latest
1212
continue-on-error: true
1313
strategy:
@@ -26,7 +26,24 @@ jobs:
2626
run: npm install -g @devcontainers/cli
2727

2828
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
29-
run: devcontainer features test -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
29+
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
30+
31+
test-scenarios:
32+
runs-on: ubuntu-latest
33+
continue-on-error: true
34+
strategy:
35+
matrix:
36+
features:
37+
- color
38+
- hello
39+
steps:
40+
- uses: actions/checkout@v3
41+
42+
- name: "Install latest devcontainer CLI"
43+
run: npm install -g @devcontainers/cli
44+
45+
- name: "Generating tests for '${{ matrix.features }}' scenarios"
46+
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated .
3047

3148
test-global:
3249
runs-on: ubuntu-latest

test/color/gold.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# This test file will be executed against one of the scenarios devcontainer.json test that
4+
# includes the 'color' feature with "favorite": "gold" option.
5+
6+
set -e
7+
8+
# Optional: Import test library bundled with the devcontainer CLI
9+
source dev-container-features-test-lib
10+
11+
# Feature-specific tests
12+
# The 'check' command comes from the dev-container-features-test-lib.
13+
check "version" bash -c "color | grep 'my favorite color is gold'"
14+
15+
# Report result
16+
# If any of the checks above exited with a non-zero exit code, the test will fail.
17+
reportResults

test/color/green.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# This test file will be executed against one of the scenarios devcontainer.json test that
4+
# includes the 'color' feature with "favorite": "green" option.
5+
6+
set -e
7+
8+
# Optional: Import test library bundled with the devcontainer CLI
9+
source dev-container-features-test-lib
10+
11+
# Feature-specific tests
12+
# The 'check' command comes from the dev-container-features-test-lib.
13+
check "version" bash -c "color | grep 'my favorite color is green'"
14+
15+
# Report result
16+
# If any of the checks above exited with a non-zero exit code, the test will fail.
17+
reportResults

test/color/scenarios.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"gold": {
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"color": {
6+
"favorite": "gold"
7+
}
8+
}
9+
},
10+
"green": {
11+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
12+
"features": {
13+
"color": {
14+
"favorite": "green"
15+
}
16+
}
17+
}
18+
}

test/hello/hello.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# This test file will be executed against one of the scenarios devcontainer.json test that
4+
# includes the 'color' feature with "greeting": "hello" option.
5+
6+
set -e
7+
8+
# Optional: Import test library bundled with the devcontainer CLI
9+
source dev-container-features-test-lib
10+
11+
# Feature-specific tests
12+
# The 'check' command comes from the dev-container-features-test-lib.
13+
check "version" bash -c "hello | grep 'hello, $(whoami)!'"
14+
15+
# Report results
16+
# If any of the checks above exited with a non-zero exit code, the test will fail.
17+
reportResults

test/hello/scenarios.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"hello": {
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"hello": {
6+
"greeting": "hello"
7+
}
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)