Skip to content

Commit

Permalink
fix: correct permission for vcpkg and add tests (#23)
Browse files Browse the repository at this point in the history
* chore: use javascript-node
* fix: correct permission for vcpkg and add tests
* remove ubuntu:boinic from test matrix

---------

Signed-off-by: msclock <[email protected]>
  • Loading branch information
msclock authored Oct 23, 2024
1 parent a7649a0 commit 886743e
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-18",
"image": "mcr.microsoft.com/devcontainers/javascript-node",
"customizations": {
"vscode": {
"extensions": [
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
[
"ubuntu:focal",
"ubuntu:jammy",
"ubuntu:bionic",
"debian:11",
"debian:10",
"mcr.microsoft.com/devcontainers/base:ubuntu",
Expand All @@ -30,7 +29,22 @@ jobs:
run: npm install -g @devcontainers/cli

- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
run: devcontainer features test -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .

test-scenarios:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
features: ["vcpkg", "gitlab-ci-local"]
steps:
- uses: actions/checkout@v4

- name: "Install latest devcontainer CLI"
run: npm install -g @devcontainers/cli

- name: "Testing '${{ matrix.features }}' scenarios"
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated .

test-global:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Vcpkg Tool",
"id": "vcpkg",
"version": "1.3.5",
"version": "1.3.6",
"documentationURL": "https://github.com/msclock/features/tree/main/src/vcpkg",
"description": "A vcpkg tool feature",
"options": {
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _log() {
echo -e "$_preset["${level^^}"]:\033[0m $msg" 1>&2
}

USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
USERNAME="${_REMOTE_USER:-"${USERNAME:-"automatic"}"}"
VCPKG_ROOT="${VCPKGROOT:-"/usr/local/vcpkg"}"
VCPKG_DOWNLOADS="${VCPKGDOWNLOADS:-"/usr/local/vcpkg-downloads"}"
VCPKG_VERSION="${VCPKGVERSION:-"stable"}"
Expand Down
10 changes: 10 additions & 0 deletions test/gitlab-ci-local/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scene_tag": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"gitlab-ci-local": {
"version": "4.55.0"
}
}
}
}
21 changes: 21 additions & 0 deletions test/gitlab-ci-local/scene_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# shellcheck disable=SC1091

# This test can be run with the following command (from the root of this repo)
# devcontainer features test \
# --features vcpkg \
# --base-image mcr.microsoft.com/devcontainers/base:ubuntu .

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "gitlab-ci-local is installed" gitlab-ci-local --version

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
2 changes: 1 addition & 1 deletion test/gitlab-ci-local/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ check "gitlab-ci-local is installed" gitlab-ci-local --version

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
reportResults
35 changes: 35 additions & 0 deletions test/vcpkg/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"scene_use_existing_user_vscode": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"remoteUser": "vscode",
"features": {
"vcpkg": {}
}
},
"scene_use_created_user_dummy": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"remoteUser": "dummy",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"username": "dummy"
},
"vcpkg": {}
}
},
"scene_stable": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"vcpkg": {
"vcpkgversion": "stable"
}
}
},
"scene_tag": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"vcpkg": {
"vcpkgversion": "2024.09.30"
}
}
}
}
23 changes: 23 additions & 0 deletions test/vcpkg/scene_stable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# shellcheck disable=SC1091

# This test can be run with the following command (from the root of this repo)
# devcontainer features test \
# --features vcpkg \
# --base-image mcr.microsoft.com/devcontainers/base:ubuntu .

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "vcpkg is installed" vcpkg --version
check "cmake is installed" cmake --version
check "write permission" bash -c "test -w /usr/local/vcpkg"

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

# shellcheck disable=SC1091

# This test can be run with the following command (from the root of this repo)
# devcontainer features test \
# --features vcpkg \
# --base-image mcr.microsoft.com/devcontainers/base:ubuntu .

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "vcpkg is installed" vcpkg --version
check "cmake is installed" cmake --version
check "write permission" bash -c "test -w /usr/local/vcpkg"

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

# shellcheck disable=SC1091

# This test can be run with the following command (from the root of this repo)
# devcontainer features test \
# --features vcpkg \
# --base-image mcr.microsoft.com/devcontainers/base:ubuntu .

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "vcpkg is installed" vcpkg --version
check "cmake is installed" cmake --version
check "write permission" bash -c "test -w /usr/local/vcpkg"

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

# shellcheck disable=SC1091

# This test can be run with the following command (from the root of this repo)
# devcontainer features test \
# --features vcpkg \
# --base-image mcr.microsoft.com/devcontainers/base:ubuntu .

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "vcpkg is installed" vcpkg --version
check "cmake is installed" cmake --version
check "write permission" bash -c "test -w /usr/local/vcpkg"

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
3 changes: 2 additions & 1 deletion test/vcpkg/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ source dev-container-features-test-lib
# The 'check' command comes from the dev-container-features-test-lib.
check "vcpkg is installed" vcpkg --version
check "cmake is installed" cmake --version
check "write permission" bash -c "test -w /usr/local/vcpkg"

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

0 comments on commit 886743e

Please sign in to comment.