Skip to content

Commit

Permalink
Merge branch 'master' into chore/remove-circle
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck authored Nov 9, 2023
2 parents 388a76b + 8cb01c3 commit 02a5001
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build application
description: Build the example application

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

runs:
using: composite

steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
shell: bash
run: npm ci
working-directory: ${{ inputs.working-directory }}

- 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: Build
shell: bash
run: npm run build
working-directory: ${{ inputs.working-directory }}

- name: Tests
shell: bash
run: npm run test:ci
working-directory: ${{ inputs.working-directory }}
76 changes: 76 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: E2E test
description: Run E2E tests against the example application

inputs:
working-directory:
description: The current working directory
required: true
domain:
description: The Auth0 domain to use
required: true
client-id:
description: The Auth0 client id to use
required: true
api-identifier:
description: The Auth0 API identifier to use
required: true

runs:
using: composite

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: auth0-samples/spa-quickstarts-tests
path: scripts

- 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
AUTH0_TEST_DOMAIN: ${{ inputs.domain }}
AUTH0_TEST_CLIENT_ID: ${{ inputs.client-id }}
AUTH0_TEST_API_IDENTIFIER: ${{ inputs.api-identifier }}
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
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 }}
shell: bash
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
shell: bash
run: |
sleep 10
docker run --network host --rm appropriate/curl --retry 8 --retry-connrefused -v localhost:4200
- name: Run tests
shell: bash
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
env:
CONTAINER_NAME: ${{ github.event.pull_request.head.sha || github.sha }}
shell: bash
run: |
mkdir -p /tmp/out
docker logs $CONTAINER_NAME > /tmp/out/app_logs.log
docker cp tester:/tests/out /tmp/
if: failure()
70 changes: 70 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: E2E Test

on:
merge_group:
workflow_dispatch:
pull_request_target:
types:
- opened
- synchronize
push:
branches:
- master

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

env:
NODE_VERSION: 18
CACHE_KEY: '${{ github.ref }}-${{ github.run_id }}-${{ github.run_attempt }}'

jobs:
authorize:
name: Authorize
environment: ${{ github.actor != 'dependabot[bot]' && github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true

sample-01:
needs: authorize
name: E2E Test Sample
runs-on: ubuntu-latest

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

- name: E2E Test Sample
uses: ./.github/actions/test
with:
working-directory: Sample-01
domain: ${{ secrets.AUTH0_TEST_DOMAIN }}
client-id: ${{ secrets.AUTH0_TEST_CLIENT_ID }}
api-identifier: ${{ secrets.AUTH0_TEST_API_IDENTIFIER }}

standalone:
needs: authorize
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 }}

- name: E2E Test Standalone
uses: ./.github/actions/test
with:
working-directory: Standalone
domain: ${{ secrets.AUTH0_TEST_DOMAIN }}
client-id: ${{ secrets.AUTH0_TEST_CLIENT_ID }}
api-identifier: ${{ secrets.AUTH0_TEST_API_IDENTIFIER }}

52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and Test

on:
merge_group:
workflow_dispatch:
pull_request:
branches:
- master
push:
branches:
- master

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

env:
NODE_VERSION: 18
CACHE_KEY: '${{ github.ref }}-${{ github.run_id }}-${{ github.run_attempt }}'

jobs:
sample-01:
name: Build and Unit Test Sample
runs-on: ubuntu-latest

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

- name: Build Sample
uses: ./.github/actions/build
with:
working-directory: Sample-01
standalone:
name: Build and Unit Test Standalone
runs-on: ubuntu-latest

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

- name: Build Standalone
uses: ./.github/actions/build
with:
working-directory: Standalone

0 comments on commit 02a5001

Please sign in to comment.