Merge pull request #402 from stevenc987/main #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Integration Tests | |
#Note: This workflow requires OP_CONNECT_URL, OP_CONNECT_TOKEN if you want to use one pass. otherwise all must be in secrets | |
#required variables | |
#TESTIM_PROJECT | |
#TESTIM_USER | |
#Reqiured secrets | |
#TESTIM_TOKEN | |
#OIDC_URL | |
#OIDC_CLIENT | |
#OIDC_CLIENT_SECRET | |
#AUTH_API_URL | |
#PAY_API_URL | |
#TEST_USER | |
#TEST_PASSWORD | |
#CANADA_POST_API_KEY | |
#AUTH_URL | |
#AUTH_REALM | |
#REGISTRY_HOME_URL | |
#NUXT_CLIENT_ID | |
#COLIN_API_URL | |
#COLIN_CLIENT_ID | |
#COLIN_CLIENT_SECRET | |
#DASHBOARD_URL | |
#NOTIFY_API_URL | |
#REPORT_API_URL | |
#PAYMENT_PORTAL_URL | |
#May be needed in future | |
#FIREBASE_API_KEY | |
#FIREBASE_MESSAGING_SENDER_ID | |
#FIREBASE_APP_ID | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
target: | |
description: "Environment to use (OP)" | |
required: true | |
default: "DEV" | |
type: choice | |
options: | |
- DEV | |
- TEST | |
- SANDBOX | |
- PROD | |
jobs: | |
integration_tests: | |
env: | |
OP_CONNECT_HOST: ${{ secrets.OP_CONNECT_URL }} | |
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }} | |
APP_ENV: ${{ github.event.inputs.target }} | |
OIDC_URL: ${{ secrets.OIDC_URL }} | |
OIDC_CLIENT: ${{ secrets.OIDC_CLIENT }} | |
OIDC_CLIENT_SECRET: ${{ secrets.OIDC_CLIENT_SECRET }} | |
AUTH_API_URL: ${{ secrets.AUTH_API_URL }} | |
PAY_API_URL: ${{ secrets.PAY_API_URL }} | |
TEST_USER: ${{secrets.TEST_USER}} | |
TEST_PASSWORD: ${{secrets.TEST_PASSWORD}} | |
CANADA_POST_API_KEY: ${{secrets.CANADA_POST_API_KEY}} | |
AUTH_URL: ${{secrets.AUTH_URL}} | |
AUTH_REALM: ${{secrets.AUTH_REALM}} | |
REGISTRY_HOME_URL: ${{secrets.REGISTRY_HOME_URL}} | |
NUXT_CLIENT_ID: ${{secrets.NUXT_CLIENT_ID}} | |
TESTIM_TOKEN: ${{secrets.TESTIM_TOKEN}} | |
TESTIM_PROJECT: ${{vars.TESTIM_PROJECT}} | |
TESTIM_USER: ${{vars.TESTIM_USER}} | |
COLIN_API_URL: ${{secrets.COLIN_API_URL}} | |
COLIN_CLIENT_ID: ${{secrets.COLIN_CLIENT_ID}} | |
COLIN_CLIENT_SECRET: ${{secrets.COLIN_CLIENT_SECRET}} | |
DASHBOARD_URL: ${{secrets.DASHBOARD_URL}} | |
NOTIFY_API_URL: ${{secrets.NOTIFY_API_URL}} | |
REPORT_API_URL: ${{secrets.REPORT_API_URL}} | |
PAYMENT_PORTAL_URL: ${{secrets.PAYMENT_PORTAL_URL}} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
# Install 1password cli tool | |
- name: Install 1password cli tool | |
uses: bcgov/bcregistry-sre/.github/actions/install-1pass@main | |
- name: terraform | |
id: terraform | |
env: | |
TERRAFORM_VERSION: "1.8.0" | |
run: | | |
export WD=`pwd` | |
cd /tmp | |
wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip | |
unzip -o /tmp/terraform_${TERRAFORM_VERSION}_linux_amd64.zip | |
rm -rf /tmp/terraform_${TERRAFORM_VERSION}_linux_amd64.zip | |
chmod +x terraform | |
alias terraform='/tmp/terraform' | |
cd $WD/api | |
docker build . -t regapi:latest | |
cd $WD/web/site | |
docker build . -t regweb:latest | |
cd $WD/test/terraform | |
mkdir _tmp | |
chmod -R 777 _tmp | |
echo "127.0.0.1 ar.example.demo" | sudo tee -a /etc/hosts | |
echo "127.0.0.1 ar.example.demo" | sudo tee -a /etc/hosts | |
terraform init | |
chmod ugo+x ../get_var.py | |
get_var(){ | |
export OUTPUT=`../get_var.py $1 $2 $3` | |
echo "::add-mask::$OUTPUT" >> /dev/null | |
echo $OUTPUT | |
} | |
#create terraform vars file | |
# echo "firebase_api_key=\"${{ secrets.FIREBASE_API_KEY }}\"" > terraform.tfvars | |
# echo "firebase_messaging_sender_id=\"${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}\"" >> terraform.tfvars | |
# echo "firebase_app_id=\"${{ secrets.FIREBASE_APP_ID }}\"" >> terraform.tfvars | |
echo "auth_api_url=\"`get_var "op://API/$APP_ENV/auth-api/AUTH_API_URL" "AUTH_API_URL"`\"" >> terraform.tfvars | |
echo "pay_api_url=\"`get_var "op://API/$APP_ENV/pay-api/PAY_API_URL" "PAY_API_URL"`\"" >> terraform.tfvars | |
echo "oidc_issuer=\"`get_var "op://keycloak/$APP_ENV/jwt-base/JWT_OIDC_ISSUER" "OIDC_URL"`\"" >> terraform.tfvars | |
echo "oidc_well_known_config=\"`get_var "op://keycloak/$APP_ENV/jwt-base/JWT_OIDC_WELL_KNOWN_CONFIG" "OIDC_URL" "/.well-known/openid-configuration"`\"" >> terraform.tfvars | |
echo "auth_svc_url=\"`get_var "op://keycloak/$APP_ENV/base/KEYCLOAK_AUTH_TOKEN_URL" "OIDC_URL" "/protocol/openid-connect/token"`\"" >> terraform.tfvars | |
echo "auth_client_id=\"`get_var "op://keycloak/$APP_ENV/entity-service-account/ENTITY_SERVICE_ACCOUNT_CLIENT_ID" "OIDC_CLIENT"`\"" >> terraform.tfvars | |
echo "auth_client_secret=\"`get_var "op://keycloak/$APP_ENV/entity-service-account/ENTITY_SERVICE_ACCOUNT_CLIENT_SECRET" "OIDC_CLIENT_SECRET"`\"" >> terraform.tfvars | |
#echo "canada_post_api_key=\"`get_var "op://API/$APP_ENV/auth-api/DONT_KNOW_LOOKUP" "CANADA_POST_API_KEY"`\"" >> terraform.tfvars | |
echo "auth_url=\"`get_var "op://keycloak/$APP_ENV/base/KEYCLOAK_AUTH_BASE_URL" "AUTH_URL"`\"" >> terraform.tfvars | |
echo "auth_realm=\"`get_var "op://keycloak/$APP_ENV/base/KEYCLOAK_REALMNAME" "AUTH_REALM"`\"" >> terraform.tfvars | |
echo "registry_home_url=\"`get_var "op://web-url/$APP_ENV/registry/REGISTRY_HOME_URL" "REGISTRY_HOME_URL"`\"" >> terraform.tfvars | |
echo "nuxt_client_id=\"`get_var "op://keycloak/$APP_ENV/bar-web/UI_KEYCLOAK_RESOURCE_NAME" "NUXT_CLIENT_ID"`\"" >> terraform.tfvars | |
#May 22 | |
echo "hostname = \"http://127.0.0.1\"" >> terraform.tfvars | |
echo "colin_api_url = \"`get_var "op://API/$APP_ENV/colin-api-entity/COLIN_API_URL" "COLIN_API_URL"`\"" >> terraform.tfvars | |
echo "colin_client_id = \"`get_var "op://keycloak/$APP_ENV/entity-service-account/ENTITY_SERVICE_ACCOUNT_CLIENT_ID" "COLIN_CLIENT_ID"`\"" >> terraform.tfvars | |
echo "colin_client_secret = \"`get_var "op://keycloak/$APP_ENV/entity-service-account/ENTITY_SERVICE_ACCOUNT_CLIENT_SECRET" "COLIN_CLIENT_SECRET"`\"" >> terraform.tfvars | |
echo "dashboard_url = \"`get_var "op://web-url/$APP_ENV/registry/REGISTRY_HOME_URL" "DASHBOARD_URL"`\"" >> terraform.tfvars | |
echo "notify_api_url = \"`get_var "op://API/$APP_ENV/notify-api/NOTIFY_API_URL" "NOTIFY_API_URL"`\"" >> terraform.tfvars | |
#May 28 | |
echo "report_api_url = \"`get_var "op://API/$APP_ENV/report-api/REPORT_API_URL" "REPORT_API_URL"`\"" >> terraform.tfvars | |
#June 19 | |
echo "paymentPortalUrl = \"`get_var "op://web-url/$APP_ENV/pay/PAYMENT_PORTAL_URL" "PAYMENT_PORTAL_URL"`\"" >> terraform.tfvars | |
#end terraform vars file | |
terraform apply -var hostRootPath=`pwd`/_tmp -var init=true -auto-approve | |
cd ../testim | |
echo "{" > ./config2.json | |
echo "\"username\": \"${{secrets.TEST_USER}}\"," >> ./config2.json | |
echo "\"password\": \"${{secrets.TEST_PASSWORD}}\"" >> ./config2.json | |
echo "}" >> ./config2.json | |
#for later steps | |
echo "TEST_STEP_USER=`get_var "op://API/$APP_ENV/auth-api/DONT_KNOW_LOOKUP" "TEST_USER"`" >> "$GITHUB_OUTPUT" | |
echo "TEST_STEP_PASSWORD=`get_var "op://API/$APP_ENV/auth-api/DONT_KNOW_LOOKUP" "TEST_PASSWORD"`" >> "$GITHUB_OUTPUT" | |
echo "TEST_STEP_TESTIM_TOKEN=`get_var "op://API/$APP_ENV/auth-api/DONT_KNOW_LOOKUP" "TESTIM_TOKEN"`" >> "$GITHUB_OUTPUT" | |
echo "TEST_STEP_TESTIM_PROJECT=`get_var "op://API/$APP_ENV/auth-api/DONT_KNOW_LOOKUP" "TESTIM_PROJECT"`" >> "$GITHUB_OUTPUT" | |
echo "TEST_STEP_TESTIM_USER=`get_var "op://API/$APP_ENV/auth-api/DONT_KNOW_LOOKUP" "TESTIM_USER"`" >> "$GITHUB_OUTPUT" | |
- name: testim install | |
uses: coactions/setup-xvfb@v1 | |
with: | |
run: npm i -g @testim/testim-cli | |
working-directory: ./test/testim #optional | |
- name: test | |
uses: coactions/setup-xvfb@v1 | |
env: | |
TIM_TOKEN: ${{ steps.terraform.outputs.TEST_STEP_TESTIM_TOKEN }} | |
TIM_USER: ${{ steps.terraform.outputs.TEST_STEP_TESTIM_USER }} | |
TIM_PROJECT: ${{ steps.terraform.outputs.TEST_STEP_TESTIM_PROJECT }} | |
with: | |
working-directory: ./test/testim #optional | |
run: | | |
testim --token ${{secrets.TESTIM_TOKEN}} --project ${{vars.TESTIM_PROJECT}} --use-local-chrome-driver --user ${{vars.TESTIM_USER}} --suite "Annual Report Integration" --base-url http://localhost:3000 --params-file ./config2.json | |
# - name: Debug terraform file | |
# if: always() | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: terraform.tfvars | |
# path: test/terraform/terraform.tfvars | |
- name: Debug config json file | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: config2.json | |
path: test/testim/config2.json |