Skip to content

Commit

Permalink
test(devcontainer): Add a GH Action for testing dev-container build.
Browse files Browse the repository at this point in the history
  • Loading branch information
TAM360 committed Aug 15, 2024
1 parent 0486fe0 commit 9dd369d
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/test-devcontainer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Test DevContainer Image

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test-devcontainer:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Go 1.22.x
uses: actions/setup-go@v5
with:
go-version: "1.22.x"

# required for installing devcontainer CLI
- name: Setup NodeJS 20.x
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Setup Devcontainer CLI
run: |
npm install -g @devcontainers/cli
- name: Generate sample Kubebuilder project
run: |
make install
mkdir test-project
cd test-project
../bin/kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project
# - name: Build and Validate DevContainer
# run: |
# ls -altr
# cd test-project/.devcontainer
# docker build -t kubebuilder-dc:latest .

# if docker image inspect kubebuilder-dc:latest > /dev/null 2>&1; then
# echo "Docker image was built successfully."
# else
# echo "Docker image build failed."
# exit 1
# fi

- name: Build and Validate DevContainer
run: |
ls -altr
OUTPUT=$(devcontainer up --workspace-folder=./test-project/)
STATUS=$(echo "$OUTPUT" | jq -r '.outcome')
if [[ "$STATUS" == "success" ]]; then
echo "Devcontainer setup was successful."
else
echo "Devcontainer setup failed."
exit 1
fi

0 comments on commit 9dd369d

Please sign in to comment.