Merge pull request #225 from konflux-ci/konflux/mintmaker/main/contai… #1029
This file contains hidden or 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
name: DevContainer CI | |
on: | |
pull_request: | |
merge_group: | |
types: [checks_requested] | |
push: | |
branches: [ main ] | |
jobs: | |
build-devcontainer: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Free disk space | |
uses: jlumbroso/[email protected] | |
with: | |
android: false | |
dotnet: false | |
haskell: false | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install podman | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y podman | |
- name: Start podman service | |
run: | | |
# Start user podman service for socket mounting | |
systemctl --user start podman.socket | |
- name: Initialize devcontainer environment | |
run: | | |
# Set up git config for initialize.sh | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
# Run initialize script to generate devcontainer.env | |
bash .devcontainer/initialize.sh | |
- name: Build devcontainer | |
run: | | |
cd .devcontainer | |
USER_UID=$(id -u) | |
USER_GID=$(id -g) | |
podman build -f Containerfile \ | |
--build-arg USER_UID=$USER_UID \ | |
--build-arg USER_GID=$USER_GID \ | |
-t devcontainer:latest .. | |
- name: Start devcontainer | |
run: | | |
podman run -d \ | |
--name devcontainer-test \ | |
--network=host \ | |
--userns=keep-id \ | |
--env-file=.devcontainer/devcontainer.env \ | |
--cap-add=SYS_ADMIN \ | |
--security-opt=label=disable \ | |
--privileged \ | |
-v $PWD:/workspaces/caching \ | |
-v ${XDG_RUNTIME_DIR}/podman/podman.sock:/var/run/podman.sock:Z \ | |
-e CONTAINER_HOST=unix:///var/run/podman.sock \ | |
devcontainer:latest \ | |
sleep infinity | |
- name: Wait for container to be ready | |
run: | | |
sleep 5 | |
podman exec devcontainer-test echo "Container is ready" | |
- name: Verify we're running as vscode user | |
run: | | |
# Check that we're running as vscode user by default | |
CURRENT_USER=$(podman exec devcontainer-test whoami) | |
echo "Current user in container: $CURRENT_USER" | |
if [ "$CURRENT_USER" != "vscode" ]; then | |
echo "ERROR: Expected to be vscode user, but got: $CURRENT_USER" | |
exit 1 | |
fi | |
# Also verify user details | |
podman exec devcontainer-test id vscode | |
- name: Verify workspace files and ownership | |
run: | | |
podman exec devcontainer-test ls -la /workspaces/caching | |
podman exec devcontainer-test stat -c "%U %G" /workspaces/caching | |
- name: Verify workspace files are accessible | |
run: | | |
# Test that we can access files as the vscode user (default) | |
podman exec devcontainer-test ls -la /workspaces/caching | |
podman exec devcontainer-test cat /workspaces/caching/README.md | head -5 | |
- name: Lint Squid Helm chart | |
run: | | |
# Run helm lint on the squid chart | |
podman exec devcontainer-test helm lint /workspaces/caching/squid | |
- name: Lint main Containerfile | |
run: | | |
podman exec -w /workspaces/caching devcontainer-test hadolint Containerfile | |
- name: Lint test Containerfile | |
run: | | |
podman exec -w /workspaces/caching devcontainer-test hadolint test.Containerfile | |
- name: Lint devcontainer Containerfile | |
run: | | |
podman exec -w /workspaces/caching devcontainer-test hadolint .devcontainer/Containerfile | |
- name: Run unit tests | |
run: | | |
podman exec -w /workspaces/caching devcontainer-test mage test:unit | |
- name: Deploy Kind environment | |
run: | | |
# Test that deploying our environment in Kind and our Helm chart works | |
podman exec -w /workspaces/caching devcontainer-test mage squidHelm:up | |
- name: Run our test suite (via mirrord) | |
run: | | |
# Run the test suite via mirrord, so we can see detailed output | |
podman exec -w /workspaces/caching devcontainer-test mage test:cluster | |
- name: Retest Kind environment | |
run: | | |
# Test that our deployment is reentrant and that `helm test` works | |
podman exec -w /workspaces/caching devcontainer-test mage all | |
- name: Clean up Kind environment | |
if: always() | |
run: | | |
podman exec -w /workspaces/caching devcontainer-test mage clean | |
podman exec -w /workspaces/caching devcontainer-test kind delete cluster --name caching-ci | |
- name: Cleanup container | |
if: always() | |
run: | | |
podman stop devcontainer-test || true | |
podman rm devcontainer-test || true |