diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4242bdc4..01b85cd5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -111,14 +111,15 @@ jobs: - name: App Tests working-directory: ./app-tests env: + OPAL_IMAGE_TAG: test OPAL_TESTS_POLICY_REPO_DEPLOY_KEY: ${{ secrets.OPAL_TESTS_POLICY_REPO_DEPLOY_KEY }} run: | # Prepare git for using tests policy repo - export POLICY_REPO_SSH_KEY_PATH=$(realpath ./opal-tests-policy-repo-key) - echo "$OPAL_TESTS_POLICY_REPO_DEPLOY_KEY" > $POLICY_REPO_SSH_KEY_PATH - chmod 400 $POLICY_REPO_SSH_KEY_PATH + export OPAL_POLICY_REPO_SSH_KEY_PATH=$(realpath ./opal-tests-policy-repo-key) + echo "$OPAL_TESTS_POLICY_REPO_DEPLOY_KEY" > $OPAL_POLICY_REPO_SSH_KEY_PATH + chmod 400 $OPAL_POLICY_REPO_SSH_KEY_PATH - git config --global core.sshCommand "ssh -i $POLICY_REPO_SSH_KEY_PATH -o IdentitiesOnly=yes" + git config --global core.sshCommand "ssh -i $OPAL_POLICY_REPO_SSH_KEY_PATH -o IdentitiesOnly=yes" git config --global user.name "$GITHUB_ACTOR" git config --global user.email "<>" diff --git a/app-tests/docker-compose-app-tests.yml b/app-tests/docker-compose-app-tests.yml index 589a642d..f158e264 100644 --- a/app-tests/docker-compose-app-tests.yml +++ b/app-tests/docker-compose-app-tests.yml @@ -7,7 +7,7 @@ services: - POSTGRES_PASSWORD=postgres opal_server: - image: permitio/opal-server:test + image: permitio/opal-server:${OPAL_IMAGE_TAG:-latest} deploy: mode: replicated replicas: 2 @@ -34,7 +34,7 @@ services: - broadcast_channel opal_client: - image: permitio/opal-client:test + image: permitio/opal-client:${OPAL_IMAGE_TAG:-latest} deploy: mode: replicated replicas: 2 diff --git a/app-tests/run.sh b/app-tests/run.sh index 62f87d31..edb3bbce 100755 --- a/app-tests/run.sh +++ b/app-tests/run.sh @@ -20,7 +20,8 @@ function generate_opal_keys { sleep 2; OPAL_CLIENT_TOKEN="$(opal-client obtain-token "$OPAL_AUTH_MASTER_TOKEN" --type client)" OPAL_DATA_SOURCE_TOKEN="$(opal-client obtain-token "$OPAL_AUTH_MASTER_TOKEN" --type datasource)" - pkill opal + # shellcheck disable=SC2009 + ps -ef | grep opal-server | grep -v grep | awk '{print $2}' | xargs kill sleep 5; echo "- Create .env file" @@ -45,14 +46,17 @@ function prepare_policy_repo { git push --set-upstream origin $POLICY_REPO_BRANCH cd - + # That's for the docker-compose to use, set ssh key from "~/.ssh/id_rsa", unless another path/key data was configured export OPAL_POLICY_REPO_SSH_KEY - OPAL_POLICY_REPO_SSH_KEY=$(cat "$POLICY_REPO_SSH_KEY_PATH") + OPAL_POLICY_REPO_SSH_KEY_PATH=${OPAL_POLICY_REPO_SSH_KEY_PATH:-~/.ssh/id_rsa} + OPAL_POLICY_REPO_SSH_KEY=${OPAL_POLICY_REPO_SSH_KEY:$(cat "$OPAL_POLICY_REPO_SSH_KEY_PATH")} } -# Test setup +# Setup generate_opal_keys prepare_policy_repo + function compose { docker compose -f ./docker-compose-app-tests.yml --env-file .env "$@" } @@ -88,6 +92,7 @@ function clean_up { } trap clean_up EXIT +# Bring up OPAL containers compose down --remove-orphans compose up -d sleep 10