Skip to content

Commit

Permalink
Add test suite for actionlint feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarber623-cargosense committed Feb 28, 2024
1 parent 04bbe39 commit cb7d4b9
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 8 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,3 @@ jobs:
- uses: actions/checkout@v4
- run: npm install -g @devcontainers/cli
- run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated .
test-global:
name: Test global scenarios
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- run: npm install -g @devcontainers/cli
- run: devcontainer features test --global-scenarios-only .
17 changes: 17 additions & 0 deletions test/actionlint/actionlint-install-path.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "which actionlint" bash -c "which actionlint | grep /usr/bin/actionlint"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
17 changes: 17 additions & 0 deletions test/actionlint/actionlint-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "version" bash -c "actionlint --version | grep 1.2.3"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
19 changes: 19 additions & 0 deletions test/actionlint/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"actionlint-version": {
"image": "debian:latest",
"features": {
"actionlint": {
"version": "1.2.3"
}
}
},

"actionlint-install-path": {
"image": "debian:latest",
"features": {
"actionlint": {
"installPath": "/usr/bin"
}
}
}
}
47 changes: 47 additions & 0 deletions test/actionlint/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

# This test file will be executed against an auto-generated devcontainer.json that
# includes the 'actionlint' Feature with no options.
#
# For more information, see: https://github.com/devcontainers/cli/blob/main/docs/features/test.md
#
# Eg:
# {
# "image": "<..some-base-image...>",
# "features": {
# "actionlint": {}
# },
# "remoteUser": "root"
# }
#
# Thus, the value of all options will fall back to the default value in the
# Feature's 'devcontainer-feature.json'.
#
# These scripts are run as 'root' by default. Although that can be changed
# with the '--remote-user' flag.
#
# This test can be run with the following command:
#
# devcontainer features test \
# --features actionlint \
# --remote-user root \
# --skip-scenarios \
# --base-image mcr.microsoft.com/devcontainers/base:ubuntu \
# /path/to/this/repo

set -e

# Optional: Import test library bundled with the devcontainer CLI
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
# Provides the 'check' and 'reportResults' commands.
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "version" actionlint --version
check "which actionlint" bash -c "which actionlint | grep /usr/local/bin/actionlint"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults

0 comments on commit cb7d4b9

Please sign in to comment.