-
Notifications
You must be signed in to change notification settings - Fork 67
Run e2e tests on GitHub actions #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ewanharris
wants to merge
13
commits into
master
Choose a base branch
from
ci/setup-gh-actions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7a5ad29
Add first pass at ci on gh actions
ewanharris 4ed5fe8
Setup docker
ewanharris bb19036
Dont background the build script as it starts the server
ewanharris 999f093
Dont use exec script
ewanharris 8d645e6
Add missing name arg
ewanharris 7231c66
Fix environment variable names
ewanharris 094647c
Pass secrets in as environment variables directly
ewanharris 4adb443
Set API_URL environent variable
ewanharris 6080259
Fix environment variable names
ewanharris f9b2dd7
Move to a reusable workflow
ewanharris 41790e9
Remove temporary branch
ewanharris 1530455
Add collecting of app logs when tests fail
ewanharris 8f61cd0
Update .github/workflows/api-qs-tests.yml
ewanharris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Run API QuickStart Sample Tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
sample-directory: | ||
required: true | ||
type: string | ||
api-url: | ||
default: 'http://localhost:3010' | ||
type: string | ||
test-directory: | ||
default: 'tests' | ||
type: string | ||
test-ref: | ||
default: 'master' | ||
type: string | ||
secrets: | ||
AUTH0_DOMAIN: | ||
required: true | ||
API_IDENTIFIER: | ||
required: true | ||
CLIENT_ID_SCOPES_NONE: | ||
required: true | ||
CLIENT_SECRET_SCOPES_NONE: | ||
required: true | ||
CLIENT_ID_SCOPES_READ: | ||
required: true | ||
CLIENT_SECRET_SCOPES_READ: | ||
required: true | ||
CLIENT_ID_SCOPES_WRITE: | ||
required: true | ||
CLIENT_SECRET_SCOPES_WRITE: | ||
required: true | ||
CLIENT_ID_SCOPES_READWRITE: | ||
required: true | ||
CLIENT_SECRET_SCOPES_READWRITE: | ||
required: true | ||
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: | ||
needs: authorize | ||
name: 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: Checkout Tests | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: auth0-samples/api-quickstarts-tests | ||
path: ${{ inputs.test-directory }} | ||
ref: ${{ inputs.test-ref }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Setup sample .env | ||
working-directory: ${{ inputs.sample-directory }} | ||
env: | ||
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} | ||
API_IDENTIFIER: ${{ secrets.API_IDENTIFIER }} | ||
run: | | ||
sed \ | ||
-e "s|{DOMAIN}|$AUTH0_DOMAIN|g" \ | ||
-e "s|{API_IDENTIFIER}|$API_IDENTIFIER|g" \ | ||
.env.example > .env | ||
|
||
- name: Build PR image | ||
working-directory: ${{ inputs.sample-directory }} | ||
env: | ||
IMAGE_NAME: ${{ github.event.pull_request.head.sha || github.sha }} | ||
CONTAINER_NAME: ${{ github.event.pull_request.head.sha || github.sha }} | ||
run: | | ||
docker build -t $IMAGE_NAME . | ||
docker run -d --env-file .env -p 3010:3010 --name $CONTAINER_NAME $IMAGE_NAME | ||
|
||
- name: Wait for sample to start | ||
run: | | ||
sleep 10 | ||
docker run --network host --rm appropriate/curl --retry 8 --retry-connrefused -v localhost:3010 | ||
|
||
- name: Install dependencies | ||
working-directory: tests | ||
run: npm i | ||
|
||
- name: Run tests | ||
working-directory: tests | ||
env: | ||
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} | ||
API_IDENTIFIER: ${{ secrets.API_IDENTIFIER }} | ||
API_URL: ${{ inputs.api-url }} | ||
AUTH0_CLIENT_ID_1: ${{ secrets.CLIENT_ID_SCOPES_NONE }} | ||
AUTH0_CLIENT_SECRET_1: ${{ secrets.CLIENT_SECRET_SCOPES_NONE }} | ||
AUTH0_CLIENT_ID_2: ${{ secrets.CLIENT_ID_SCOPES_READ }} | ||
AUTH0_CLIENT_SECRET_2: ${{ secrets.CLIENT_SECRET_SCOPES_READ }} | ||
AUTH0_CLIENT_ID_3: ${{ secrets.CLIENT_ID_SCOPES_WRITE }} | ||
AUTH0_CLIENT_SECRET_3: ${{ secrets.CLIENT_SECRET_SCOPES_WRITE }} | ||
AUTH0_CLIENT_ID_4: ${{ secrets.CLIENT_ID_SCOPES_READWRITE }} | ||
AUTH0_CLIENT_SECRET_4: ${{ secrets.CLIENT_SECRET_SCOPES_READWRITE }} | ||
run: npm test | ||
|
||
- name: Copy app logs | ||
env: | ||
CONTAINER_NAME: ${{ github.event.pull_request.head.sha || github.sha }} | ||
run: | | ||
mkdir -p /tmp/out | ||
docker logs $CONTAINER_NAME > /tmp/out/app_logs.log | ||
if: failure() |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Test | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- synchronize | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
RS256-tests: | ||
uses: ./.github/workflows/api-qs-tests.yml | ||
with: | ||
sample-directory: '01-Authorization-RS256' | ||
secrets: inherit |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.