From 38028f7d0c31b4e6691a4709fc489e3d127c44a9 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 11 Jul 2020 13:17:28 -0500 Subject: [PATCH 1/5] Confirm latest Spigot jar is always downloaded --- start-deployBukkitSpigot | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/start-deployBukkitSpigot b/start-deployBukkitSpigot index 28b07fd3..cb2309e5 100644 --- a/start-deployBukkitSpigot +++ b/start-deployBukkitSpigot @@ -62,8 +62,12 @@ function downloadSpigot { downloadUrl="https://cdn.getbukkit.org/${getbukkitFlavor}/${getbukkitFlavor}-${VANILLA_VERSION}.jar" fi + if [ -f $SERVER ]; then + # tell curl to only download when newer + zarg="-z $SERVER" + fi log "Downloading $match from $downloadUrl ..." - curl -fsSL -o $SERVER "$downloadUrl" + curl -fsSL -o $SERVER $zarg "$downloadUrl" if [[ $? != 0 || $(grep -c "DOCTYPE html" $SERVER) != 0 ]]; then cat < Date: Sat, 11 Jul 2020 13:30:39 -0500 Subject: [PATCH 2/5] Confirm latest Paper jar is always downloaded --- start-deployPaper | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/start-deployPaper b/start-deployPaper index f3d12472..1bc5839e 100644 --- a/start-deployPaper +++ b/start-deployPaper @@ -5,17 +5,18 @@ : ${PAPERBUILD:=latest} export SERVER=paper_server-${VANILLA_VERSION}-${PAPERBUILD}.jar -if [ ! -f "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then - downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/${PAPERBUILD}/download} - log "Downloading Paper $VANILLA_VERSION (build $PAPERBUILD) from $downloadUrl ..." - curl -fsSL -o "$SERVER" "$downloadUrl" - if [ ! -f "$SERVER" ]; then - log "ERROR: failed to download from $downloadUrl (status=$?)" - exit 3 - fi +if [ -f "$SERVER" ] && ! isTrue "$FORCE_REDOWNLOAD"; then + zarg="-z '$SERVER'" fi -# Normalize on Spigot for operations below +downloadUrl=${PAPER_DOWNLOAD_URL:-https://papermc.io/api/v1/paper/${VANILLA_VERSION}/${PAPERBUILD}/download} +log "Downloading Paper $VANILLA_VERSION (build $PAPERBUILD) from $downloadUrl ..." +if ! curl -fsSL -o "$SERVER" $zarg "$downloadUrl"; then + log "ERROR: failed to download from $downloadUrl (status=$?)" + exit 3 +fi + +# Normalize on Spigot for downstream operations export TYPE=SPIGOT export SKIP_LOG4J_CONFIG=true From 367c6cfd92db74f26fc8ee7e410f7a68a9cdf1f1 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 11 Jul 2020 14:09:08 -0500 Subject: [PATCH 3/5] ci: Added testing step to github actions --- .github/workflows/main.yml | 11 +++++++++++ .github/workflows/pr.yml | 11 ++++------- tests/docker-compose.test.yml | 16 ++++++++++++++++ tests/test.sh | 13 +++++++++++++ 4 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 tests/docker-compose.test.yml create mode 100755 tests/test.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 388a5fea..f3673005 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,18 @@ on: - "[0-9]+.[0-9]+.[0-9]+-adopt13" jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: | + tests/test.sh build: + needs: + - test runs-on: ubuntu-latest steps: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 94d19913..16096da7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,15 +5,12 @@ on: branches: [ master ] jobs: - build: + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Build Docker image - uses: docker/build-push-action@v1.1.0 - with: - tag_with_sha: true - cache_froms: itzg/minecraft-server:latest - push: false + - name: Run tests + run: | + tests/test.sh diff --git a/tests/docker-compose.test.yml b/tests/docker-compose.test.yml new file mode 100644 index 00000000..49271b76 --- /dev/null +++ b/tests/docker-compose.test.yml @@ -0,0 +1,16 @@ +version: "3.8" + +services: + sut: + depends_on: + - mc + image: itzg/mc-monitor:0.6.0 + command: status --host mc --retry-interval 1s --retry-limit 120 + mc: + build: + context: .. + cache_from: + - itzg/minecraft-server:latest + environment: + EULA: "TRUE" + diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 00000000..2f11b894 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +cd $(dirname $0) + +failed=false +args="-f docker-compose.test.yml" +docker-compose $args run sut || failed=true; docker-compose $args logs mc +docker-compose $args down -v + +if $failed; then + exit 1 +fi + From 3c9df035848f34b6c980c6f156dc71187a521562 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 11 Jul 2020 14:13:28 -0500 Subject: [PATCH 4/5] ci: Only output server logs when failed --- tests/test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test.sh b/tests/test.sh index 2f11b894..7da85273 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -4,7 +4,8 @@ cd $(dirname $0) failed=false args="-f docker-compose.test.yml" -docker-compose $args run sut || failed=true; docker-compose $args logs mc +docker-compose $args run sut || failed=true +$failed && docker-compose $args logs mc docker-compose $args down -v if $failed; then From 90183ae8236530b7c9cd6ef65bdeaa9cf532188b Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 11 Jul 2020 14:26:47 -0500 Subject: [PATCH 5/5] ci: Don't restart failed container during test --- tests/docker-compose.test.yml | 1 + tests/test.sh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/tests/docker-compose.test.yml b/tests/docker-compose.test.yml index 49271b76..ed96ba50 100644 --- a/tests/docker-compose.test.yml +++ b/tests/docker-compose.test.yml @@ -7,6 +7,7 @@ services: image: itzg/mc-monitor:0.6.0 command: status --host mc --retry-interval 1s --retry-limit 120 mc: + restart: "no" build: context: .. cache_from: diff --git a/tests/test.sh b/tests/test.sh index 7da85273..376aed99 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -5,6 +5,9 @@ cd $(dirname $0) failed=false args="-f docker-compose.test.yml" docker-compose $args run sut || failed=true +echo " +Result: failed=$failed" + $failed && docker-compose $args logs mc docker-compose $args down -v