Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck committed Nov 9, 2023
1 parent 7473f09 commit 0bdcadf
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 42 deletions.
56 changes: 56 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: E2E test
description: Run E2E tests against the example application

inputs:
working-directory:
description: The current working directory
required: true

env:
SAMPLE_PATH: ${{ inputs.working-directory }}
IMAGE_NAME: ${{ github.event.pull_request.head.sha || github.sha }}
CONTAINER_NAME: ${{ github.event.pull_request.head.sha || github.sha }}
AUTH0_TEST_DOMAIN: ${{ secrets.AUTH0_TEST_DOMAIN }}
AUTH0_TEST_CLIENT_ID: ${{ secrets.AUTH0_TEST_CLIENT_ID }}
AUTH0_TEST_API_IDENTIFIER: ${{ secrets.AUTH0_TEST_API_IDENTIFIER }}

runs:
using: composite

steps:
- name: Replace Auth0 test credentials
shell: bash
env:
AUTH0_CFG: ${{ inputs.working-directory }}/auth_config.json
AUTH0_EXAMPLE_CFG: ${{ inputs.working-directory }}/auth_config.json.example
run: |
sed \
-e "s/{DOMAIN}/$AUTH0_TEST_DOMAIN/g" \
-e "s/{CLIENT_ID}/$AUTH0_TEST_CLIENT_ID/g" \
-e "s/{API_IDENTIFIER}/$AUTH0_TEST_API_IDENTIFIER/g" \
$AUTH0_EXAMPLE_CFG > $AUTH0_CFG
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build pull request
run: |
docker build -t $IMAGE_NAME ./$SAMPLE_PATH
docker run -d -p 4200:4200 --name $CONTAINER_NAME $IMAGE_NAME
- name: Wait for app to be available
run: |
sleep 10
docker run --network host --rm appropriate/curl --retry 8 --retry-connrefused -v localhost:4200
- name: Run tests
run: |
docker create --env "SAMPLE_PORT=4200" --network host --name tester codeceptjs/codeceptjs codeceptjs run-multiple --all --steps
docker cp $(pwd)/lock_login_test.js tester:/tests/lock_login_test.js
docker cp $(pwd)/codecept.conf.js tester:/tests/codecept.conf.js
docker start -i tester
working-directory: scripts
- name: Copy app container logs
run: |
mkdir -p /tmp/out
docker logs $CONTAINER_NAME > /tmp/out/app_logs.log
docker cp tester:/tests/out /tmp/
if: failure()
62 changes: 20 additions & 42 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ jobs:
e2e-sample-01:
name: E2E Test Sample
runs-on: ubuntu-latest
env:
AUTH0_CFG: Sample-01/auth_config.json
AUTH0_EXAMPLE_CFG: Sample-01/auth_config.json.example
SAMPLE_PATH: Sample-01
IMAGE_NAME: ${{ github.event.pull_request.head.sha || github.sha }}
CONTAINER_NAME: ${{ github.event.pull_request.head.sha || github.sha }}
AUTH0_TEST_DOMAIN: ${{ secrets.AUTH0_TEST_DOMAIN }}
AUTH0_TEST_CLIENT_ID: ${{ secrets.AUTH0_TEST_CLIENT_ID }}
AUTH0_TEST_API_IDENTIFIER: ${{ secrets.AUTH0_TEST_API_IDENTIFIER }}

steps:
- name: Checkout code
Expand All @@ -76,38 +67,25 @@ jobs:

- run: git clone https://github.com/auth0-samples/spa-quickstarts-tests scripts

- name: Replace Auth0 test credentials
run: |
sed \
-e "s/{DOMAIN}/$AUTH0_TEST_DOMAIN/g" \
-e "s/{CLIENT_ID}/$AUTH0_TEST_CLIENT_ID/g" \
-e "s/{API_IDENTIFIER}/$AUTH0_TEST_API_IDENTIFIER/g" \
$AUTH0_EXAMPLE_CFG > $AUTH0_CFG
- name: E2E Test Sample
uses: ./.github/actions/test
with:
working-directory: Sample-01

- run: cat $AUTH0_CFG

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build pull request
run: |
docker build -t $IMAGE_NAME ./$SAMPLE_PATH
docker run -d -p 4200:4200 --name $CONTAINER_NAME $IMAGE_NAME
- name: Wait for app to be available
run: |
sleep 10
docker run --network host --rm appropriate/curl --retry 8 --retry-connrefused -v localhost:4200
- name: Run tests
run: |
docker create --env "SAMPLE_PORT=4200" --network host --name tester codeceptjs/codeceptjs codeceptjs run-multiple --all --steps
docker cp $(pwd)/lock_login_test.js tester:/tests/lock_login_test.js
docker cp $(pwd)/codecept.conf.js tester:/tests/codecept.conf.js
docker start -i tester
working-directory: scripts
- name: Copy app container logs
run: |
mkdir -p /tmp/out
docker logs $CONTAINER_NAME > /tmp/out/app_logs.log
docker cp tester:/tests/out /tmp/
if: failure()
e2e-standalone:
name: E2E Test Standalone
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}

- run: git clone https://github.com/auth0-samples/spa-quickstarts-tests scripts

- name: E2E Test Standalone
uses: ./.github/actions/test
with:
working-directory: Standalone

0 comments on commit 0bdcadf

Please sign in to comment.