mirror of
https://github.com/logto-io/logto.git
synced 2025-02-17 22:04:19 -05:00
ci: add alteration scripts compatibility test jobs (#4627)
* feat: refactor the integration-test ci job using custom interaction - refactor the integration-test ci job using custom action - add db alteration integration-tests * fix: fix the detection git diff fix the detection git diff * fix: should not throw error if grep statement return empty should not throw error if grep statement return empty * feat: update the action reference update the action reference * chore: update the integration test action ref update the integration test action ref
This commit is contained in:
parent
cc81d8de33
commit
735dcb67a8
2 changed files with 75 additions and 96 deletions
70
.github/workflows/alteration-compatibility-integration-test.yml
vendored
Normal file
70
.github/workflows/alteration-compatibility-integration-test.yml
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
# This integration test ci job is used to test the DB alterations compatibility with the current codebase.
|
||||
|
||||
name: Alteration compatibility 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:
|
||||
check-alteration-changes:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
has-alteration-changes: ${{ steps.changes-detection.outputs.has-alteration-changes }}
|
||||
|
||||
steps:
|
||||
- name: checkout head
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# compare the current codebase with HEAD and check if there are any changes under the alterations folder
|
||||
- name: Check for alteration changes
|
||||
id: changes-detection
|
||||
run: |
|
||||
CHANGE_FILES=$(git diff --name-only HEAD..origin/${{github.base_ref}} | grep 'packages/schemas/alterations/' || true)
|
||||
if [ -n "$CHANGE_FILES" ]; then
|
||||
echo "$CHANGE_FILES"
|
||||
echo "::set-output name=has-alteration-changes::true"
|
||||
echo "Alteration changes detected"
|
||||
else
|
||||
echo "::set-output name=has-alteration-changes::false"
|
||||
echo "No alteration changes detected"
|
||||
fi
|
||||
|
||||
package:
|
||||
needs: check-alteration-changes
|
||||
runs-on: buildjet-4vcpu-ubuntu-2204
|
||||
if: ${{needs.check-alteration-changes.outputs.has-alteration-changes == 'true'}}
|
||||
env:
|
||||
INTEGRATION_TEST: true
|
||||
steps:
|
||||
- uses: logto-io/actions-package-logto-artifact@v1.0.0
|
||||
with:
|
||||
artifact-name: alteration-integration-test-${{ github.sha }}
|
||||
branch: ${{github.base_ref}}
|
||||
|
||||
run-logto:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target: [api, experience, console]
|
||||
needs: package
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
INTEGRATION_TEST: true
|
||||
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
|
||||
|
||||
steps:
|
||||
- uses: logto-io/actions-run-logto-integration-tests@v1.0.0
|
||||
with:
|
||||
branch: ${{github.base_ref}}
|
||||
logto_artifact: alteration-integration-test-${{ github.sha }}
|
||||
test_target: ${{ matrix.target }}
|
||||
db_alteration_target: ${{github.head_ref}}
|
101
.github/workflows/integration-test.yml
vendored
101
.github/workflows/integration-test.yml
vendored
|
@ -14,33 +14,19 @@ concurrency:
|
|||
jobs:
|
||||
package:
|
||||
runs-on: buildjet-4vcpu-ubuntu-2204
|
||||
|
||||
env:
|
||||
INTEGRATION_TEST: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node and pnpm
|
||||
uses: silverhand-io/actions-node-pnpm-run-steps@v3
|
||||
|
||||
- name: Build and package
|
||||
run: |
|
||||
pnpm -r build
|
||||
./.scripts/package.sh
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: logto-io/actions-package-logto-artifact@v1.0.0
|
||||
with:
|
||||
name: integration-test-${{ github.sha }}
|
||||
path: /tmp/logto.tar.gz
|
||||
retention-days: 3
|
||||
artifact-name: integration-test-${{ github.sha }}
|
||||
|
||||
run-logto:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target: [api, experience, console]
|
||||
|
||||
needs: package
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
|
@ -48,84 +34,7 @@ jobs:
|
|||
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: logto-io/actions-run-logto-integration-tests@v1.0.0
|
||||
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@6dc7a5eeaf9a8f860b6464e05195a15f8b9f3bbb # 1.7.0
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: integration-test-${{ github.sha }}
|
||||
|
||||
- name: Extract
|
||||
working-directory: tests
|
||||
run: |
|
||||
npm run cli init -- \
|
||||
-p ../logto \
|
||||
--du ../logto.tar.gz
|
||||
|
||||
- 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":""}'
|
||||
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: Sleep for 5 seconds
|
||||
run: sleep 5
|
||||
|
||||
# Test
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd tests/packages/integration-tests
|
||||
pnpm build
|
||||
pnpm run test:${{ matrix.target }}
|
||||
|
||||
- name: Show logs
|
||||
if: always()
|
||||
working-directory: logto/
|
||||
run: cat nohup.out
|
||||
|
||||
- name: Show error logs
|
||||
if: always()
|
||||
working-directory: logto/
|
||||
run: cat nohup.err
|
||||
logto_artifact: integration-test-${{ github.sha }}
|
||||
test_target: ${{ matrix.target }}
|
||||
|
|
Loading…
Add table
Reference in a new issue