Skip to content

Commit

Permalink
headless
Browse files Browse the repository at this point in the history
  • Loading branch information
sabrehagen committed Aug 24, 2023
1 parent 5f491d7 commit 2530f9f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ jobs:
tags: ghcr.io/${{ env.REPOSITORY_OWNER }}/desktop-environment:latest

- name: Run desktop environment tests
run: |
./docker/scripts/test-start.sh
./docker/scripts/test-stop.sh
run: ./docker/scripts/test-start.sh
env:
DESKTOP_ENVIRONMENT_REGISTRY: ghcr.io/${{ env.REPOSITORY_OWNER }}
continue-on-error: true

- name: Run desktop environment
run: ./docker/scripts/test-start.sh
- name: Start headless desktop environment
run: ./docker/scripts/headless.sh
env:
DESKTOP_ENVIRONMENT_REGISTRY: ghcr.io/${{ env.REPOSITORY_OWNER }}

Expand Down
9 changes: 7 additions & 2 deletions docker/scripts/test-start.sh → docker/scripts/headless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ eval "$($REPO_ROOT/docker/scripts/environment.sh)"
docker network create $DESKTOP_ENVIRONMENT_DOCKER_NETWORK

# Set the desktop environment test container name
DESKTOP_ENVIRONMENT_CONTAINER_NAME=${DESKTOP_ENVIRONMENT_CONTAINER_IMAGE}-test-$(date +%s)
DESKTOP_ENVIRONMENT_CONTAINER_NAME=${DESKTOP_ENVIRONMENT_CONTAINER_IMAGE}-headless

# Start the desktop environment test container
docker run \
--detach \
--expose 8080 \
--name $DESKTOP_ENVIRONMENT_CONTAINER_NAME \
--rm \
$DESKTOP_ENVIRONMENT_REGISTRY/$DESKTOP_ENVIRONMENT_CONTAINER_IMAGE \
sleep infinity

# Wait until the desktop environment test container is running before proceeding
timeout 10 sh -c "until docker inspect $DESKTOP_ENVIRONMENT_CONTAINER_NAME | grep Status | grep -m 1 running >/dev/null; do sleep 1; done"

# Start the desktop environment inside the container
$REPO_ROOT/docker/scripts/exec.sh /home/$DESKTOP_ENVIRONMENT_USER/.config/scripts/startup.sh
20 changes: 17 additions & 3 deletions docker/scripts/test-stop.sh → docker/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ REPO_ROOT=$(dirname $(readlink -f $0))/../..
# Export desktop environment shell configuration
eval "$($REPO_ROOT/docker/scripts/environment.sh)"

# Ensure the desktop environment test network exists
docker network create $DESKTOP_ENVIRONMENT_DOCKER_NETWORK

# Set the desktop environment test container name
DESKTOP_ENVIRONMENT_CONTAINER_NAME=${DESKTOP_ENVIRONMENT_CONTAINER_IMAGE}-test-$(date +%s)

# Start the desktop environment test container
docker run \
--detach \
--name $DESKTOP_ENVIRONMENT_CONTAINER_NAME \
--rm \
$DESKTOP_ENVIRONMENT_REGISTRY/$DESKTOP_ENVIRONMENT_CONTAINER_IMAGE \
sleep infinity

# Wait until the desktop environment test container is running before proceeding
timeout 10 sh -c "until docker inspect $DESKTOP_ENVIRONMENT_CONTAINER_NAME | grep Status | grep -m 1 running >/dev/null; do sleep 1; done"

# Remove desktop environment test container
docker rm -f $DESKTOP_ENVIRONMENT_CONTAINER_NAME

# Check desktop environment container started successfully
TEST_RESULT=$?

# Remove desktop environment test container
docker rm -f $DESKTOP_ENVIRONMENT_CONTAINER_NAME

# Exit with test result exit code
exit $TEST_RESULT

0 comments on commit 2530f9f

Please sign in to comment.