diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 7e33696..241c8b5 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -41,13 +41,19 @@ jobs: run: npm ci - name: Run linter over tests run: npx prettier -c test/**/*.ts - - name: Run integration tests with API token auth + - name: Should run integration tests + id: should-run-integration-tests if: ${{ matrix.node-version == '20.x' && - github.repository_owner == 'onfido' && - (github.event_name == 'pull_request' || - github.event_name == 'release' || - github.event_name == 'workflow_dispatch' || - github.event_name == 'schedule') }} + github.repository_owner == 'onfido' }} + uses: onfido/onfido-actions/should-run-integration-tests@main + - name: Acquire integration test lock + if: steps.should-run-integration-tests.outputs.result == 'true' + uses: onfido/onfido-actions/lock/acquire@main + with: + app-id: ${{ secrets.ONFIDO_CI_LOCK_APP_ID }} + app-private-key: ${{ secrets.ONFIDO_CI_LOCK_PRIVATE_KEY }} + - name: Run integration tests with API token auth + if: steps.should-run-integration-tests.outputs.result == 'true' run: npm test -- -i env: ONFIDO_API_TOKEN: ${{ secrets.ONFIDO_API_TOKEN }} @@ -57,11 +63,8 @@ jobs: ONFIDO_SAMPLE_MOTION_ID_1: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_1 }} ONFIDO_SAMPLE_MOTION_ID_2: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_2 }} - name: Run integration tests with OAuth client credentials auth - if: ${{ matrix.node-version == '20.x' && - github.repository_owner == 'onfido' && - (github.event_name == 'pull_request' || - github.event_name == 'release' || - github.event_name == 'workflow_dispatch') }} + if: ${{ steps.should-run-integration-tests.outputs.result == 'true' && + github.event_name != 'schedule' }} run: npm test -- -i env: ONFIDO_OAUTH_CLIENT_ID: ${{ secrets.ONFIDO_OAUTH_CLIENT_ID }} @@ -71,6 +74,12 @@ jobs: ONFIDO_SAMPLE_VIDEO_ID_2: ${{ secrets.ONFIDO_SAMPLE_VIDEO_ID_2 }} ONFIDO_SAMPLE_MOTION_ID_1: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_1 }} ONFIDO_SAMPLE_MOTION_ID_2: ${{ secrets.ONFIDO_SAMPLE_MOTION_ID_2 }} + - name: Release integration test lock + if: always() && steps.should-run-integration-tests.outputs.result == 'true' + uses: onfido/onfido-actions/lock/release@main + with: + app-id: ${{ secrets.ONFIDO_CI_LOCK_APP_ID }} + app-private-key: ${{ secrets.ONFIDO_CI_LOCK_PRIVATE_KEY }} publish: runs-on: ubuntu-latest