-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDK-4436] test: Migrate CI to GitHub Actions (#564)
- Loading branch information
Showing
13 changed files
with
3,319 additions
and
11,759 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build package | ||
description: Build the SDK package | ||
|
||
inputs: | ||
node: | ||
description: The Node version to use | ||
required: false | ||
default: 18 | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.node }} | ||
cache: 'npm' | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: npm ci --include=dev | ||
|
||
- name: Build package | ||
shell: bash | ||
run: npm run build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Run integration test | ||
description: Prepares the environment and runs an integration test using Cypress | ||
|
||
inputs: | ||
integration: | ||
description: The integration test to run | ||
required: true | ||
node: | ||
description: The Node version to use | ||
required: false | ||
default: 18 | ||
dotenv: | ||
description: The path to the .env file | ||
required: false | ||
default: .env.sample | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
|
||
- name: Prepare dependencies | ||
shell: bash | ||
run: | | ||
pnpm import | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.node }} | ||
cache: 'pnpm' | ||
|
||
- name: Update /etc/hosts | ||
shell: bash | ||
run: | | ||
sudo echo "127.0.0.1 localhost" | sudo tee -a /etc/hosts | ||
- name: Move dotenv file | ||
shell: bash | ||
run: | | ||
mv examples/${{ inputs.integration }}/${{ inputs.dotenv }} examples/${{ inputs.integration }}/.env | ||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
pnpm i | ||
- name: Start mock API server | ||
shell: bash | ||
run: | | ||
cd examples/users-api | ||
pnpm i | ||
pnpm run start & | ||
env: | ||
DOMAIN: your-tenant.auth0.com | ||
AUDIENCE: https://api.example.com/users | ||
PORT: 3001 | ||
|
||
- name: Start application | ||
shell: bash | ||
run: | | ||
cd examples/${{ inputs.integration }} | ||
pnpm i | ||
pnpm run start & | ||
env: | ||
PORT: 3000 | ||
|
||
- name: Run Cypress test | ||
uses: cypress-io/github-action@v6 | ||
with: | ||
spec: cypress/integration/smoke.test.ts | ||
install: false | ||
wait-on: 'http://localhost:3001/, http://localhost:3000' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Browserstack | ||
|
||
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 | ||
|
||
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 | ||
|
||
browserstack: | ||
needs: authorize # Require approval before running on forked pull requests | ||
|
||
name: BrowserStack Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha || github.ref }} | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
cache: npm | ||
|
||
- name: Build package | ||
uses: ./.github/actions/build | ||
with: | ||
node: ${{ env.NODE_VERSION }} | ||
|
||
- name: Run tests | ||
shell: bash | ||
run: npx concurrently --raw --kill-others --success first "npm:start" "wait-on http://127.0.0.1:3000/ && browserstack-cypress run --build-name ${{ github.event.pull_request.head.sha || github.ref }} --no-wrap --specs "cypress/integration/smoke-bs.test.ts"" | ||
env: | ||
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} | ||
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Integration Tests | ||
|
||
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 | ||
# Mock user credentials for Cypress tests | ||
CYPRESS_USER_EMAIL: [email protected] | ||
CYPRESS_USER_PASSWORD: mockpassword | ||
|
||
jobs: | ||
test-react-router: | ||
name: Run react-router tests | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
SKIP_PREFLIGHT_CHECK: true | ||
REACT_APP_DOMAIN: your-tenant.auth0.com | ||
REACT_APP_CLIENT_ID: yourclientid | ||
REACT_APP_AUDIENCE: https://api.example.com/users | ||
REACT_APP_API_PORT: 3001 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run integration test | ||
uses: ./.github/actions/integration | ||
with: | ||
integration: 'cra-react-router' | ||
node: ${{ env.NODE_VERSION }} | ||
|
||
test-gatsby: | ||
name: Run Gatsby tests | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
GATSBY_DOMAIN: your-tenant.auth0.com | ||
GATSBY_CLIENT_ID: yourclientid | ||
GATSBY_AUDIENCE: https://api.example.com/users | ||
GATSBY_API_PORT: 3001 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run integration test | ||
uses: ./.github/actions/integration | ||
with: | ||
integration: 'gatsby-app' | ||
node: ${{ env.NODE_VERSION }} | ||
dotenv: '.env.development.sample' | ||
|
||
test-nextjs: | ||
name: Run NextJS tests | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
NEXT_PUBLIC_DOMAIN: your-tenant.auth0.com | ||
NEXT_PUBLIC_CLIENT_ID: yourclientid | ||
NEXT_PUBLIC_AUDIENCE: https://api.example.com/users | ||
NEXT_PUBLIC_API_PORT: 3001 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run integration test | ||
uses: ./.github/actions/integration | ||
with: | ||
integration: 'nextjs-app' | ||
node: ${{ env.NODE_VERSION }} |
Oops, something went wrong.