forked from kubernetes-sigs/kubebuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(devcontainer): Add a GH Action for testing dev-container build.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |