Skip to content
This repository has been archived by the owner on Feb 21, 2025. It is now read-only.

Commit

Permalink
refactor test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed Feb 3, 2025
1 parent 396aeda commit 83eda55
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 35 deletions.
44 changes: 17 additions & 27 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,32 @@ jobs:
fail-fast: false
matrix:
variant:
- 'debian:buster'
- 'debian:bullseye'
- 'ubuntu:20.04'
- 'ubuntu:22.04'
- 'ubuntu:23.04'
- debian:bullseye
- debian:bookworm
- ubuntu:20.04
- ubuntu:22.04
- ubuntu:24.04
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Create Dockerfile
run: |
mkdir -p test-install
cp install.sh ./test-install/
cat > ./test-install/Dockerfile <<EOL
FROM ${{ matrix.variant }}
COPY install.sh /install.sh
ENV CSGOSL_VERSION=dev
ENV CSGOSL_DOWNLOAD_URL=https://raw.githubusercontent.com/crazy-max/csgo-server-launcher/master
RUN /install.sh
EOL
-
name: Test
uses: docker/build-push-action@v4
uses: docker/bake-action@v6
with:
context: ./test-install
outputs: type=cacheonly
targets: test-install
env:
TEST_BASE_IMAGE: ${{ matrix.variant }}

docker:
runs-on: ubuntu-22.04
steps:
-
name: Free up disk space
run: |
#sudo du -h -S / | sort -rh
sudo rm -rf /opt/google/chrome /opt/microsoft/msedge /usr/local/julia* /usr/share/dotnet /opt/hostedtoolcache /usr/local/lib/android/sdk
name: Free disk space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
-
name: Build
uses: docker/bake-action@v6
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# syntax=docker/dockerfile:1

FROM debian:bullseye-slim

RUN dpkg --add-architecture i386 \
Expand Down
13 changes: 13 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ target "image-local" {
inherits = ["image"]
output = ["type=docker"]
}

variable "TEST_BASE_IMAGE" {
default = null
}

target "test-install" {
dockerfile = "test.Dockerfile"
target = "install"
args = {
BASE_IMAGE = TEST_BASE_IMAGE
}
output = ["type=cacheonly"]
}
34 changes: 26 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fi

: "${CSGOSL_VERSION=v1.17.0}"
: "${CSGOSL_DOWNLOAD_URL=https://github.com/crazy-max/csgo-server-launcher/releases/download/$CSGOSL_VERSION}"
: "${CSGOSL_BASE_DIR=}"

### Vars
version=$CSGOSL_VERSION
Expand All @@ -76,11 +77,20 @@ echo ""
echo "Starting CSGO Server Launcher install (${version})..."
echo ""

echo "Downloading CSGO Server Launcher script..."
if ! curl -sSLk ${downloadUrl}/csgo-server-launcher.sh -o ${scriptPath}; then
echo "ERROR: Cannot download CSGO Server Launcher script..."
exit 1
if [ -n "$CSGOSL_BASE_DIR" ]; then
echo "Copying CSGO Server Launcher script..."
if ! cp -f "$CSGOSL_BASE_DIR/csgo-server-launcher.sh" "$scriptPath"; then
echo "ERROR: Cannot copy CSGO Server Launcher script..."
exit 1
fi
else
echo "Downloading CSGO Server Launcher script..."
if ! curl -sSLk "${downloadUrl}/csgo-server-launcher.sh" -o ${scriptPath}; then
echo "ERROR: Cannot download CSGO Server Launcher script..."
exit 1
fi
fi

if ! chmod +x ${scriptPath}; then
echo "ERROR: Cannot chmod CSGO Server Launcher script..."
exit 1
Expand All @@ -92,13 +102,21 @@ if ! update-rc.d csgo-server-launcher defaults >/dev/null; then
exit 1
fi

echo "Downloading CSGO Server Launcher configuration..."
mkdir -p /etc/csgo-server-launcher/
if [ ! -f $confPath ]; then
if ! curl -sSLk ${downloadUrl}/csgo-server-launcher.conf -o ${confPath}; then
echo "ERROR: Cannot download CSGO Server Launcher configuration..."
if [ -n "$CSGOSL_BASE_DIR" ]; then
echo "Copying CSGO Server Launcher configuration..."
if ! cp -f "$CSGOSL_BASE_DIR/csgo-server-launcher.conf" "$confPath"; then
echo "ERROR: Cannot copy CSGO Server Launcher configuration..."
exit 1
fi
else
echo "Downloading CSGO Server Launcher configuration..."
if [ ! -f $confPath ]; then
if ! curl -sSLk "${downloadUrl}/csgo-server-launcher.conf" -o ${confPath}; then
echo "ERROR: Cannot download CSGO Server Launcher configuration..."
exit 1
fi
fi
fi

echo "Checking $user user exists..."
Expand Down
10 changes: 10 additions & 0 deletions test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# syntax=docker/dockerfile:1

ARG BASE_IMAGE=debian:bookworm-slim

FROM $BASE_IMAGE AS install
COPY install.sh /csgosl/install.sh
COPY csgo-server-launcher.* /csgosl/
ENV CSGOSL_VERSION=dev
ENV CSGOSL_BASE_DIR=/csgosl
RUN /csgosl/install.sh

0 comments on commit 83eda55

Please sign in to comment.