From 89cabfb79afbcadc442b205462c68ba18e56e7ac Mon Sep 17 00:00:00 2001 From: rakeshkumar1019 Date: Wed, 28 Feb 2024 16:51:12 +0530 Subject: [PATCH] concurrency --- .github/workflows/cancel.yaml | 30 --------------------- .github/workflows/test.yaml | 51 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/cancel.yaml diff --git a/.github/workflows/cancel.yaml b/.github/workflows/cancel.yaml deleted file mode 100644 index 06e63aa028..0000000000 --- a/.github/workflows/cancel.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: Cancel - -on: - pull_request: - branches: - - maintenance-3.1.x - workflow_run: - workflows: ["Test"] - types: - - completed - -jobs: - cancel_checks: - if: github.event_name == 'pull_request' && github.event.action == 'synchronize' - runs-on: ubuntu-latest - steps: - - name: Get commit SHA - id: get_commit_sha - run: echo "::set-output name=commit_sha::$(jq -r '.after' $GITHUB_EVENT_PATH)" - - name: List check runs - id: list_check_runs - run: | - checks=$(curl -s -X GET -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/commits/${{ steps.get_commit_sha.outputs.commit_sha }}/check-runs" | jq -r '.check_runs[] | select(.status == "in_progress") | .id') - echo "::set-output name=checks::$checks" - - name: Cancel check runs - if: steps.list_check_runs.outputs.checks != '' - run: | - for check_id in ${{ steps.list_check_runs.outputs.checks }}; do - curl -s -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.antiope-preview+json" "https://api.github.com/repos/${{ github.repository }}/check-runs/${check_id}/cancel" - done diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e69de29bb2..2776a629db 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -0,0 +1,51 @@ +name: Test + +on: + pull_request: + branches: + - maintenance-3.1.x + workflow_call: + inputs: + branch: + description: 'The current branch' + default: maintenance-3.1.x + type: string + required: false + secrets: + NPM_PACKAGES_TOKEN: + description: 'NPM_PACKAGES_TOKEN' + required: true + SAUCE_ACCESS_KEY: + description: 'SAUCE_ACCESS_KEY' + required: true + +env: + BRANCH_NAME: ${{ github.head_ref || inputs.branch || 'maintenance-3.1.x' }} + +jobs: + unit-test: + runs-on: [ self-hosted, master ] + concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || inputs.branch || 'maintenance-3.1.x' }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ env.BRANCH_NAME }} + + - uses: actions/setup-node@v3 + with: + registry-url: 'https://packages.nuxeo.com/repository/npm-public/' + scope: '@nuxeo' + node-version: 18 + + - name: Install + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm install + + - name: Unit tests + env: + SAUCE_USERNAME: nuxeo-web-ui + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} + run: npm run test \ No newline at end of file