From f0ebc6a70831321fc38afb07e3274bd704724e5c Mon Sep 17 00:00:00 2001 From: David Antoon Date: Wed, 6 Sep 2023 06:47:43 +0300 Subject: [PATCH 1/2] trigger e2e test for alpha versions --- .github/workflows/publish-prerelease.yml | 37 ++++++++++++++++++++ .github/workflows/trigger-e2e-test.yml | 44 ++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/trigger-e2e-test.yml diff --git a/.github/workflows/publish-prerelease.yml b/.github/workflows/publish-prerelease.yml index de397cb26..8daa83b62 100644 --- a/.github/workflows/publish-prerelease.yml +++ b/.github/workflows/publish-prerelease.yml @@ -103,6 +103,43 @@ jobs: env: NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + - name: Publish Pre-Release version to NPM + id: publish_pre_release_version + run: | + version=$(node -p 'require("./lerna.json").version') + echo "::set-output name=LIB_VERSION::${version}" + echo "Publishing DEV version - v${version}-alpha.${{ github.run_id }}" + make move-package-json-to-dist + make prerelease-version-upgrade-${version}-alpha.${{ github.run_id }} + make pretty + git add . + git commit -m "chore: prelrease version" + make publish-packages-next + env: + NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + + - name: Trigger E2E test workflow + uses: actions/github-script@v5 + env: + PR_REF: '${{ steps.cpr.outputs.pull-request-head-sha }}' + PR_VERSION: '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }}' + with: + github-token: ${{ secrets.GH_REPOSITORY_ADMIN_TOKEN }} + script: | + const sha = process.env.PR_REF; + const repo = context.payload.repository.name + const owner = context.payload.repository.organization + + const data = await github.rest.actions.createWorkflowDispatch({ + owner: context.payload.repository.organization, + repo: context.payload.repository.name, + workflow_id: 'trigger-e2e-test.yml', + ref: process.env.PR_REF, + inputs: { + version: process.env.PR_VERSION, + dispatch_id: `${repo}/${sha}`, + } + }); - name : Notify Slack on alpha version deployment uses : rtCamp/action-slack-notify@v2 env : diff --git a/.github/workflows/trigger-e2e-test.yml b/.github/workflows/trigger-e2e-test.yml new file mode 100644 index 000000000..001d10002 --- /dev/null +++ b/.github/workflows/trigger-e2e-test.yml @@ -0,0 +1,44 @@ +name: Trigger E2E tests Workflow + +on: + workflow_dispatch: + inputs: + version: + description: 'Version' + required: true + dispatch_id: + description: 'Dispatch Id (repo/sha)' + required: true + +jobs: + trigger_e2e_tests: + name: "Trigger E2E tests Workflow" + runs-on: ubuntu-latest + steps: + - name: "Trigger E2E tests" + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GH_REPOSITORY_ADMIN_TOKEN }} + script: | + const sha = context.payload.after; + const repo = context.payload.repository.name + const owner = context.payload.repository.organization + const e2eRepo = 'e2e-system-tests' + const workflow_id = 'frontegg-react-e2e-tests.yml' + const context = `${owner}/${e2eRepo}` + const dispatch_id = `${repo}/${sha}`; + + const res = await github.rest.repos.createCommitStatus({ + context, owner, repo, sha, + state: 'pending', + description: 'Dispatching E2E tests...', + }); + + const data = await github.rest.actions.createWorkflowDispatch({ + owner, repo:e2eRepo, workflow_id, + ref: 'main', + inputs: { + version: '1.0.0', + dispatch_id, + } + }); From 30457a492283c9665727a2fb441c72a51d77f4e7 Mon Sep 17 00:00:00 2001 From: David Antoon Date: Wed, 6 Sep 2023 10:40:46 +0300 Subject: [PATCH 2/2] get version from inputs --- .github/workflows/publish-prerelease.yml | 3 ++- .github/workflows/trigger-e2e-test.yml | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-prerelease.yml b/.github/workflows/publish-prerelease.yml index 8daa83b62..9fceef20e 100644 --- a/.github/workflows/publish-prerelease.yml +++ b/.github/workflows/publish-prerelease.yml @@ -137,7 +137,8 @@ jobs: ref: process.env.PR_REF, inputs: { version: process.env.PR_VERSION, - dispatch_id: `${repo}/${sha}`, + repo, + sha } }); - name : Notify Slack on alpha version deployment diff --git a/.github/workflows/trigger-e2e-test.yml b/.github/workflows/trigger-e2e-test.yml index 001d10002..f69d30e46 100644 --- a/.github/workflows/trigger-e2e-test.yml +++ b/.github/workflows/trigger-e2e-test.yml @@ -17,16 +17,18 @@ jobs: steps: - name: "Trigger E2E tests" uses: actions/github-script@v5 + env: + version: ${{ inputs.version }} + dispatch_id: ${{ inputs.dispatch_id }} with: github-token: ${{ secrets.GH_REPOSITORY_ADMIN_TOKEN }} script: | - const sha = context.payload.after; - const repo = context.payload.repository.name + const {repo, sha, version} = process.env; const owner = context.payload.repository.organization const e2eRepo = 'e2e-system-tests' const workflow_id = 'frontegg-react-e2e-tests.yml' const context = `${owner}/${e2eRepo}` - const dispatch_id = `${repo}/${sha}`; + const dispatch_id = `${repo}/${sha}` const res = await github.rest.repos.createCommitStatus({ context, owner, repo, sha, @@ -35,10 +37,12 @@ jobs: }); const data = await github.rest.actions.createWorkflowDispatch({ - owner, repo:e2eRepo, workflow_id, + owner, + repo:e2eRepo, + workflow_id, ref: 'main', inputs: { - version: '1.0.0', + version, dispatch_id, } });