mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fa0dbafe81
* feat(phrases): add phrases * feat(core): add domains library * feat(core): integrate cloudflare * chore: changeset * fix: read envset inside * fix: fix cloudflare request * fix: fix integration test envset problem * fix: cr fixes
163 lines
4.6 KiB
YAML
163 lines
4.6 KiB
YAML
name: Integration Test
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- "push-action/**"
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
package:
|
|
# See https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations
|
|
strategy:
|
|
matrix:
|
|
env: [oss, cloud]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Node and pnpm
|
|
uses: silverhand-io/actions-node-pnpm-run-steps@v3
|
|
|
|
- name: Build and package
|
|
if: matrix.env != 'cloud'
|
|
run: |
|
|
pnpm -r build
|
|
./.scripts/package.sh
|
|
|
|
- name: Build and package (Cloud)
|
|
if: matrix.env == 'cloud'
|
|
run: |
|
|
pnpm -r build
|
|
./.scripts/package.sh
|
|
env:
|
|
IS_CLOUD: 1
|
|
CONSOLE_PUBLIC_URL: /
|
|
ADMIN_ENDPOINT: http://localhost:3002
|
|
# Setup ApplicationInsights for smoke testing. Note the connection string should be a dev string.
|
|
APPLICATIONINSIGHTS_CONNECTION_STRING: ${{ secrets.APPLICATIONINSIGHTS_CONNECTION_STRING }}
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: integration-test-${{ github.sha }}-${{ matrix.env }}
|
|
path: /tmp/logto.tar.gz
|
|
retention-days: 3
|
|
|
|
run-logto:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
target: [api, api-cloud, ui, ui-cloud]
|
|
|
|
needs: package
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
INTEGRATION_TEST: true
|
|
IS_CLOUD: ${{ contains(matrix.target, 'cloud') && '1' || '0' }}
|
|
PATH_BASED_MULTI_TENANCY: ${{ contains(matrix.target, 'cloud') && '1' || '0' }}
|
|
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
path: tests
|
|
|
|
- name: Copy lockfile
|
|
run: |
|
|
cp tests/pnpm-lock.yaml ./
|
|
cp tests/package.json ./
|
|
|
|
- name: Setup Node and pnpm
|
|
uses: silverhand-io/actions-node-pnpm-run-steps@v3
|
|
with:
|
|
run-install: false
|
|
|
|
# Setup integration test
|
|
- name: Install dependencies
|
|
run: |
|
|
cd tests
|
|
pnpm i
|
|
pnpm prepack
|
|
# Install Chromium
|
|
cd packages/integration-tests/node_modules/puppeteer
|
|
pnpm postinstall
|
|
|
|
# Setup environment
|
|
- name: Setup Postgres
|
|
uses: ikalnytskyi/action-setup-postgres@v4
|
|
|
|
- name: Setup Redis
|
|
uses: supercharge/redis-github-action@1.5.0
|
|
with:
|
|
redis-version: 6
|
|
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: integration-test-${{ github.sha }}-${{ contains(matrix.target, 'cloud') && 'cloud' || 'oss' }}
|
|
|
|
- name: Extract
|
|
working-directory: tests
|
|
run: |
|
|
npm run cli init -- \
|
|
-p ../logto \
|
|
--du ../logto.tar.gz \
|
|
${{ contains(matrix.target, 'cloud') && '--cloud' || '' }}
|
|
|
|
- name: Check and add mock connectors
|
|
working-directory: tests
|
|
run: |
|
|
npm run cli connector list -- -p ../logto | grep OFFICIAL
|
|
npm run cli connector link -- --mock -p ../logto
|
|
|
|
- name: Setup mock Cloudflare Hostname Provider config
|
|
working-directory: tests
|
|
run: npm run cli db system set cloudflareHostnameProvider '{"zoneId":"mock-zone-id","apiToken":"","fallbackOrigin":"mock.logto.dev"}'
|
|
env:
|
|
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
|
|
|
|
- name: Run Logto
|
|
working-directory: logto/
|
|
run: nohup npm start > nohup.out 2> nohup.err < /dev/null &
|
|
env:
|
|
REDIS_URL: 1
|
|
|
|
- name: Run Logto Cloud
|
|
working-directory: logto/
|
|
if: contains(matrix.target, 'cloud')
|
|
run: nohup npm run start:cloud > nohup-cloud.out 2> nohup-cloud.err < /dev/null &
|
|
|
|
- name: Sleep for 5 seconds
|
|
run: sleep 5
|
|
|
|
# Test
|
|
- name: Run tests
|
|
# continue-on-error: true # Uncomment this line to debug
|
|
run: |
|
|
cd tests/packages/integration-tests
|
|
pnpm build
|
|
pnpm run test:${{ matrix.target }}
|
|
|
|
- name: Show logs
|
|
working-directory: logto/
|
|
run: cat nohup.out
|
|
|
|
- name: Show error logs
|
|
working-directory: logto/
|
|
run: cat nohup.err
|
|
|
|
- name: Show cloud logs
|
|
working-directory: logto/
|
|
if: contains(matrix.target, 'cloud')
|
|
run: cat nohup-cloud.out
|
|
|
|
- name: Show cloud error logs
|
|
working-directory: logto/
|
|
if: contains(matrix.target, 'cloud')
|
|
run: cat nohup-cloud.err
|