Skip to content
Open
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
32 changes: 31 additions & 1 deletion .github/workflows/run-build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,39 @@ jobs:
uses: ./.github/workflows/define-build-linux-image.yaml
secrets: inherit

push:
test-linux:
needs: [build-linux]
runs-on: [self-hosted, linux]
steps:
- name: lowercase github.repository
run: |
echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV}
- name: Download cached docker image
run: |
curl -X GET http://192.168.0.11:25000/attachments/gha-runner/1/image_ubuntu.tar -o /tmp/image_ubuntu.tar
- name: Load image
run: |
docker load --input /tmp/image_ubuntu.tar
- name: Run container with tests
if: failure()
run: |
docker run --name gha-runner --runtime sysbox-runc -e TEST_ONLY_RUN=yes -e REPO=Ableytner/docker-github-actions-runner -e TOKEN=XXXX ${{ env.IMAGE_NAME }}:latest-ubuntu
if [[ $? -ne 0 ]]; then
echo "tests failed!"
exit 1
fi
- name: Print out server container logs
if: failure()
run: |
docker logs gha-runner
- name: Stop and delete server container
if: always()
run: |
docker rm -f gha-runner

push:
needs: [test-linux]
runs-on: [self-hosted, linux]
permissions:
contents: read
packages: write
Expand Down
5 changes: 5 additions & 0 deletions linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ARG RUNNER_VERSION="2.330.0" \
DOCKER_VERSION="29.1.3" \
BUILDX_VERSION="0.30.1" \
COMPOSE_VERSION="2.40.3" \
SYSBOX_VERSION="0.6.7" \
ARCH="amd64" \
INSTRUCTION_SET="x64"

Expand Down Expand Up @@ -41,6 +42,9 @@ RUN apt-get update \
unzip \
wget

# install systemd alternative
RUN wget https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl3.py -O /usr/local/bin/systemctl

# install gh cli
RUN curl -L -H "Accept: application/vnd.github+json" https://api.github.com/repos/cli/cli/releases/latest \
| jq -r '.tag_name' \
Expand All @@ -63,6 +67,7 @@ RUN mkdir -p /home/runner/tmp \
&& curl -L ${BASE_URL}/docker-ce-cli_${DOCKER_VERSION}-1~ubuntu.22.04~jammy_${ARCH}.deb -o ./docker-ce-cli.deb \
&& curl -L ${BASE_URL}/docker-buildx-plugin_${BUILDX_VERSION}-1~ubuntu.22.04~jammy_${ARCH}.deb -o ./docker-buildx-plugin.deb \
&& curl -L ${BASE_URL}/docker-compose-plugin_${COMPOSE_VERSION}-1~ubuntu.22.04~jammy_${ARCH}.deb -o ./docker-compose-plugin.deb \
&& curl -L https://downloads.nestybox.com/sysbox/releases/v${SYSBOX_VERSION}/sysbox-ce_${SYSBOX_VERSION}-0.linux_amd64.deb -o ./sysbox.deb \
&& apt-get install -y $(ls *.deb | sed -e "s/^/.\//") \
&& rm $(ls *.deb) \
&& sed -i 's/ulimit -Hn/# ulimit -Hn/g' /etc/init.d/docker \
Expand Down
9 changes: 8 additions & 1 deletion linux/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ if [[ "$(service docker status)" == *"Docker is running"* ]]; then
echo "Done!"
else
echo "Docker didn't start, status is:"
echo $(service docker status)
service docker status
exit 1
fi

# [RUN TESTS]
if [[ -v TEST_ONLY_RUN ]]; then
/run-tests.sh
echo "all tests succeeded!"
exit 0
fi

# [START]

echo "Registering runner..."
Expand Down
11 changes: 11 additions & 0 deletions linux/scripts/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -o nounset # exit if unset variable is used
set -e # exit on command error

docker container ls
container_id=$(docker run -d hello-world)
echo $container_id
docker logs $container_id
docker rm $container_id
docker container ls