diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 378accc..b01e351 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,53 +1,57 @@ name: Test on: # Run CI on all pushes to the master and release/** branches, and on all new # pull requests, and on all pushes to pull requests (even if a pull request # is not against master). push: branches: - "master" - "releases/**" pull_request: env: DOCKER_COMPOSE_VERSION: 1.24.1 defaults: run: shell: bash jobs: - test: + unit-test: + runs-on: ubuntu-18.04 + name: "unit tests" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Unit Tests + working-directory: install + run: find ./ -type f -name "*-test.sh" -exec "./{}" \; + + integration-test: runs-on: ubuntu-18.04 name: "test" steps: - name: Pin docker-compose run: | sudo rm /usr/local/bin/docker-compose curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose chmod +x docker-compose sudo mv docker-compose /usr/local/bin - name: Checkout uses: actions/checkout@v2 - name: Integration Test run: | echo "Testing initial install" ./install.sh ./test.sh echo "Testing in-place upgrade" # Also test plugin installation here echo "sentry-auth-oidc" >> sentry/requirements.txt ./install.sh --minimize-downtime ./test.sh - - name: Unit Tests - working-directory: install - run: | - ./create-docker-volumes-test.sh - ./relay-credentials-test.sh - ./geoip-test.sh - - name: Inspect failure if: failure() run: | docker-compose ps docker-compose logs diff --git a/install/_test_setup.sh b/install/_test_setup.sh index e00d8d6..6fdf29e 100644 --- a/install/_test_setup.sh +++ b/install/_test_setup.sh @@ -1,52 +1,52 @@ set -euo pipefail source "$(dirname $0)/_lib.sh" rm -rf /tmp/sentry-onpremise-test-sandbox.* _SANDBOX="$(mktemp -d /tmp/sentry-onpremise-test-sandbox.XXX)" report_success() { echo "$(basename $0) - Success 👍" } teardown() { test "${DEBUG:-}" || rm -rf "$_SANDBOX" } setup() { cd .. # Clone the local repo into a temp dir. FWIW `git clone --local` breaks for # me because it depends on hard-linking, which doesn't work across devices, # and I happen to have my workspace and /tmp on separate devices. - git clone --depth=1 "file://$(pwd)" "$_SANDBOX" + git -c advice.detachedHead=false clone --depth=1 "file://$(pwd)" "$_SANDBOX" # Now propagate any local changes from the working copy to the sandbox. This # provides a pretty nice dev experience: edit the files in the working copy, # then run `DEBUG=1 some-test.sh` to leave the sandbox up for interactive # dev/debugging. git status --porcelain | while read line; do # $line here is something like `M some-script.sh`. local filepath="$(cut -f2 -d' ' <(echo $line))" local filestatus="$(cut -f1 -d' ' <(echo $line))" case $filestatus in D) rm "$_SANDBOX/$filepath" ;; A | M | AM | ??) ln -sf "$(realpath $filepath)" "$_SANDBOX/$filepath" ;; **) echo "Wuh? $line" exit 77 ;; esac done cd "$_SANDBOX/install" trap teardown EXIT } setup