diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..225726c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: Build + +on: + push: + branches: + - master + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +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: + - uses: actions/checkout@v2 + + - name: Build and push Docker images + uses: docker/build-push-action@v1.1.0 + with: + repository: itzg/minecraft-bedrock-server + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASSWORD }} + tag_with_ref: true + tag_with_sha: false + cache_froms: itzg/minecraft-bedrock-server:latest + add_git_labels: true + push: false diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..777eb7e --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,16 @@ +name: Validate PR + +on: + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: | + tests/test.sh diff --git a/tests/docker-compose.defaults.test.yml b/tests/docker-compose.defaults.test.yml new file mode 100644 index 0000000..a2417dd --- /dev/null +++ b/tests/docker-compose.defaults.test.yml @@ -0,0 +1,14 @@ +version: "3.8" + +services: + sut: + depends_on: + - mc + image: itzg/mc-monitor:0.6.0 + command: status-bedrock --host mc --retry-interval 1s --retry-limit 60 + mc: + build: + context: .. + environment: + EULA: "TRUE" + diff --git a/tests/docker-compose.versioned.test.yml b/tests/docker-compose.versioned.test.yml new file mode 100644 index 0000000..7ab35d6 --- /dev/null +++ b/tests/docker-compose.versioned.test.yml @@ -0,0 +1,21 @@ +version: "3.8" + +services: + sut: + depends_on: + - mc + image: itzg/mc-monitor:0.6.0 + command: status-bedrock --host mc --retry-interval 1s --retry-limit 90 + mc: + build: + context: .. + environment: + EULA: "TRUE" + VERSION: "${BDS_VERSION}" + volumes: + - mc:/data + +volumes: + mc: + external: + name: mc-shared diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..db995c9 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Args: +# - compose project +# - test description +runTest() { + composeArgs="-f docker-compose.$1.test.yml -p $1" + failed=false + docker-compose ${composeArgs} run sut || failed=true + $failed && docker-compose ${composeArgs} logs + docker-compose ${composeArgs} down -v + if $failed; then + echo "Test failed using compose project $1: $2" + exit 1 + fi +} + +cd $(dirname $0) + +runTest defaults "using defaults" + +docker volume create mc-shared +trap "docker volume rm mc-shared" EXIT + +export BDS_VERSION=1.14 +runTest versioned "with VERSION=1.14" +export BDS_VERSION=1.16 +runTest versioned "upgrading to VERSION=1.16"