From 534041d23708a410424f203f88291bce0930b8e9 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 05:29:27 +0000 Subject: [PATCH 01/23] [CI] allow for manual triggered jobs to accept inputs Utilizing the GitHub `workflow_dispatch`, we can trigger a job with a specific input. Here we are allowing for tests to be ran pulling down from: https://github.com/opensearch-project/opensearch-dashboards-functional-test This workflow uses the target branch of the PR to pull down from the FTRepo and run the tests from that specific branch. For example, PRs against `main` will pull down `main` from the FTRepo. The problem occurs when new functionality is opened or a bug is fixed and, per industry standard, we want to see tests added to ensure functionality, stability, and raise the bar. But the cypress tests PR into the FTRepo depends on the new code to be merged for the CI within the FTRepo to work. So we have a stalemate that usually slows down PR review time. Here, a manual run can be triggered using the branch provided by the maintainer who ran the job. Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 5e78785f9b88..0f75de6dd222 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -6,6 +6,14 @@ on: branches: [ '**' ] paths-ignore: - '**/*.md' + workflow_dispatch: + inputs: + branch: + description: 'Execute tests from this branch' + required: true + default: '${{ github.base_ref }}' + type: string + env: FTR_PATH: 'ftr' From 0bfeab04a42426250104297b222ad16509a793a2 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 05:47:23 +0000 Subject: [PATCH 02/23] utilize different variable Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 4 ++-- .gitignore | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 0f75de6dd222..2b2d5d502ec0 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -11,7 +11,7 @@ on: branch: description: 'Execute tests from this branch' required: true - default: '${{ github.base_ref }}' + default: '${{ GITHUB_BASE_REF }}' type: string @@ -63,7 +63,7 @@ jobs: with: path: ${{ env.FTR_PATH }} repository: opensearch-project/opensearch-dashboards-functional-test - ref: '${{ github.base_ref }}' + ref: '${{ inputs.branch }}' - name: Get Cypress version id: cypress_version diff --git a/.gitignore b/.gitignore index d72d66a6d17d..930222139ef3 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,10 @@ trash target /build /bwc_tmp +/scripts/random/data +/scripts/random/stdout.txt +/scripts/random/data.tar.gz +/scripts/random.tar.gz .jruby .idea *.iml From a1f867db308b90c71ce4ac3d28667fa9912cbeb6 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 05:51:18 +0000 Subject: [PATCH 03/23] use gitenv Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 2b2d5d502ec0..6a0f7a0c7443 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -11,7 +11,7 @@ on: branch: description: 'Execute tests from this branch' required: true - default: '${{ GITHUB_BASE_REF }}' + default: $env:GITHUB_BASE_REF type: string From 2b1768e829920a5e47ec3b85a7ebe643e2fbd190 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 05:59:13 +0000 Subject: [PATCH 04/23] log Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 6a0f7a0c7443..b84baea951a1 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -38,6 +38,7 @@ jobs: TERM: xterm name: Run cypress tests steps: + - run: echo "Targetted branch is ${{ inputs.branch }}" - name: Checkout code uses: actions/checkout@v2 From adcf8db1693da2727338e3e5d6b1414f13753033 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 06:04:56 +0000 Subject: [PATCH 05/23] base ref Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index b84baea951a1..fd1dc5087f63 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -11,7 +11,7 @@ on: branch: description: 'Execute tests from this branch' required: true - default: $env:GITHUB_BASE_REF + default: ' ${{ env.GITHUB_BASE_REF }}' type: string From b8946be562f783d9f6b5eb3395d754630aec065a Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 06:53:22 +0000 Subject: [PATCH 06/23] pass 3 var Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index fd1dc5087f63..0154720eb28b 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -8,18 +8,30 @@ on: - '**/*.md' workflow_dispatch: inputs: - branch: - description: 'Execute tests from this branch' + repository: + description: 'Repo of the tests' + default: 'opensearch-project/opensearch-dashboards-functional-test' required: true - default: ' ${{ env.GITHUB_BASE_REF }}' type: string - + branch: + description: 'Branch of the tests (default: target branch)' + default: '' + required: false + type: string + specs: + description: 'Additional tests to run' + default: '' + required: false + type: string env: + REPO: ${{ inputs.repository != '' && inputs.repository || 'opensearch-project/opensearch-dashboards-functional-test' }} + TEST_BRANCH: ${{ inputs.branch != '' && inputs.branch || github.base_ref }} FTR_PATH: 'ftr' START_CMD: 'node ../scripts/opensearch_dashboards --dev --no-base-path --no-watch' OPENSEARCH_SNAPSHOT_CMD: 'node ../scripts/opensearch snapshot' SPEC: 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js,' + ADDITIONAL_SPEC: "${{ inputs.specs != '' && inputs.specs || '' }}" CYPRESS_BROWSER: 'chromium' CYPRESS_VISBUILDER_ENABLED: true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED: false @@ -38,7 +50,11 @@ jobs: TERM: xterm name: Run cypress tests steps: - - run: echo "Targetted branch is ${{ inputs.branch }}" + - run: | + echo "Repo: ${{ env.REPO }}" + echo "Test branch: ${{ env.TEST_BRANCH }}" + echo "Extra spec: ${{ env.ADDITIONAL_SPEC }}" + - name: Checkout code uses: actions/checkout@v2 @@ -63,8 +79,8 @@ jobs: uses: actions/checkout@v2 with: path: ${{ env.FTR_PATH }} - repository: opensearch-project/opensearch-dashboards-functional-test - ref: '${{ inputs.branch }}' + repository: ${{ env.REPO }} + ref: '${{ env.TEST_BRANCH }}' - name: Get Cypress version id: cypress_version @@ -88,7 +104,7 @@ jobs: working-directory: ${{ env.FTR_PATH }} start: ${{ env.OPENSEARCH_SNAPSHOT_CMD }}, ${{ env.START_CMD }} wait-on: 'http://localhost:9200, http://localhost:5601' - command: yarn cypress:run-without-security --browser ${{ env.CYPRESS_BROWSER }} --spec ${{ env.SPEC }} + command: yarn cypress:run-without-security --browser ${{ env.CYPRESS_BROWSER }} --spec ${{ env.SPEC }}${{ env.ADDITIONAL_SPEC }} # Screenshots are only captured on failure, will change this once we do visual regression tests - uses: actions/upload-artifact@v3 From 2228674c3da68fa878386a420adcded1163fbb23 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 06:55:25 +0000 Subject: [PATCH 07/23] verify inputs Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 0154720eb28b..e5cff5d760c7 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -50,6 +50,7 @@ jobs: TERM: xterm name: Run cypress tests steps: + - name: Verify inputs - run: | echo "Repo: ${{ env.REPO }}" echo "Test branch: ${{ env.TEST_BRANCH }}" From b303bdcc7872bf0fc9f6ad9b7977dbc31e30ebcb Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 06:56:05 +0000 Subject: [PATCH 08/23] invalid Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index e5cff5d760c7..0154720eb28b 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -50,7 +50,6 @@ jobs: TERM: xterm name: Run cypress tests steps: - - name: Verify inputs - run: | echo "Repo: ${{ env.REPO }}" echo "Test branch: ${{ env.TEST_BRANCH }}" From b55fa72a05cce42fc81abaa03ac4841ea71c128c Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 07:57:39 +0000 Subject: [PATCH 09/23] add comment adder Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 44 +++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 0154720eb28b..7e3e99f301dd 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -23,6 +23,11 @@ on: default: '' required: false type: string + pr_number: + description: 'Pull request number to link results' + default: '' + required: false + type: number env: REPO: ${{ inputs.repository != '' && inputs.repository || 'opensearch-project/opensearch-dashboards-functional-test' }} @@ -36,6 +41,9 @@ env: CYPRESS_VISBUILDER_ENABLED: true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED: false OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true + COMMENT_TAG: '[MANUAL CYPRESS TEST RUN RESULTS]' + COMMENT_SUCCESS_MSG: ':white_check_mark: Cypress test run succeeded.' + COMMENT_FAILURE_MSG: ':x: Cypress test run failed.' jobs: cypress-tests: @@ -126,4 +134,38 @@ jobs: with: name: ftr-cypress-results path: ${{ env.FTR_PATH }}/cypress/results - retention-days: 1 \ No newline at end of file + retention-days: 1 + + add-comment: + needs: [cypress-tests] + if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} + permissions: + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: ${{ inputs.pr_number }} + comment-author: 'github-actions[bot]' + body-includes: "${{ env.COMMENT_TAG }}" + + - name: Add comment on the PR + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ inputs.pr_number }} + body: | + ### ${{ env.COMMENT_TAG }} + + #### ${{ needs.cypress-tests.result == 'success' && env.COMMENT_SUCCESS_MSG || env.COMMENT_FAILURE_MSG }} + + #### Inputs: + Test repo: `${{ env.REPO }}` + Test branch: `${{ env.TEST_BRANCH }}` + Spec: `${{ env.SPEC }}${{ env.ADDITIONAL_SPEC }}` + + Link to results: + ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + edit-mode: replace From fa67faa72a29b00123a6678eeefa4a42b54ad4da Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 08:00:30 +0000 Subject: [PATCH 10/23] test comment Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 7e3e99f301dd..ed620964c233 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -46,6 +46,39 @@ env: COMMENT_FAILURE_MSG: ':x: Cypress test run failed.' jobs: + test-add-comment: + if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} + permissions: + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: ${{ inputs.pr_number }} + comment-author: 'github-actions[bot]' + body-includes: "${{ env.COMMENT_TAG }}" + + - name: Add comment on the PR + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ inputs.pr_number }} + body: | + ### ${{ env.COMMENT_TAG }} + + #### ${{ env.CYPRESS_VISBUILDER_ENABLED && env.COMMENT_SUCCESS_MSG || env.COMMENT_FAILURE_MSG }} + + #### Inputs: + Test repo: `${{ env.REPO }}` + Test branch: `${{ env.TEST_BRANCH }}` + Spec: `${{ env.SPEC }}${{ env.ADDITIONAL_SPEC }}` + + Link to results: + ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + edit-mode: replace + cypress-tests: runs-on: ubuntu-latest container: From 98079ab9bc06bbdefe904639bd2bdf0bd7cf9dea Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 09:43:39 +0000 Subject: [PATCH 11/23] accept input and read pr Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 93 ++++++++++++++++++++------ 1 file changed, 74 insertions(+), 19 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index ed620964c233..7ddbf8a26350 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -7,31 +7,30 @@ on: paths-ignore: - '**/*.md' workflow_dispatch: - inputs: - repository: - description: 'Repo of the tests' + inputs: + test_repo: + description: 'Test repo' default: 'opensearch-project/opensearch-dashboards-functional-test' required: true type: string - branch: - description: 'Branch of the tests (default: target branch)' - default: '' + test_branch: + description: 'Test branch (default: source branch)' required: false type: string + pr_number: + description: 'PR Number' + required: false + type: number specs: description: 'Additional tests to run' - default: '' required: false type: string - pr_number: - description: 'Pull request number to link results' - default: '' - required: false - type: number env: - REPO: ${{ inputs.repository != '' && inputs.repository || 'opensearch-project/opensearch-dashboards-functional-test' }} - TEST_BRANCH: ${{ inputs.branch != '' && inputs.branch || github.base_ref }} + SOURCE_REPO: ${{ github.repository }} + SOURCE_BRANCH: ${{ github.base_ref }} + TEST_REPO: ${{ inputs.test_repo != '' && inputs.test_repo || 'opensearch-project/opensearch-dashboards-functional-test' }} + TEST_BRANCH: ${{ inputs.test_branch != '' && inputs.test_branch || github.base_ref }} FTR_PATH: 'ftr' START_CMD: 'node ../scripts/opensearch_dashboards --dev --no-base-path --no-watch' OPENSEARCH_SNAPSHOT_CMD: 'node ../scripts/opensearch snapshot' @@ -52,6 +51,30 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: + - name: Get source information from PR number + if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} + id: get_pr_info + uses: actions/github-script@v6 + with: + result-encoding: string + script: | + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: "${{ inputs.pr_number }}" + }); + + const sourceRepo = pr.head.repo.full_name; + const sourceBranch = pr.head.ref; + const sourceJSON = `{ 'source': { 'repo': '${sourceRepo}', 'branch': '${sourceBranch}' } }`; + return sourceJSON; + + - name: Set source branch from PR number + if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} + run: | + echo "SOURCE_REPO=${{ fromJSON(steps.get_pr_info.outputs.result.source.repo) }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ fromJSON(steps.get_pr_info.outputs.result.source.branch) }}" >> $GITHUB_ENV + - name: Find Comment uses: peter-evans/find-comment@v2 id: fc @@ -71,7 +94,9 @@ jobs: #### ${{ env.CYPRESS_VISBUILDER_ENABLED && env.COMMENT_SUCCESS_MSG || env.COMMENT_FAILURE_MSG }} #### Inputs: - Test repo: `${{ env.REPO }}` + Source repo: `${{ env.SOURCE_REPO }}` + Source branch: `${{ env.SOURCE_BRANCH }}` + Test repo: `${{ env.TEST_REPO }}` Test branch: `${{ env.TEST_BRANCH }}` Spec: `${{ env.SPEC }}${{ env.ADDITIONAL_SPEC }}` @@ -91,13 +116,42 @@ jobs: TERM: xterm name: Run cypress tests steps: + - name: Get source information from PR number + if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} + id: get_pr_info + uses: actions/github-script@v6 + with: + result-encoding: string + script: | + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: "${{ inputs.pr_number }}" + }); + + const sourceRepo = pr.head.repo.full_name; + const sourceBranch = pr.head.ref; + const sourceJSON = `{ 'source': { 'repo': '${sourceRepo}', 'branch': '${sourceBranch}' } }`; + return sourceJSON; + + - name: Set source branch from PR number + if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} + run: | + echo "SOURCE_REPO=${{ fromJSON(steps.get_pr_info.outputs.result.source.repo) }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ fromJSON(steps.get_pr_info.outputs.result.source.branch) }}" >> $GITHUB_ENV + - run: | - echo "Repo: ${{ env.REPO }}" + echo "Source repo: ${{ env.SOURCE_REPO }}" + echo "Source branch: ${{ env.SOURCE_BRANCH }}" + echo "Test repo: ${{ env.TEST_REPO }}" echo "Test branch: ${{ env.TEST_BRANCH }}" echo "Extra spec: ${{ env.ADDITIONAL_SPEC }}" - name: Checkout code uses: actions/checkout@v2 + with: + repository: ${{ env.SOURCE_REPO }} + ref: '${{ env.SOURCE_BRANCH }}' - name: Setup Node uses: actions/setup-node@v2 @@ -120,7 +174,7 @@ jobs: uses: actions/checkout@v2 with: path: ${{ env.FTR_PATH }} - repository: ${{ env.REPO }} + repository: ${{ env.TEST_REPO }} ref: '${{ env.TEST_BRANCH }}' - name: Get Cypress version @@ -195,9 +249,10 @@ jobs: #### ${{ needs.cypress-tests.result == 'success' && env.COMMENT_SUCCESS_MSG || env.COMMENT_FAILURE_MSG }} #### Inputs: - Test repo: `${{ env.REPO }}` + Source repo: `${{ env.SOURCE_REPO }}` + Source branch: `${{ env.SOURCE_BRANCH }}` + Test repo: `${{ env.TEST_REPO }}` Test branch: `${{ env.TEST_BRANCH }}` - Spec: `${{ env.SPEC }}${{ env.ADDITIONAL_SPEC }}` Link to results: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} From ebc4df99b15657e486c123fa7775a98c06394d09 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 09:53:30 +0000 Subject: [PATCH 12/23] use esclation Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 7ddbf8a26350..9a50af607ded 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -41,8 +41,8 @@ env: CYPRESS_DATASOURCE_MANAGEMENT_ENABLED: false OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true COMMENT_TAG: '[MANUAL CYPRESS TEST RUN RESULTS]' - COMMENT_SUCCESS_MSG: ':white_check_mark: Cypress test run succeeded.' - COMMENT_FAILURE_MSG: ':x: Cypress test run failed.' + COMMENT_SUCCESS_MSG: ':white_check_mark: Cypress test run succeeded!' + COMMENT_FAILURE_MSG: ':x: Cypress test run failed!' jobs: test-add-comment: From 9d86579d590268de466d0ad45462750774d8c02b Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 10:07:18 +0000 Subject: [PATCH 13/23] use number Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 9a50af607ded..289b0173f925 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -61,7 +61,7 @@ jobs: const { data: pr } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: "${{ inputs.pr_number }}" + pull_number: ${{ inputs.pr_number }} }); const sourceRepo = pr.head.repo.full_name; From 3cb144ede59da0df6afec59a10b0efb3225ff20c Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 10:23:28 +0000 Subject: [PATCH 14/23] use json Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 289b0173f925..58062b378ec9 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -56,24 +56,18 @@ jobs: id: get_pr_info uses: actions/github-script@v6 with: - result-encoding: string script: | - const { data: pr } = await github.rest.pulls.get({ + await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: ${{ inputs.pr_number }} }); - const sourceRepo = pr.head.repo.full_name; - const sourceBranch = pr.head.ref; - const sourceJSON = `{ 'source': { 'repo': '${sourceRepo}', 'branch': '${sourceBranch}' } }`; - return sourceJSON; - - name: Set source branch from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ fromJSON(steps.get_pr_info.outputs.result.source.repo) }}" >> $GITHUB_ENV - echo "SOURCE_BRANCH=${{ fromJSON(steps.get_pr_info.outputs.result.source.branch) }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ fromJSON(steps.get_pr_info.outputs.result.head.repo.full_name) }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ fromJSON(steps.get_pr_info.outputs.result.head.ref) }}" >> $GITHUB_ENV - name: Find Comment uses: peter-evans/find-comment@v2 From 41db465587684a5c492ba461ef5f83e07afb860c Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 10:27:03 +0000 Subject: [PATCH 15/23] remove from json Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 58062b378ec9..77eea34db2d6 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -66,8 +66,8 @@ jobs: - name: Set source branch from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ fromJSON(steps.get_pr_info.outputs.result.head.repo.full_name) }}" >> $GITHUB_ENV - echo "SOURCE_BRANCH=${{ fromJSON(steps.get_pr_info.outputs.result.head.ref) }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.head.repo.full_name }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV - name: Find Comment uses: peter-evans/find-comment@v2 @@ -248,6 +248,6 @@ jobs: Test repo: `${{ env.TEST_REPO }}` Test branch: `${{ env.TEST_BRANCH }}` - Link to results: + #### Link to results: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} edit-mode: replace From a2054d779795afb3e15a1b22530c99bb178960ae Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 10:31:54 +0000 Subject: [PATCH 16/23] double quote Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 77eea34db2d6..6e180196f393 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -246,7 +246,7 @@ jobs: Source repo: `${{ env.SOURCE_REPO }}` Source branch: `${{ env.SOURCE_BRANCH }}` Test repo: `${{ env.TEST_REPO }}` - Test branch: `${{ env.TEST_BRANCH }}` + Test branch: ``${{ env.TEST_BRANCH }}`` #### Link to results: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} From a80ee928f63680d4e36faff04bade2f33540295b Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 10:49:54 +0000 Subject: [PATCH 17/23] fix body Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 6e180196f393..06c5e481fd02 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -115,24 +115,18 @@ jobs: id: get_pr_info uses: actions/github-script@v6 with: - result-encoding: string script: | - const { data: pr } = await github.rest.pulls.get({ + await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: "${{ inputs.pr_number }}" + pull_number: ${{ inputs.pr_number }} }); - const sourceRepo = pr.head.repo.full_name; - const sourceBranch = pr.head.ref; - const sourceJSON = `{ 'source': { 'repo': '${sourceRepo}', 'branch': '${sourceBranch}' } }`; - return sourceJSON; - - name: Set source branch from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ fromJSON(steps.get_pr_info.outputs.result.source.repo) }}" >> $GITHUB_ENV - echo "SOURCE_BRANCH=${{ fromJSON(steps.get_pr_info.outputs.result.source.branch) }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.head.repo.full_name }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV - run: | echo "Source repo: ${{ env.SOURCE_REPO }}" From e0becd3729d3d0dabd0a99802f2eab9b7b5961e3 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 11:00:11 +0000 Subject: [PATCH 18/23] consle Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 06c5e481fd02..00627240637f 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -57,11 +57,13 @@ jobs: uses: actions/github-script@v6 with: script: | - await github.rest.pulls.get({ + const result = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: ${{ inputs.pr_number }} }); + console.log(result); + return result; - name: Set source branch from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} From dfe0b1b9240b94a545decfe50e9d4f4ae5db9b29 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 11:13:45 +0000 Subject: [PATCH 19/23] split it Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 00627240637f..0fd237e3bb79 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -65,10 +65,14 @@ jobs: console.log(result); return result; + - name: Set source repo from PR number + if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} + run: | + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV + - name: Set source branch from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.head.repo.full_name }}" >> $GITHUB_ENV echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV - name: Find Comment @@ -124,10 +128,14 @@ jobs: pull_number: ${{ inputs.pr_number }} }); + - name: Set source repo from PR number + if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} + run: | + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV + - name: Set source branch from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.head.repo.full_name }}" >> $GITHUB_ENV echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV - run: | From a4cab381d98eacede5adb358b7ff5ae679547591 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 11:19:40 +0000 Subject: [PATCH 20/23] is it not a string Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 0fd237e3bb79..b5d0be1725d5 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -28,7 +28,7 @@ on: env: SOURCE_REPO: ${{ github.repository }} - SOURCE_BRANCH: ${{ github.base_ref }} + SOURCE_BRANCH: "${{ github.base_ref }}" TEST_REPO: ${{ inputs.test_repo != '' && inputs.test_repo || 'opensearch-project/opensearch-dashboards-functional-test' }} TEST_BRANCH: ${{ inputs.test_branch != '' && inputs.test_branch || github.base_ref }} FTR_PATH: 'ftr' @@ -68,7 +68,7 @@ jobs: - name: Set source repo from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.head.repo.full_name }}" >> $GITHUB_ENV - name: Set source branch from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} @@ -131,7 +131,7 @@ jobs: - name: Set source repo from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.head.repo.full_name }}" >> $GITHUB_ENV - name: Set source branch from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} From 9cf044468967f8a6ba6e4fb87ec32daa5aa94f6b Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 11:26:38 +0000 Subject: [PATCH 21/23] include data Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index b5d0be1725d5..880d5a023953 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -30,7 +30,7 @@ env: SOURCE_REPO: ${{ github.repository }} SOURCE_BRANCH: "${{ github.base_ref }}" TEST_REPO: ${{ inputs.test_repo != '' && inputs.test_repo || 'opensearch-project/opensearch-dashboards-functional-test' }} - TEST_BRANCH: ${{ inputs.test_branch != '' && inputs.test_branch || github.base_ref }} + TEST_BRANCH: "${{ inputs.test_branch != '' && inputs.test_branch || github.base_ref }}" FTR_PATH: 'ftr' START_CMD: 'node ../scripts/opensearch_dashboards --dev --no-base-path --no-watch' OPENSEARCH_SNAPSHOT_CMD: 'node ../scripts/opensearch snapshot' @@ -57,23 +57,17 @@ jobs: uses: actions/github-script@v6 with: script: | - const result = await github.rest.pulls.get({ + await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: ${{ inputs.pr_number }} }); - console.log(result); - return result; - name: Set source repo from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.head.repo.full_name }}" >> $GITHUB_ENV - - - name: Set source branch from PR number - if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} - run: | - echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.data.head.repo.full_name }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.data.head.ref }}" >> $GITHUB_ENV - name: Find Comment uses: peter-evans/find-comment@v2 @@ -131,12 +125,8 @@ jobs: - name: Set source repo from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.head.repo.full_name }}" >> $GITHUB_ENV - - - name: Set source branch from PR number - if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} - run: | - echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.head.ref }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.data.head.repo.full_name }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.data.head.ref }}" >> $GITHUB_ENV - run: | echo "Source repo: ${{ env.SOURCE_REPO }}" From bca03e37c4e9afe4301dd7fcd3b7247078a1a8b1 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 11:33:55 +0000 Subject: [PATCH 22/23] last try Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 880d5a023953..25a8965538a2 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -57,17 +57,18 @@ jobs: uses: actions/github-script@v6 with: script: | - await github.rest.pulls.get({ + const { data: result } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: ${{ inputs.pr_number }} }); + return result; - name: Set source repo from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.data.head.repo.full_name }}" >> $GITHUB_ENV - echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.data.head.ref }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.head.repo.full_name }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.head.ref }}" >> $GITHUB_ENV - name: Find Comment uses: peter-evans/find-comment@v2 @@ -116,17 +117,18 @@ jobs: uses: actions/github-script@v6 with: script: | - await github.rest.pulls.get({ + const { data: result } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: ${{ inputs.pr_number }} }); + return result; - name: Set source repo from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.result.data.head.repo.full_name }}" >> $GITHUB_ENV - echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.result.data.head.ref }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.head.repo.full_name }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.head.ref }}" >> $GITHUB_ENV - run: | echo "Source repo: ${{ env.SOURCE_REPO }}" From 9dfe41765592687b5e5c38314e3b81720644602a Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Wed, 27 Sep 2023 11:40:24 +0000 Subject: [PATCH 23/23] use core Signed-off-by: Kawika Avilla --- .github/workflows/cypress_workflow.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cypress_workflow.yml b/.github/workflows/cypress_workflow.yml index 25a8965538a2..6180edd50d1e 100644 --- a/.github/workflows/cypress_workflow.yml +++ b/.github/workflows/cypress_workflow.yml @@ -62,13 +62,14 @@ jobs: repo: context.repo.repo, pull_number: ${{ inputs.pr_number }} }); - return result; + core.setOutput('head_name', result.head.repo.full_name); + core.setOutput('head_ref', result.head.ref); - name: Set source repo from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.head.repo.full_name }}" >> $GITHUB_ENV - echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.head.ref }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.head_name }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.head_ref }}" >> $GITHUB_ENV - name: Find Comment uses: peter-evans/find-comment@v2 @@ -122,13 +123,14 @@ jobs: repo: context.repo.repo, pull_number: ${{ inputs.pr_number }} }); - return result; + core.setOutput('head_name', result.head.repo.full_name); + core.setOutput('head_ref', result.head.ref); - name: Set source repo from PR number if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} run: | - echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.head.repo.full_name }}" >> $GITHUB_ENV - echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.head.ref }}" >> $GITHUB_ENV + echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.head_name }}" >> $GITHUB_ENV + echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.head_ref }}" >> $GITHUB_ENV - run: | echo "Source repo: ${{ env.SOURCE_REPO }}"