Skip to content

Commit

Permalink
Small changes for running locally
Browse files Browse the repository at this point in the history
  • Loading branch information
roekatz committed Aug 15, 2024
1 parent 9783603 commit d6847da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ jobs:
- name: App Tests
working-directory: ./app-tests
env:
OPAL_TESTS_POLICY_REPO_DEPLOY_KEY: ${{ secrets.OPAL_TESTS_POLICY_REPO_DEPLOY_KEY }}
OPAL_IMAGE_TAG: test
OPAL_POLICY_REPO_SSH_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 "<>"
Expand Down
4 changes: 2 additions & 2 deletions app-tests/docker-compose-app-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 8 additions & 3 deletions app-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 "$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 "$@"
}
Expand Down Expand Up @@ -88,6 +92,7 @@ function clean_up {
}
trap clean_up EXIT

# Bring up OPAL containers
compose down --remove-orphans
compose up -d
sleep 10
Expand Down

0 comments on commit d6847da

Please sign in to comment.