Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/actions/smoke-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ inputs:
description: 'Definition to test'
required: true
default: 'debian'
image:
description: 'Image to run smoke test in'
required: true
default: 'none'
user:
description: 'User in container image to use for smoke test'
required: true
Expand All @@ -14,16 +18,18 @@ runs:
steps:
- name: Checkout main
id: checkout_release
uses: actions/checkout@v3
uses: actions/checkout@v2
with:
repository: 'devcontainers/images'
path: '__build'
ref: 'main'

- name: Build image
id: build_image
shell: bash
run: ${{ github.action_path }}/build.sh ${{ inputs.definition }}

- name: Test image
id: test_image
shell: bash
run: chmod +x ${{ github.action_path }}/test.sh && ${{ github.action_path }}/test.sh ${{ inputs.definition }} ${{ inputs.user }}
run: ${{ github.action_path }}/test.sh ${{ inputs.definition }} ${{ inputs.image }} ${{ inputs.user }}
26 changes: 18 additions & 8 deletions .github/actions/smoke-test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ DEFINITION="$1"
set -e

export DOCKER_BUILDKIT=1
echo "(*) Pulling latest '@devcontainer/cli"
# npm install -g @devcontainers/cli

#Temporarily installing cli from source until https://github.com/devcontainers/cli/pull/6 is merged
cd build
chmod +x devcontainers-cli-0.3.0-1.tgz
# Symlink build scripts from main to improve security when testing PRs
if [ -d "$GITHUB_WORKSPACE/__build/build" ]; then
cp -r "$GITHUB_WORKSPACE/__build/build" "$GITHUB_WORKSPACE/"
else
echo "WARNING: Using build/vscdc from $GITHUB_REF instead of main."
fi
rm -rf node_modules
yarn install

echo "(*) Building image - ${DEFINITION}"
npx --yes devcontainers-cli-0.3.0-1.tgz up --workspace-folder ../src/${DEFINITION}
# devcontainer build --workspace-folder "src/${DEFINITION}/" --image-name vsc-${DEFINITION}
# Run test build
chmod +x build/vscdc
build/vscdc push ${DEFINITION} \
--no-push \
--release dev \
--github-repo "devcontainers/images" \
--registry "mcr.microsoft.com" \
--registry-path "devcontainers" \
--stub-registry "mcr.microsoft.com" \
--stub-registry-path "devcontainers"
48 changes: 42 additions & 6 deletions .github/actions/smoke-test/test.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
#/bin/bash
DEFINITION="$1"
USERNAME="$2"
IMAGE="$2"
USERNAME="$3"

export DOCKER_BUILDKIT=1
set -e

# List docker images
echo "(*) Listing docker images..."
docker images


# Update UID/GID for user in container - Actions uses different UID/GID than container
# which causes bind mounts to be read only and cause certain write tests to fail
# The dev container CLI handles this automatically but we're not using it.
local_uid=$(id -u)
local_gid=$(id -g)

echo "(*) Updating container user UID/GID..."
echo -e "FROM ${IMAGE}\n \
RUN export sudo_cmd="" \
&& if [ "$(id -u)" != "0" ]; then export sudo_cmd=sudo; fi \
&& \${sudo_cmd} groupmod -g ${local_gid} ${USERNAME} \
&& \${sudo_cmd} usermod -u ${local_uid} -g ${local_gid} ${USERNAME}" > uid.Dockerfile
cat uid.Dockerfile
docker build -t ${IMAGE}-uid -f uid.Dockerfile .

# Start container
echo "(*) Starting container..."
container_name="vscdc-test-container-$DEFINITION"
docker run -d --name ${container_name} --rm --init --privileged -v "$(pwd)/src/${DEFINITION}:/workspace" ${IMAGE}-uid /bin/sh -c 'while sleep 1000; do :; done'

# Run actual test
echo "(*) Running test..."
cd build
chmod +x devcontainers-cli-0.3.0-1.tgz

npx --yes devcontainers-cli-0.3.0-1.tgz exec --workspace-folder $(pwd)/../src/$DEFINITION /bin/sh -c 'set -e && if [ -f "test-project/test.sh" ]; then cd test-project && if [ "$(id -u)" = "0" ]; then chmod +x test.sh; else sudo chmod +x test.sh; fi && ./test.sh; else ls -a; fi'
docker exec -u "${USERNAME}" ${container_name} /bin/sh -c '\
set -e \
&& cd /workspace \
&& if [ -f "test-project/test.sh" ]; then \
cd test-project \
&& if [ "$(id -u)" = "0" ]; then \
chmod +x test.sh; \
else \
sudo chmod +x test.sh; \
fi \
&& ./test.sh; \
else \
ls -a;
fi'

# Clean up
docker stop $(docker container ls -q)
docker rm -f ${container_name}
4 changes: 2 additions & 2 deletions .github/workflows/push-and-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
name: Build and push images
strategy:
matrix:
page: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
page-total: [10]
page: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
page-total: [11]
fail-fast: false
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
if: "!contains(github.event.head_commit.message, 'Automated update') && !contains(github.event.head_commit.message, 'CI ignore')"
strategy:
matrix:
page: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
page-total: [10]
page: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
page-total: [11]
fail-fast: true
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/smoke-alpine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
paths:
- src/alpine/**
- .github/workflows/smoke-alpine.yaml
- .github/actions/**
- build/**
jobs:
smoke-test:
name: Smoke test
Expand All @@ -24,4 +26,5 @@ jobs:
uses: ./.github/actions/smoke-test
with:
definition: alpine
image: mcr.microsoft.com/devcontainers/base:dev-alpine
user: vscode
3 changes: 3 additions & 0 deletions .github/workflows/smoke-anaconda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
paths:
- src/anaconda/**
- .github/workflows/smoke-anaconda.yaml
- .github/actions/**
- build/**
jobs:
smoke-test:
name: Smoke test
Expand All @@ -26,4 +28,5 @@ jobs:
uses: ./.github/actions/smoke-test
with:
definition: anaconda
image: mcr.microsoft.com/devcontainers/anaconda:dev-3
user: vscode
14 changes: 7 additions & 7 deletions .github/workflows/smoke-codespaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: Smoke test "codespaces" build

on:
workflow_dispatch:

push:
branches: [main]
paths:
- 'src/codespaces/**'
pull_request:
branches:
- main
- main
pull_request:
paths:
- 'src/codespaces/**'
- src/codespaces/**
- .github/codespaces/smoke-codespaces.yaml
- .github/actions/**
- build/**
jobs:
smoke-test:
name: Smoke test
Expand All @@ -29,4 +28,5 @@ jobs:
uses: ./.github/actions/smoke-test
with:
definition: codespaces
image: mcr.microsoft.com/devcontainers/universal:dev-linux
user: codespace
14 changes: 7 additions & 7 deletions .github/workflows/smoke-cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: Smoke test "cpp" build

on:
workflow_dispatch:

push:
branches: [main]
paths:
- 'src/cpp/**'
pull_request:
branches:
- main
- main
pull_request:
paths:
- 'src/cpp/**'
- src/cpp/**
- .github/workflows/smoke-cpp.yaml
- .github/actions/**
- build/**
jobs:
smoke-test:
name: Smoke test
Expand All @@ -27,4 +26,5 @@ jobs:
uses: ./.github/actions/smoke-test
with:
definition: cpp
image: mcr.microsoft.com/devcontainers/cpp:dev-debian
user: vscode
14 changes: 7 additions & 7 deletions .github/workflows/smoke-debian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: Smoke test "debian" build

on:
workflow_dispatch:

push:
branches: [main]
paths:
- 'src/debian/**'
pull_request:
branches:
- main
- main
pull_request:
paths:
- 'src/debian/**'
- src/debian/**
- .github/workflows/smoke-debian.yaml
- .github/actions/**
- build/**
jobs:
smoke-test:
name: Smoke test
Expand All @@ -27,4 +26,5 @@ jobs:
uses: ./.github/actions/smoke-test
with:
definition: debian
image: mcr.microsoft.com/devcontainers/base:dev-debian
user: vscode
14 changes: 7 additions & 7 deletions .github/workflows/smoke-dotnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: Smoke test "dotnet" build

on:
workflow_dispatch:

push:
branches: [main]
paths:
- 'src/dotnet/**'
pull_request:
branches:
- main
- main
pull_request:
paths:
- 'src/dotnet/**'
- src/dotnet/**
- .github/workflows/smoke-dotnet.yaml
- .github/actions/**
- build/**
jobs:
smoke-test:
name: Smoke test
Expand All @@ -29,4 +28,5 @@ jobs:
uses: ./.github/actions/smoke-test
with:
definition: dotnet
image: mcr.microsoft.com/devcontainers/dotnet:dev-6.0
user: vscode
14 changes: 7 additions & 7 deletions .github/workflows/smoke-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: Smoke test "go" build

on:
workflow_dispatch:

push:
branches: [main]
paths:
- 'src/go/**'
pull_request:
branches:
- main
- main
pull_request:
paths:
- 'src/go/**'
- src/go/**
- .github/workflows/smoke-go.yaml
- .github/actions/**
- build/**
jobs:
smoke-test:
name: Smoke test
Expand All @@ -29,4 +28,5 @@ jobs:
uses: ./.github/actions/smoke-test
with:
definition: go
image: mcr.microsoft.com/devcontainers/go:dev-1
user: vscode
14 changes: 7 additions & 7 deletions .github/workflows/smoke-java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: Smoke test "java" build

on:
workflow_dispatch:

push:
branches: [main]
paths:
- 'src/java/**'
pull_request:
branches:
- main
- main
pull_request:
paths:
- 'src/java/**'
- src/java/**
- .github/workflows/smoke-java.yaml
- .github/actions/**
- build/**
jobs:
smoke-test:
name: Smoke test
Expand All @@ -29,4 +28,5 @@ jobs:
uses: ./.github/actions/smoke-test
with:
definition: java
image: mcr.microsoft.com/devcontainers/java:dev-17
user: vscode
14 changes: 7 additions & 7 deletions .github/workflows/smoke-jekyll.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: Smoke test "jekyll" build

on:
workflow_dispatch:

push:
branches: [main]
paths:
- 'src/jekyll/**'
pull_request:
branches:
- main
- main
pull_request:
paths:
- 'src/jekyll/**'
- src/jekyll/**
- .github/workflows/smoke-jekyll.yaml
- .github/actions/**
- build/**
jobs:
smoke-test:
name: Smoke test
Expand All @@ -27,4 +26,5 @@ jobs:
uses: ./.github/actions/smoke-test
with:
definition: jekyll
image: mcr.microsoft.com/devcontainers/jekyll:dev-bullseye
user: vscode
Loading