Skip to content

Commit

Permalink
feat: add dev feature disabled test (#6014)
Browse files Browse the repository at this point in the history
feat: implement dev feature disabled integration test

implement dev feature desiabled integration test
  • Loading branch information
simeng-li authored Jun 17, 2024
1 parent ef21c7a commit bb6fd66
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/dev-feature-disabled-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Dev feature disabled compatibility integration test
on:
push:
branches:
- master
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
detect-dev-feature-changes:
runs-on: ubuntu-latest
outputs:
has-dev-feature-changes: ${{ steps.changes-detection.outputs.has-dev-feature-changes }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

# compare the current codebase with HEAD and check if there are any new lines with isDevFeaturesEnabled
- name: Get the diff and filter added lines
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE=$(git merge-base origin/${{github.base_ref}} HEAD)
else
BASE=${{ github.event.before }}
fi
git diff $BASE --unified=0 | grep -E '^\+' > added_lines.txt
sed -i '/^+++ /d' added_lines.txt
- name: Check for isDevFeaturesEnabled in added lines
id: changes-detection
run: |
if grep -q 'isDevFeaturesEnabled' added_lines.txt; then
echo "Dev features enabled changes detected"
echo "::set-output name=has-dev-feature-changes::true"
else
echo "No dev features enabled changes detected"
echo "::set-output name=has-dev-feature-changes::false"
fi
package:
needs: detect-dev-feature-changes
runs-on: ubuntu-latest
if: ${{needs.detect-dev-feature-changes.outputs.has-dev-feature-changes == 'true'}}
env:
INTEGRATION_TEST: true
DEV_FEATURES_ENABLED: false
steps:
- uses: logto-io/actions-package-logto-artifact@v2
with:
artifact-name: dev-feature-disabled-integration-test-${{ github.sha }}
branch: ${{github.base_ref}}
pnpm-version: 9

run-logto:
strategy:
fail-fast: false
matrix:
target: [api, experience, console]
needs: package
runs-on: ubuntu-latest
env:
INTEGRATION_TEST: true
DEV_FEATURES_ENABLED: false
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
steps:
- uses: logto-io/actions-run-logto-integration-tests@v3
with:
logto-artifact: dev-feature-disabled-integration-test-${{ github.sha }}
test-target: ${{ matrix.target }}
pnpm-version: 9
7 changes: 7 additions & 0 deletions packages/integration-tests/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { generateStandardId } from '@logto/shared';
import { assert } from '@silverhand/essentials';
import { type Page } from 'puppeteer';

import { isDevFeaturesEnabled } from './constants.js';

export const generateName = () => crypto.randomUUID();
export const generateUserId = () => crypto.randomUUID();
export const generateUsername = () => `usr_${crypto.randomUUID().replaceAll('-', '_')}`;
Expand Down Expand Up @@ -127,3 +129,8 @@ export const dmodal = () => `div[aria-modal=true]`;
export const generateTestName = () => `test_${generateStandardId(4)}`;

export const randomString = () => crypto.randomBytes(8).toString('hex');

export const devFeatureTest = Object.freeze({
it: isDevFeaturesEnabled ? it : it.skip,
describe: isDevFeaturesEnabled ? describe : describe.skip,
});

0 comments on commit bb6fd66

Please sign in to comment.