From cb75361ceefbeaa98ad45a782c0ba7a0a5b0d777 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 11:51:24 +0100 Subject: [PATCH 01/31] Add workflow Added the first version of GHA workflow running workflow tests on opening and syncing of PRs See: https://github.com/Expensify/App/issues/13604 --- .../workflows/testGithubActionsWorkflows.yml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/testGithubActionsWorkflows.yml diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml new file mode 100644 index 000000000000..a7f86cee3b77 --- /dev/null +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -0,0 +1,27 @@ +name: Test GitHub Actions workflows + +on: + workflow_call: + pull_request: + types: [opened, reopened, synchronize] + branches-ignore: [staging, production] + paths: ['.github'] + +jobs: + testGHWorkflows: + if: ${{ github.actor != 'OSBotify' && github.actor != 'imgbot[bot]' || github.event_name == 'workflow_call' }} + runs-on: ubuntu-latest + env: + CI: true + strategy: + fail-fast: false + name: test GitHub Workflows + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main + + - name: Run tests + runs: npm run workflow-test From 62256f70092b557e8b82ae2094c4394bb184cade Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 11:52:51 +0100 Subject: [PATCH 02/31] Fix runs -> run See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index a7f86cee3b77..2a65b4fb4ffe 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -24,4 +24,4 @@ jobs: uses: Expensify/App/.github/actions/composite/setupNode@main - name: Run tests - runs: npm run workflow-test + run: npm run workflow-test From 6df5949c47b45f6b585368c241f0f94aa1ad29c1 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 11:55:12 +0100 Subject: [PATCH 03/31] Add trigger Added workflow_dispatch trigger See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 2a65b4fb4ffe..b871663b06b6 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -1,6 +1,7 @@ name: Test GitHub Actions workflows on: + workflow_dispatch: workflow_call: pull_request: types: [opened, reopened, synchronize] From 38f51dd8a7b24413b2592e8b240499443d12cd19 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 12:05:54 +0100 Subject: [PATCH 04/31] Update trigger Added PR event type of edited See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index b871663b06b6..17d1af433a89 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: workflow_call: pull_request: - types: [opened, reopened, synchronize] + types: [opened, reopened, edited, synchronize] branches-ignore: [staging, production] paths: ['.github'] From 9bb710e1f218ffb611286471c9f9973b3d047950 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 12:16:31 +0100 Subject: [PATCH 05/31] Add step Added step for Act installation See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 17d1af433a89..2e8046e47b1b 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -24,5 +24,8 @@ jobs: - name: Setup Node uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Install Act + run: brew install act + - name: Run tests run: npm run workflow-test From 4010b801fe7455c1de08085eef7c7db5b646fabd Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 12:21:26 +0100 Subject: [PATCH 06/31] Add step Added step for Homebrew installation See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 2e8046e47b1b..d8decc2c14da 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -24,6 +24,9 @@ jobs: - name: Setup Node uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Install Homebrew + run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + - name: Install Act run: brew install act From 28cb3bff429e921cf03536f9d7b3440f26a8828a Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 12:27:24 +0100 Subject: [PATCH 07/31] Update step Updated step for Homebrew installation with post install commands See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index d8decc2c14da..2611a15d3c81 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -25,7 +25,11 @@ jobs: uses: Expensify/App/.github/actions/composite/setupNode@main - name: Install Homebrew - run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + run: | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/runner/.bashrc + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + sudo apt-get install build-essential - name: Install Act run: brew install act From e40c556913003c06ee24457daaf3a2100eaa8262 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 13:40:54 +0100 Subject: [PATCH 08/31] Update step Added some debug echoes See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 2611a15d3c81..9b7909c6e7c4 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -27,9 +27,11 @@ jobs: - name: Install Homebrew run: | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + echo "Test" (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/runner/.bashrc eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" sudo apt-get install build-essential + echo "Homebrew installed" - name: Install Act run: brew install act From 0cca425c9721870855ee95589572843e86af5a59 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 13:48:54 +0100 Subject: [PATCH 09/31] Update step Found existing Homebrew setup step See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 9b7909c6e7c4..429ed874bb76 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -24,14 +24,8 @@ jobs: - name: Setup Node uses: Expensify/App/.github/actions/composite/setupNode@main - - name: Install Homebrew - run: | - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - echo "Test" - (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/runner/.bashrc - eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - sudo apt-get install build-essential - echo "Homebrew installed" + - name: Setup Homebrew + uses: Homebrew/actions/setup-homebrew@master - name: Install Act run: brew install act From 33d29b6c66996dc42de0c94ae90aef3dfef463b5 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 13:54:32 +0100 Subject: [PATCH 10/31] Add step Added step for setting the ACT_BINARY env variable See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 429ed874bb76..387be65d1afc 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -30,5 +30,8 @@ jobs: - name: Install Act run: brew install act + - name: Set ACT_BINARY + run: export ACT_BINARY="$(which act)" + - name: Run tests run: npm run workflow-test From 6cd203e20e2441114150ed0ef0cb39b0cb251b82 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 14:00:29 +0100 Subject: [PATCH 11/31] Update step Updated step for setting the ACT_BINARY to use the way proposed by GHA See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 387be65d1afc..9b69364c2cb0 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -31,7 +31,7 @@ jobs: run: brew install act - name: Set ACT_BINARY - run: export ACT_BINARY="$(which act)" + run: echo "ACT_BINARY=$(which act)" >> $GITHUB_ENV - name: Run tests run: npm run workflow-test From d45567959342b33329311097ce7194a02eda09f0 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 14:07:19 +0100 Subject: [PATCH 12/31] Update step Updated step for running tests with debug echoes to get into what is the working dir See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 9b69364c2cb0..ab7eb6b5a4a0 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -34,4 +34,7 @@ jobs: run: echo "ACT_BINARY=$(which act)" >> $GITHUB_ENV - name: Run tests - run: npm run workflow-test + run: | + echo "$(pwd)" + echo "$(ls)" + npm run workflow-test From ac5632f7d1ffb40753c9021ae5db303db20c1d70 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 7 Nov 2023 14:36:28 +0100 Subject: [PATCH 13/31] Update step Updated step for running tests by removing debug echoes See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index ab7eb6b5a4a0..9b69364c2cb0 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -34,7 +34,4 @@ jobs: run: echo "ACT_BINARY=$(which act)" >> $GITHUB_ENV - name: Run tests - run: | - echo "$(pwd)" - echo "$(ls)" - npm run workflow-test + run: npm run workflow-test From a08af4fc629a27fecdeabe7ea3101bc6248ffb2e Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 11:21:58 +0100 Subject: [PATCH 14/31] Fix tests Fixed tests for preDeploy after two of the jobs have been removed See: https://github.com/Expensify/App/issues/13604 --- .../assertions/preDeployAssertions.js | 87 ------ workflow_tests/mocks/preDeployMocks.js | 98 ------ workflow_tests/preDeploy.test.js | 292 ------------------ 3 files changed, 477 deletions(-) diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index 90d6f9febb75..1ed7d52bd53f 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -36,91 +36,6 @@ const assertTestJobExecuted = (workflowResult, didExecute = true) => { }); }; -const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion('Get merged pull request', true, null, 'IS_EXPENSIFY_EMPLOYEE', 'Getting merged pull request', [{key: 'github_token', value: '***'}]), - utils.createStepAssertion( - 'Check whether the PR author is member of Expensify/expensify team', - true, - null, - 'IS_EXPENSIFY_EMPLOYEE', - 'Checking actors Expensify membership', - [], - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - ]; - - steps.forEach((expectedStep) => { - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); - } - }); -}; - -const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecute = true, isOsBotify = false, isFirstPr = false) => { - const steps = [ - utils.createStepAssertion('Checkout', true, null, 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', 'Checking out', [{key: 'token', value: '***'}]), - utils.createStepAssertion('Get merged pull request', true, null, 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', 'Getting merged pull request', [{key: 'github_token', value: '***'}]), - utils.createStepAssertion(isOsBotify ? 'Get PR count for OSBotify' : 'Get PR count for Dummy Author', true, null, 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', 'Getting PR count', [ - {key: 'GITHUB_TOKEN', value: '***'}, - ]), - ]; - const osBotifyBody = - '@OSBotify, Great job getting your first Expensify/App pull request over the finish line! ' + - ":tada:\n\nI know there's a lot of information in our " + - '[contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), ' + - 'so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be ' + - "hired for another issue. Once you've completed a few issues, you may be eligible to work on more than one " + - 'job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) ' + - "testing. If we find that it doesn't work as expected or causes a regression, you'll be responsible for " + - 'fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without ' + - 'causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. ' + - 'After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. ' + - ":moneybag:\n\nSo it might take a while before you're paid for your work, but we typically post multiple " + - "new jobs every day, so there's plenty of opportunity. I hope you've had a positive experience " + - 'contributing to this repo! :blush:'; - const userBody = - '@Dummy Author, Great job getting your first Expensify/App pull request over the finish ' + - "line! :tada:\n\nI know there's a lot of information in our " + - '[contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), ' + - 'so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be ' + - "hired for another issue. Once you've completed a few issues, you may be eligible to work on more than one " + - 'job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) ' + - "testing. If we find that it doesn't work as expected or causes a regression, you'll be responsible for " + - 'fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without ' + - 'causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. ' + - 'After it has been on production for 7 days without causing any regressions, then we pay out the Upwork ' + - "job. :moneybag:\n\nSo it might take a while before you're paid for your work, but we typically post " + - "multiple new jobs every day, so there's plenty of opportunity. I hope you've had a positive experience " + - 'contributing to this repo! :blush:'; - if (isFirstPr) { - steps.push( - utils.createStepAssertion( - isOsBotify ? "Comment on OSBotify\\'s first pull request!" : "Comment on Dummy Author\\'s first pull request!", - true, - null, - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - 'Creating comment', - [ - {key: 'github_token', value: '***'}, - {key: 'number', value: '12345'}, - {key: 'body', value: isOsBotify ? osBotifyBody : userBody}, - ], - ), - ); - } - - steps.forEach((expectedStep) => { - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); - } - }); -}; - const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ utils.createStepAssertion('Get merged pull request', true, null, 'CHOOSE_DEPLOY_ACTIONS', 'Getting merged pull request', [{key: 'github_token', value: '***'}]), @@ -209,8 +124,6 @@ module.exports = { assertTypecheckJobExecuted, assertLintJobExecuted, assertTestJobExecuted, - assertIsExpensifyEmployeeJobExecuted, - assertNewContributorWelcomeMessageJobExecuted, assertChooseDeployActionsJobExecuted, assertSkipDeployJobExecuted, assertCreateNewVersionJobExecuted, diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index 3dc67a904cf9..daadf3d0c743 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -86,99 +86,6 @@ const UPDATE_STAGING_JOB_MOCK_STEPS = [ ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP, ]; -// is_expensify_employee -const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = utils.createMockStep( - 'Get merged pull request', - 'Getting merged pull request', - 'IS_EXPENSIFY_EMPLOYEE', - ['github_token'], - null, - {author: 'Dummy Author'}, -); -const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = utils.createMockStep( - 'Check whether the PR author is member of Expensify/expensify team', - 'Checking actors Expensify membership', - 'IS_EXPENSIFY_EMPLOYEE', - [], - ['GITHUB_TOKEN'], - {IS_EXPENSIFY_EMPLOYEE: true}, -); -const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE]; -const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = utils.createMockStep( - 'Check whether the PR author is member of Expensify/expensify team', - 'Checking actors Expensify membership', - 'IS_EXPENSIFY_EMPLOYEE', - [], - ['GITHUB_TOKEN'], - {IS_EXPENSIFY_EMPLOYEE: false}, -); -const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE]; - -// new_contributor_welcome_message -const CHECKOUT_MOCK_STEP = utils.createMockStep('Checkout', 'Checking out', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', ['token'], null, {author: 'Dummy Author'}); -const CHECKOUT_MOCK_STEP__OSBOTIFY = utils.createMockStep('Checkout', 'Checking out', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', ['token'], null, {author: 'OSBotify'}); -const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = utils.createMockStep( - 'Get merged pull request', - 'Getting merged pull request', - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - ['github_token'], - null, - {number: '12345', author: 'Dummy Author'}, -); -const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY = utils.createMockStep( - 'Get merged pull request', - 'Getting merged pull request', - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - ['github_token'], - null, - {number: '12345', author: 'OSBotify'}, -); -const GET_PR_COUNT_MOCK_STEP__1 = utils.createMockStep( - // eslint-disable-next-line no-template-curly-in-string - 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', - 'Getting PR count', - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - null, - ['GITHUB_TOKEN'], - null, - {PR_COUNT: '1'}, -); -const GET_PR_COUNT_MOCK_STEP__10 = utils.createMockStep( - // eslint-disable-next-line no-template-curly-in-string - 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', - 'Getting PR count', - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - null, - ['GITHUB_TOKEN'], - null, - {PR_COUNT: '10'}, -); -const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = utils.createMockStep( - // eslint-disable-next-line no-template-curly-in-string - "Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\'s first pull request!", - 'Creating comment', - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - ['github_token', 'number', 'body'], -); -const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS = [ - CHECKOUT_MOCK_STEP, - GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, - GET_PR_COUNT_MOCK_STEP__10, - COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, -]; -const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR = [ - CHECKOUT_MOCK_STEP, - GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, - GET_PR_COUNT_MOCK_STEP__1, - COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, -]; -const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY = [ - CHECKOUT_MOCK_STEP__OSBOTIFY, - GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY, - GET_PR_COUNT_MOCK_STEP__10, - COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, -]; - const PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP = utils.createMockStep('Perform E2E tests', 'Perform E2E tests', 'E2EPERFORMANCETESTS'); const PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS = [PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP]; @@ -192,10 +99,5 @@ module.exports = { SKIP_DEPLOY_JOB_MOCK_STEPS, CREATE_NEW_VERSION_JOB_MOCK_STEPS, UPDATE_STAGING_JOB_MOCK_STEPS, - IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, - NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR, - NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 4a4d9dcc82bb..0d5b126b4430 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -68,8 +68,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { typecheck: { @@ -112,7 +110,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); @@ -128,8 +125,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { typecheck: { @@ -180,7 +175,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result, false); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); - assertions.assertIsExpensifyEmployeeJobExecuted(result, false); assertions.assertChooseDeployActionsJobExecuted(result, false); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -208,7 +202,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result, false); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); - assertions.assertIsExpensifyEmployeeJobExecuted(result, false); assertions.assertChooseDeployActionsJobExecuted(result, false); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -236,8 +229,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { typecheck: { @@ -277,7 +268,6 @@ describe('test workflow preDeploy', () => { ); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); expect(result).toEqual( expect.arrayContaining([ utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'CONFIRM_PASSING_BUILD', 'Announcing failed workflow in slack', [ @@ -312,8 +302,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { typecheck: { @@ -351,7 +339,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result); expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run lint workflow', false, null, 'LINT', 'Running lint workflow - Lint workflow failed')])); assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); expect(result).toEqual( expect.arrayContaining([ utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'CONFIRM_PASSING_BUILD', 'Announcing failed workflow in slack', [ @@ -386,8 +373,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { typecheck: { @@ -425,7 +410,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run test workflow', false, null, 'TEST', 'Running test workflow - Test workflow failed')])); - assertions.assertIsExpensifyEmployeeJobExecuted(result); expect(result).toEqual( expect.arrayContaining([ utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'CONFIRM_PASSING_BUILD', 'Announcing failed workflow in slack', [ @@ -460,8 +444,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { typecheck: { @@ -499,7 +481,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); @@ -507,264 +488,6 @@ describe('test workflow preDeploy', () => { }); }); - describe('new contributor welcome message', () => { - it('actor is OSBotify - no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, - }; - const testMockJobs = { - typecheck: { - steps: mocks.TYPECHECK_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - lint: { - steps: mocks.LINT_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - test: { - steps: mocks.TEST_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertTypecheckJobExecuted(result); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertNewContributorWelcomeMessageJobExecuted(result, false); - }); - - it('actor is Expensify employee - no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - }; - const testMockJobs = { - typecheck: { - steps: mocks.TYPECHECK_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - lint: { - steps: mocks.LINT_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - test: { - steps: mocks.TEST_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertTypecheckJobExecuted(result); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertNewContributorWelcomeMessageJobExecuted(result, false); - }); - - it('actor is not Expensify employee, its not their first PR - job triggers, but no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - }; - const testMockJobs = { - typecheck: { - steps: mocks.TYPECHECK_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - lint: { - steps: mocks.LINT_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - test: { - steps: mocks.TEST_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertTypecheckJobExecuted(result); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertNewContributorWelcomeMessageJobExecuted(result, true, false, false); - }); - - it('actor is not Expensify employee, and its their first PR - job triggers and comment left', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR, - }; - const testMockJobs = { - typecheck: { - steps: mocks.TYPECHECK_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - lint: { - steps: mocks.LINT_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - test: { - steps: mocks.TEST_JOB_MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-latest', - }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertTypecheckJobExecuted(result); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertNewContributorWelcomeMessageJobExecuted(result, true, false, true); - }); - }); - describe('choose deploy actions', () => { describe('staging locked', () => { it('not automated PR - deploy skipped and comment left', async () => { @@ -777,8 +500,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { typecheck: { @@ -816,7 +537,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -834,8 +554,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, }; const testMockJobs = { typecheck: { @@ -873,7 +591,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -903,8 +620,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { typecheck: { @@ -942,7 +657,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); @@ -969,8 +683,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, }; const testMockJobs = { typecheck: { @@ -1008,7 +720,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -1037,8 +748,6 @@ describe('test workflow preDeploy', () => { chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; testMockSteps.updateStaging[3].mockWith = 'exit 1'; const testMockJobs = { @@ -1077,7 +786,6 @@ describe('test workflow preDeploy', () => { assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); From a6dafa666291ac47fd9c13753da827e7fe43ac70 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 11:35:24 +0100 Subject: [PATCH 15/31] Fix tests Fixed tests for testBuild after one of the messages have been updated See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/testBuildAssertions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index a4f7a46259ad..f65349593faa 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -365,7 +365,7 @@ const assertPostGithubCommentJobExecuted = ( 'maintain-comment', [ {key: 'token', value: '***'}, - {key: 'body-include', value: 'Use the links below to test this build in android and iOS. Happy testing!'}, + {key: 'body-include', value: 'Use the links below to test this adhoc build in Android, iOS, Desktop, and Web. Happy testing!'}, {key: 'number', value: pullRequestNumber}, {key: 'delete', value: true}, ], From a68fb46c268c2e14a7f62432e70f20586c249963 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 11:42:31 +0100 Subject: [PATCH 16/31] Fix tests Fixed tests for cherryPick after the way github token is passed to a step has changed See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/cherryPickAssertions.js | 2 +- workflow_tests/mocks/cherryPickMocks.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow_tests/assertions/cherryPickAssertions.js b/workflow_tests/assertions/cherryPickAssertions.js index 42ecc3d64262..1fe1194cf7b6 100644 --- a/workflow_tests/assertions/cherryPickAssertions.js +++ b/workflow_tests/assertions/cherryPickAssertions.js @@ -76,7 +76,7 @@ const assertCherryPickJobExecuted = (workflowResult, user = 'Dummy Author', pull 'CHERRYPICK', 'Creating Pull Request to manually finish CP', [], - [{key: 'GITHUB_TOKEN', value: '***'}], + [{key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}], ), ]; diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index 778e6fd48ded..8531d9783172 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -36,7 +36,7 @@ const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [CHERRYPICK__CREATENEWVERSION__ // cherrypick const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'CHERRYPICK', ['ref', 'token'], []); -const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep('Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], []); +const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep('Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], [], {OS_BOTIFY_API_TOKEN: 'os_botify_api_token'}); const CHERRYPICK__CHERRYPICK__GET_PREVIOUS_APP_VERSION__STEP_MOCK = utils.createMockStep('Get previous app version', 'Get previous app version', 'CHERRYPICK', ['SEMVER_LEVEL']); const CHERRYPICK__CHERRYPICK__FETCH_HISTORY_OF_RELEVANT_REFS__STEP_MOCK = utils.createMockStep('Fetch history of relevant refs', 'Fetch history of relevant refs', 'CHERRYPICK'); const CHERRYPICK__CHERRYPICK__GET_VERSION_BUMP_COMMIT__STEP_MOCK = utils.createMockStep('Get version bump commit', 'Get version bump commit', 'CHERRYPICK', [], [], { From 8ae79877f3c2298374c9851beb47731f8b3cc097 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 11:51:52 +0100 Subject: [PATCH 17/31] Fix tests Fixed tests for platformDeploy after 2 new steps have been added See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/platformDeployAssertions.js | 10 +++++++++- workflow_tests/mocks/platformDeployMocks.js | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 35242cd24d31..63b5b11ba1ab 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -63,6 +63,10 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio ); if (!isProduction) { steps.push( + utils.createStepAssertion('Upload Android version to GitHub artifacts', true, null, 'ANDROID', 'Upload Android version to GitHub artifacts', [ + {key: 'name', value: 'app-production-release.aab'}, + {key: 'path', value: 'android/app/build/outputs/bundle/productionRelease/app-production-release.aab'}, + ]), utils.createStepAssertion('Upload Android version to Browser Stack', true, null, 'ANDROID', 'Uploading Android version to Browser Stack', null, [ {key: 'BROWSERSTACK', value: '***'}, ]), @@ -183,7 +187,11 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = ]), ); if (!isProduction) { - steps.push(utils.createStepAssertion('Upload iOS version to Browser Stack', true, null, 'IOS', 'Uploading version to Browser Stack', null, [{key: 'BROWSERSTACK', value: '***'}])); + steps.push( + utils.createStepAssertion('Upload iOS version to GitHub artifacts', true, null, 'IOS', 'Upload iOS version to GitHub artifacts', [ + {key: 'name', value: 'New Expensify.ipa'}, + {key: 'path', value: '/Users/runner/work/App/App/New Expensify.ipa'}, + ]), utils.createStepAssertion('Upload iOS version to Browser Stack', true, null, 'IOS', 'Uploading version to Browser Stack', null, [{key: 'BROWSERSTACK', value: '***'}])); } else { steps.push( utils.createStepAssertion('Set iOS version in ENV', true, null, 'IOS', 'Setting iOS version'), diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 9e0b91b29156..d660d057259d 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -51,6 +51,7 @@ const PLATFORM_DEPLOY__ANDROID__FASTLANE_BETA__STEP_MOCK = utils.createMockStep( ]); const PLATFORM_DEPLOY__ANDROID__FASTLANE_PRODUCTION__STEP_MOCK = utils.createMockStep('Run Fastlane production', 'Running Fastlane production', 'ANDROID', null, ['VERSION']); const PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep('Archive Android sourcemaps', 'Archiving Android sourcemaps', 'ANDROID', ['name', 'path']); +const PLATFORM_DEPLOY__ANDROID__UPLOAD_ANDROID_VERSION_TO_GITHUB_ARTIFACTS__STEP_MOCK = utils.createMockStep('Upload Android version to GitHub artifacts', 'Upload Android version to GitHub artifacts', 'ANDROID', ['name', 'path']); const PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_BROWSER_STACK__STEP_MOCK = utils.createMockStep( 'Upload Android version to Browser Stack', 'Uploading Android version to Browser Stack', @@ -76,6 +77,7 @@ const PLATFORM_DEPLOY__ANDROID__STEP_MOCKS = [ PLATFORM_DEPLOY__ANDROID__FASTLANE_BETA__STEP_MOCK, PLATFORM_DEPLOY__ANDROID__FASTLANE_PRODUCTION__STEP_MOCK, PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__UPLOAD_ANDROID_VERSION_TO_GITHUB_ARTIFACTS__STEP_MOCK, PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_BROWSER_STACK__STEP_MOCK, PLATFORM_DEPLOY__ANDROID__WARN_DEPLOYERS__STEP_MOCK, ]; @@ -139,6 +141,7 @@ const PLATFORM_DEPLOY__IOS__FASTLANE__STEP_MOCK = utils.createMockStep('Run Fast 'APPLE_DEMO_PASSWORD', ]); const PLATFORM_DEPLOY__IOS__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep('Archive iOS sourcemaps', 'Archiving sourcemaps', 'IOS', ['name', 'path']); +const PLATFORM_DEPLOY__IOS__UPLOAD_IOS_VERSION_TO_GITHUB_ARTIFACTS__STEP_MOCK = utils.createMockStep('Upload iOS version to GitHub artifacts', 'Upload iOS version to GitHub artifacts', 'IOS', ['name', 'path']); const PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK = utils.createMockStep('Upload iOS version to Browser Stack', 'Uploading version to Browser Stack', 'IOS', null, ['BROWSERSTACK']); const PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK = utils.createMockStep('Set iOS version in ENV', 'Setting iOS version', 'IOS', null, null, null, {IOS_VERSION: '1.2.3'}); const PLATFORM_DEPLOY__IOS__RELEASE_FASTLANE__STEP_MOCK = utils.createMockStep('Run Fastlane for App Store release', 'Running Fastlane for release', 'IOS', null, ['VERSION']); @@ -162,6 +165,7 @@ const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ PLATFORM_DEPLOY__IOS__DECRYPT_APP_STORE_API_KEY__STEP_MOCK, PLATFORM_DEPLOY__IOS__FASTLANE__STEP_MOCK, PLATFORM_DEPLOY__IOS__ARCHIVE_SOURCEMAPS__STEP_MOCK, + PLATFORM_DEPLOY__IOS__UPLOAD_IOS_VERSION_TO_GITHUB_ARTIFACTS__STEP_MOCK, PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK, PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK, PLATFORM_DEPLOY__IOS__RELEASE_FASTLANE__STEP_MOCK, From 498cffc25d10d0a01d221cda37ec3879f9ff5933 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 12:21:49 +0100 Subject: [PATCH 18/31] Fix tests Fixed tests for finishReleaseCycle after 2 new steps have been added and the way the token is passed has changed See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/finishReleaseCycle.yml | 3 +- .../finishReleaseCycleAssertions.js | 11 ++++--- workflow_tests/finishReleaseCycle.test.js | 31 +++++++------------ .../mocks/finishReleaseCycleMocks.js | 22 +++++++++++++ 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/.github/workflows/finishReleaseCycle.yml b/.github/workflows/finishReleaseCycle.yml index f8b68786aaab..8391204fac54 100644 --- a/.github/workflows/finishReleaseCycle.yml +++ b/.github/workflows/finishReleaseCycle.yml @@ -18,7 +18,8 @@ jobs: ref: main token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab + - name: Setup Git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab id: setupGitForOSBotify with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} diff --git a/workflow_tests/assertions/finishReleaseCycleAssertions.js b/workflow_tests/assertions/finishReleaseCycleAssertions.js index 12a8b9f2b05d..96c473fca917 100644 --- a/workflow_tests/assertions/finishReleaseCycleAssertions.js +++ b/workflow_tests/assertions/finishReleaseCycleAssertions.js @@ -1,7 +1,10 @@ const utils = require('../utils/utils'); const assertValidateJobExecuted = (workflowResult, issueNumber = '', didExecute = true, isTeamMember = true, hasBlockers = false, isSuccessful = true) => { - const steps = [utils.createStepAssertion('Validate actor is deployer', true, null, 'VALIDATE', 'Validating if actor is deployer', [], [{key: 'GITHUB_TOKEN', value: '***'}])]; + const steps = [ + utils.createStepAssertion('Checkout', true, null, 'VALIDATE', 'Checkout', [{key: 'ref', value: 'main'}, {key: 'token', value: '***'}]), + utils.createStepAssertion('Setup Git for OSBotify', true, null, 'VALIDATE', 'Setup Git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}, {key: 'OS_BOTIFY_APP_ID', value: '***'}, {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}]), + utils.createStepAssertion('Validate actor is deployer', true, null, 'VALIDATE', 'Validating if actor is deployer', [], [{key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}])]; if (isTeamMember) { steps.push( utils.createStepAssertion( @@ -11,7 +14,7 @@ const assertValidateJobExecuted = (workflowResult, issueNumber = '', didExecute 'VALIDATE', 'Checking for deploy blockers', [ - {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}, {key: 'ISSUE_NUMBER', value: issueNumber}, ], [], @@ -36,7 +39,7 @@ const assertValidateJobExecuted = (workflowResult, issueNumber = '', didExecute 'VALIDATE', 'Reopening issue - not a team member', [ - {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}, {key: 'ISSUE_NUMBER', value: issueNumber}, {key: 'COMMENT', value: 'Sorry, only members of @Expensify/Mobile-Deployers can close deploy checklists.\nReopening!'}, ], @@ -60,7 +63,7 @@ const assertValidateJobExecuted = (workflowResult, issueNumber = '', didExecute 'VALIDATE', 'Reopening issue - blockers', [ - {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}, {key: 'ISSUE_NUMBER', value: issueNumber}, ], [], diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index 7c17ca8d4122..26b4d2f60afc 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -38,6 +38,13 @@ describe('test workflow finishReleaseCycle', () => { afterEach(async () => { await mockGithub.teardown(); }); + const secrets = { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + OS_BOTIFY_APP_ID: 'os_botify_app_id', + OS_BOTIFY_PRIVATE_KEY: 'os_botify_private_key', + }; describe('issue closed', () => { describe('issue has StagingDeployCash', () => { describe('actor is a team member', () => { @@ -57,11 +64,7 @@ describe('test workflow finishReleaseCycle', () => { number: '1234', }, }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, + secrets, ); const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, @@ -107,11 +110,7 @@ describe('test workflow finishReleaseCycle', () => { number: '1234', }, }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, + secrets, ); const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS, @@ -158,11 +157,7 @@ describe('test workflow finishReleaseCycle', () => { number: '1234', }, }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, + secrets, ); const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, @@ -209,11 +204,7 @@ describe('test workflow finishReleaseCycle', () => { number: '1234', }, }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, + secrets, ); const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.js b/workflow_tests/mocks/finishReleaseCycleMocks.js index e1bb0d112429..551105705992 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.js +++ b/workflow_tests/mocks/finishReleaseCycleMocks.js @@ -1,6 +1,20 @@ const utils = require('../utils/utils'); // validate +const FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK = utils.createMockStep( + 'Checkout', + 'Checkout', + 'VALIDATE', + ['ref', 'token'], +); +const FINISHRELEASECYCLE__VALIDATE__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( + 'Setup Git for OSBotify', + 'Setup Git for OSBotify', + 'VALIDATE', + ['GPG_PASSPHRASE', 'OS_BOTIFY_APP_ID', 'OS_BOTIFY_PRIVATE_KEY'], + [], + {OS_BOTIFY_API_TOKEN: 'os_botify_api_token'}, +); const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK = utils.createMockStep( 'Validate actor is deployer', 'Validating if actor is deployer', @@ -56,6 +70,8 @@ const FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK [], ); const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ + FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK, @@ -63,6 +79,8 @@ const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, ]; const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ + FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK, @@ -71,6 +89,8 @@ const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ ]; // eslint-disable-next-line rulesdir/no-negated-variables const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ + FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_FALSE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK, @@ -79,6 +99,8 @@ const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ ]; // eslint-disable-next-line rulesdir/no-negated-variables const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ + FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_FALSE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK, From 214a772209441ad9022ab2463547e746a14c8529 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 12:30:02 +0100 Subject: [PATCH 19/31] Fix tests Fixed tests for createNewVersion after new secrets have been added and the way the token is passed has changed See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/createNewVersionAssertions.js | 4 ++-- workflow_tests/createNewVersion.test.js | 4 +++- workflow_tests/mocks/createNewVersionMocks.js | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/workflow_tests/assertions/createNewVersionAssertions.js b/workflow_tests/assertions/createNewVersionAssertions.js index e4526ae59be2..3356cb0eef4c 100644 --- a/workflow_tests/assertions/createNewVersionAssertions.js +++ b/workflow_tests/assertions/createNewVersionAssertions.js @@ -26,7 +26,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' ], [], ), - utils.createStepAssertion('Setup git for OSBotify', true, null, 'CREATENEWVERSION', 'Setup git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'CREATENEWVERSION', 'Setup git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}, {key: 'OS_BOTIFY_APP_ID', value: '***'}, {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}], []), utils.createStepAssertion( 'Generate version', true, @@ -34,7 +34,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' 'CREATENEWVERSION', 'Generate version', [ - {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}, {key: 'SEMVER_LEVEL', value: semverLevel}, ], [], diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index 259e06450325..dca1afbd9a41 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -46,8 +46,10 @@ describe('test workflow createNewVersion', () => { }; const secrets = { LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - OS_BOTIFY_TOKEN: 'dummy_osbotify_token', + OS_BOTIFY_COMMIT_TOKEN: 'dummy_osbotify_commit_token', SLACK_WEBHOOK: 'dummy_webhook', + OS_BOTIFY_APP_ID: 'os_botify_app_id', + OS_BOTIFY_PRIVATE_KEY: 'os_botify_private_key', }; const githubToken = 'dummy_github_token'; diff --git a/workflow_tests/mocks/createNewVersionMocks.js b/workflow_tests/mocks/createNewVersionMocks.js index a1f601aef47f..5e82e2102ef0 100644 --- a/workflow_tests/mocks/createNewVersionMocks.js +++ b/workflow_tests/mocks/createNewVersionMocks.js @@ -21,8 +21,9 @@ const CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = ut 'Setup git for OSBotify', 'Setup git for OSBotify', 'CREATENEWVERSION', - ['GPG_PASSPHRASE'], + ['GPG_PASSPHRASE', 'OS_BOTIFY_APP_ID', 'OS_BOTIFY_PRIVATE_KEY'], [], + {OS_BOTIFY_API_TOKEN: 'os_botify_api_token'}, ); const CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK = utils.createMockStep( 'Generate version', From 6721a95de657c38ed5eb463687c32e3a8ce63b83 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 14:00:00 +0100 Subject: [PATCH 20/31] Fix tests Fixed tests for deploy after new secrets have been added and the way the token is passed has changed See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/deploy.yml | 6 ++-- workflow_tests/assertions/deployAssertions.js | 8 ++--- workflow_tests/deploy.test.js | 32 +++++++------------ workflow_tests/mocks/deployMocks.js | 4 +-- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 78040f237689..6b1bb42e8ace 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,7 +15,8 @@ jobs: ref: staging token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab + - name: Setup git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab id: setupGitForOSBotify with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} @@ -38,7 +39,8 @@ jobs: ref: production token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab + - name: Setup git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotifyApp@8c19d6da4a3d7ce3b15c9cd89a802187d208ecab id: setupGitForOSBotify with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js index bff99298bde5..47f8b06d66b4 100644 --- a/workflow_tests/assertions/deployAssertions.js +++ b/workflow_tests/assertions/deployAssertions.js @@ -6,7 +6,7 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { {key: 'ref', value: 'staging'}, {key: 'token', value: '***'}, ]), - utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_STAGING', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_STAGING', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}, {key: 'OS_BOTIFY_APP_ID', value: '***'}, {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}]), utils.createStepAssertion('Tag version', true, null, 'DEPLOY_STAGING', 'Tagging new version'), utils.createStepAssertion('🚀 Push tags to trigger staging deploy 🚀', true, null, 'DEPLOY_STAGING', 'Pushing tag to trigger staging deploy'), ]; @@ -26,11 +26,11 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => {key: 'ref', value: 'production'}, {key: 'token', value: '***'}, ]), - utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_PRODUCTION', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_PRODUCTION', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}, {key: 'OS_BOTIFY_APP_ID', value: '***'}, {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}]), utils.createStepAssertion('Get current app version', true, null, 'DEPLOY_PRODUCTION', 'Getting current app version'), utils.createStepAssertion('Get Release Pull Request List', true, null, 'DEPLOY_PRODUCTION', 'Getting release PR list', [ {key: 'TAG', value: '1.2.3'}, - {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}, {key: 'IS_PRODUCTION_DEPLOY', value: 'true'}, ]), utils.createStepAssertion('Generate Release Body', true, null, 'DEPLOY_PRODUCTION', 'Generating release body', [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}]), @@ -44,7 +44,7 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => {key: 'tag_name', value: '1.2.3'}, {key: 'body', value: 'Release body'}, ], - [{key: 'GITHUB_TOKEN', value: '***'}], + [{key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}], ), ]; diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index a2ccdebc0b31..4c730050a203 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -39,6 +39,13 @@ describe('test workflow deploy', () => { afterEach(async () => { await mockGithub.teardown(); }); + + const secrets = { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_APP_ID: 'os_botify_app_id', + OS_BOTIFY_PRIVATE_KEY: 'os_botify_private_key', + }; describe('push', () => { it('to main - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; @@ -50,10 +57,7 @@ describe('test workflow deploy', () => { { ref: 'refs/heads/main', }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, + secrets, 'dummy_github_token', ); const testMockSteps = { @@ -80,10 +84,7 @@ describe('test workflow deploy', () => { { ref: 'refs/heads/staging', }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, + secrets, 'dummy_github_token', ); const testMockSteps = { @@ -110,10 +111,7 @@ describe('test workflow deploy', () => { { ref: 'refs/heads/production', }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, + secrets, 'dummy_github_token', ); const testMockSteps = { @@ -145,10 +143,7 @@ describe('test workflow deploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, + secrets, 'dummy_github_token', ); let result = await act.runEvent('pull_request', { @@ -165,10 +160,7 @@ describe('test workflow deploy', () => { act, 'workflow_dispatch', {}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, + secrets, 'dummy_github_token', ); result = await act.runEvent('workflow_dispatch', { diff --git a/workflow_tests/mocks/deployMocks.js b/workflow_tests/mocks/deployMocks.js index dfec48ca7dc3..5f8f00828e9b 100644 --- a/workflow_tests/mocks/deployMocks.js +++ b/workflow_tests/mocks/deployMocks.js @@ -1,13 +1,13 @@ const utils = require('../utils/utils'); const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'DEPLOY_STAGING', ['ref', 'token']); -const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_STAGING', ['GPG_PASSPHRASE']); +const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_STAGING', ['GPG_PASSPHRASE', 'OS_BOTIFY_APP_ID', 'OS_BOTIFY_PRIVATE_KEY']); const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = utils.createMockStep('Tag version', 'Tagging new version', 'DEPLOY_STAGING'); const DEPLOY_STAGING__PUSH_TAG__STEP_MOCK = utils.createMockStep('🚀 Push tags to trigger staging deploy 🚀', 'Pushing tag to trigger staging deploy', 'DEPLOY_STAGING'); const DEPLOY_STAGING_STEP_MOCKS = [DEPLOY_STAGING__CHECKOUT__STEP_MOCK, DEPLOY_STAGING__SETUP_GIT__STEP_MOCK, DEPLOY_STAGING__TAG_VERSION__STEP_MOCK, DEPLOY_STAGING__PUSH_TAG__STEP_MOCK]; const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'DEPLOY_PRODUCTION', ['ref', 'token']); -const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_PRODUCTION', ['GPG_PASSPHRASE']); +const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_PRODUCTION', ['GPG_PASSPHRASE', 'OS_BOTIFY_APP_ID', 'OS_BOTIFY_PRIVATE_KEY'], null, {OS_BOTIFY_API_TOKEN: 'os_botify_api_token'}); const DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK = utils.createMockStep('Get current app version', 'Getting current app version', 'DEPLOY_PRODUCTION', null, null, null, { PRODUCTION_VERSION: '1.2.3', }); From 9737ba437c9ad1f9e1bb96b42542f695c6482c69 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 14:08:29 +0100 Subject: [PATCH 21/31] Fix tests Fixed tests for lint after new steps have been added See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/lintAssertions.js | 3 ++- workflow_tests/mocks/lintMocks.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/workflow_tests/assertions/lintAssertions.js b/workflow_tests/assertions/lintAssertions.js index 938f9b383464..ddebdd54c70e 100644 --- a/workflow_tests/assertions/lintAssertions.js +++ b/workflow_tests/assertions/lintAssertions.js @@ -5,7 +5,8 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { utils.createStepAssertion('Checkout', true, null, 'LINT', 'Checkout', [], []), utils.createStepAssertion('Setup Node', true, null, 'LINT', 'Setup Node', [], []), utils.createStepAssertion('Lint JavaScript and Typescript with ESLint', true, null, 'LINT', 'Lint JavaScript with ESLint', [], [{key: 'CI', value: 'true'}]), - utils.createStepAssertion('Lint shell scripts with ShellCheck', true, null, 'LINT', 'Lint shell scripts with ShellCheck', [], []), + utils.createStepAssertion("Verify there's no Prettier diff", true, null, 'LINT', "Verify theres no Prettier diff", [], []), + utils.createStepAssertion('Run unused style searcher', true, null, 'LINT', 'Run unused style searcher', [], []), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/mocks/lintMocks.js b/workflow_tests/mocks/lintMocks.js index ecf11074e20f..ee149d454cfe 100644 --- a/workflow_tests/mocks/lintMocks.js +++ b/workflow_tests/mocks/lintMocks.js @@ -4,12 +4,14 @@ const utils = require('../utils/utils'); const LINT__LINT__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'LINT', [], []); const LINT__LINT__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'LINT', [], []); const LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK = utils.createMockStep('Lint JavaScript and Typescript with ESLint', 'Lint JavaScript with ESLint', 'LINT', [], ['CI']); -const LINT__LINT__LINT_SHELL_SCRIPTS_WITH_SHELLCHECK__STEP_MOCK = utils.createMockStep('Lint shell scripts with ShellCheck', 'Lint shell scripts with ShellCheck', 'LINT', [], []); +const LINT__LINT__VERIFY_NO_PRETTIER__STEP_MOCK = utils.createMockStep("Verify there's no Prettier diff", "Verify theres no Prettier diff", 'LINT'); +const LINT__LINT__RUN_UNUSED_SEARCHER__STEP_MOCK = utils.createMockStep('Run unused style searcher', 'Run unused style searcher', 'LINT'); const LINT__LINT__STEP_MOCKS = [ LINT__LINT__CHECKOUT__STEP_MOCK, LINT__LINT__SETUP_NODE__STEP_MOCK, LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK, - LINT__LINT__LINT_SHELL_SCRIPTS_WITH_SHELLCHECK__STEP_MOCK, + LINT__LINT__VERIFY_NO_PRETTIER__STEP_MOCK, + LINT__LINT__RUN_UNUSED_SEARCHER__STEP_MOCK, ]; module.exports = { From eb18ea0532bf21fe3b634e680a3cf267b0833922 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 14:12:11 +0100 Subject: [PATCH 22/31] Run prettier Run prettier See: https://github.com/Expensify/App/issues/13604 --- .../assertions/createNewVersionAssertions.js | 14 +++++++++++++- workflow_tests/assertions/deployAssertions.js | 12 ++++++++++-- .../assertions/finishReleaseCycleAssertions.js | 14 +++++++++++--- workflow_tests/assertions/lintAssertions.js | 2 +- .../assertions/platformDeployAssertions.js | 10 ++++++---- workflow_tests/deploy.test.js | 18 +++--------------- workflow_tests/mocks/cherryPickMocks.js | 4 +++- workflow_tests/mocks/deployMocks.js | 15 +++++++++++++-- .../mocks/finishReleaseCycleMocks.js | 7 +------ workflow_tests/mocks/lintMocks.js | 2 +- workflow_tests/mocks/platformDeployMocks.js | 14 ++++++++++++-- 11 files changed, 74 insertions(+), 38 deletions(-) diff --git a/workflow_tests/assertions/createNewVersionAssertions.js b/workflow_tests/assertions/createNewVersionAssertions.js index 3356cb0eef4c..27c54e924975 100644 --- a/workflow_tests/assertions/createNewVersionAssertions.js +++ b/workflow_tests/assertions/createNewVersionAssertions.js @@ -26,7 +26,19 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' ], [], ), - utils.createStepAssertion('Setup git for OSBotify', true, null, 'CREATENEWVERSION', 'Setup git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}, {key: 'OS_BOTIFY_APP_ID', value: '***'}, {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}], []), + utils.createStepAssertion( + 'Setup git for OSBotify', + true, + null, + 'CREATENEWVERSION', + 'Setup git for OSBotify', + [ + {key: 'GPG_PASSPHRASE', value: '***'}, + {key: 'OS_BOTIFY_APP_ID', value: '***'}, + {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}, + ], + [], + ), utils.createStepAssertion( 'Generate version', true, diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js index 47f8b06d66b4..ce0907e84be8 100644 --- a/workflow_tests/assertions/deployAssertions.js +++ b/workflow_tests/assertions/deployAssertions.js @@ -6,7 +6,11 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { {key: 'ref', value: 'staging'}, {key: 'token', value: '***'}, ]), - utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_STAGING', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}, {key: 'OS_BOTIFY_APP_ID', value: '***'}, {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}]), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_STAGING', 'Setting up git for OSBotify', [ + {key: 'GPG_PASSPHRASE', value: '***'}, + {key: 'OS_BOTIFY_APP_ID', value: '***'}, + {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}, + ]), utils.createStepAssertion('Tag version', true, null, 'DEPLOY_STAGING', 'Tagging new version'), utils.createStepAssertion('🚀 Push tags to trigger staging deploy 🚀', true, null, 'DEPLOY_STAGING', 'Pushing tag to trigger staging deploy'), ]; @@ -26,7 +30,11 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => {key: 'ref', value: 'production'}, {key: 'token', value: '***'}, ]), - utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_PRODUCTION', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}, {key: 'OS_BOTIFY_APP_ID', value: '***'}, {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}]), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_PRODUCTION', 'Setting up git for OSBotify', [ + {key: 'GPG_PASSPHRASE', value: '***'}, + {key: 'OS_BOTIFY_APP_ID', value: '***'}, + {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}, + ]), utils.createStepAssertion('Get current app version', true, null, 'DEPLOY_PRODUCTION', 'Getting current app version'), utils.createStepAssertion('Get Release Pull Request List', true, null, 'DEPLOY_PRODUCTION', 'Getting release PR list', [ {key: 'TAG', value: '1.2.3'}, diff --git a/workflow_tests/assertions/finishReleaseCycleAssertions.js b/workflow_tests/assertions/finishReleaseCycleAssertions.js index 96c473fca917..cd90422bf995 100644 --- a/workflow_tests/assertions/finishReleaseCycleAssertions.js +++ b/workflow_tests/assertions/finishReleaseCycleAssertions.js @@ -2,9 +2,17 @@ const utils = require('../utils/utils'); const assertValidateJobExecuted = (workflowResult, issueNumber = '', didExecute = true, isTeamMember = true, hasBlockers = false, isSuccessful = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'VALIDATE', 'Checkout', [{key: 'ref', value: 'main'}, {key: 'token', value: '***'}]), - utils.createStepAssertion('Setup Git for OSBotify', true, null, 'VALIDATE', 'Setup Git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}, {key: 'OS_BOTIFY_APP_ID', value: '***'}, {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}]), - utils.createStepAssertion('Validate actor is deployer', true, null, 'VALIDATE', 'Validating if actor is deployer', [], [{key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}])]; + utils.createStepAssertion('Checkout', true, null, 'VALIDATE', 'Checkout', [ + {key: 'ref', value: 'main'}, + {key: 'token', value: '***'}, + ]), + utils.createStepAssertion('Setup Git for OSBotify', true, null, 'VALIDATE', 'Setup Git for OSBotify', [ + {key: 'GPG_PASSPHRASE', value: '***'}, + {key: 'OS_BOTIFY_APP_ID', value: '***'}, + {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}, + ]), + utils.createStepAssertion('Validate actor is deployer', true, null, 'VALIDATE', 'Validating if actor is deployer', [], [{key: 'GITHUB_TOKEN', value: 'os_botify_api_token'}]), + ]; if (isTeamMember) { steps.push( utils.createStepAssertion( diff --git a/workflow_tests/assertions/lintAssertions.js b/workflow_tests/assertions/lintAssertions.js index ddebdd54c70e..1253bae2e258 100644 --- a/workflow_tests/assertions/lintAssertions.js +++ b/workflow_tests/assertions/lintAssertions.js @@ -5,7 +5,7 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { utils.createStepAssertion('Checkout', true, null, 'LINT', 'Checkout', [], []), utils.createStepAssertion('Setup Node', true, null, 'LINT', 'Setup Node', [], []), utils.createStepAssertion('Lint JavaScript and Typescript with ESLint', true, null, 'LINT', 'Lint JavaScript with ESLint', [], [{key: 'CI', value: 'true'}]), - utils.createStepAssertion("Verify there's no Prettier diff", true, null, 'LINT', "Verify theres no Prettier diff", [], []), + utils.createStepAssertion("Verify there's no Prettier diff", true, null, 'LINT', 'Verify theres no Prettier diff', [], []), utils.createStepAssertion('Run unused style searcher', true, null, 'LINT', 'Run unused style searcher', [], []), ]; diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 63b5b11ba1ab..d59223f14b40 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -188,10 +188,12 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = ); if (!isProduction) { steps.push( - utils.createStepAssertion('Upload iOS version to GitHub artifacts', true, null, 'IOS', 'Upload iOS version to GitHub artifacts', [ - {key: 'name', value: 'New Expensify.ipa'}, - {key: 'path', value: '/Users/runner/work/App/App/New Expensify.ipa'}, - ]), utils.createStepAssertion('Upload iOS version to Browser Stack', true, null, 'IOS', 'Uploading version to Browser Stack', null, [{key: 'BROWSERSTACK', value: '***'}])); + utils.createStepAssertion('Upload iOS version to GitHub artifacts', true, null, 'IOS', 'Upload iOS version to GitHub artifacts', [ + {key: 'name', value: 'New Expensify.ipa'}, + {key: 'path', value: '/Users/runner/work/App/App/New Expensify.ipa'}, + ]), + utils.createStepAssertion('Upload iOS version to Browser Stack', true, null, 'IOS', 'Uploading version to Browser Stack', null, [{key: 'BROWSERSTACK', value: '***'}]), + ); } else { steps.push( utils.createStepAssertion('Set iOS version in ENV', true, null, 'IOS', 'Setting iOS version'), diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 4c730050a203..b15a167d4702 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -39,7 +39,7 @@ describe('test workflow deploy', () => { afterEach(async () => { await mockGithub.teardown(); }); - + const secrets = { OS_BOTIFY_TOKEN: 'dummy_token', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', @@ -139,13 +139,7 @@ describe('test workflow deploy', () => { }; // pull_request - act = utils.setUpActParams( - act, - 'pull_request', - {head: {ref: 'main'}}, - secrets, - 'dummy_github_token', - ); + act = utils.setUpActParams(act, 'pull_request', {head: {ref: 'main'}}, secrets, 'dummy_github_token'); let result = await act.runEvent('pull_request', { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, @@ -156,13 +150,7 @@ describe('test workflow deploy', () => { assertions.assertDeployProductionJobExecuted(result, false); // workflow_dispatch - act = utils.setUpActParams( - act, - 'workflow_dispatch', - {}, - secrets, - 'dummy_github_token', - ); + act = utils.setUpActParams(act, 'workflow_dispatch', {}, secrets, 'dummy_github_token'); result = await act.runEvent('workflow_dispatch', { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index 8531d9783172..5ce9b2ecccfb 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -36,7 +36,9 @@ const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [CHERRYPICK__CREATENEWVERSION__ // cherrypick const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'CHERRYPICK', ['ref', 'token'], []); -const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep('Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], [], {OS_BOTIFY_API_TOKEN: 'os_botify_api_token'}); +const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep('Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], [], { + OS_BOTIFY_API_TOKEN: 'os_botify_api_token', +}); const CHERRYPICK__CHERRYPICK__GET_PREVIOUS_APP_VERSION__STEP_MOCK = utils.createMockStep('Get previous app version', 'Get previous app version', 'CHERRYPICK', ['SEMVER_LEVEL']); const CHERRYPICK__CHERRYPICK__FETCH_HISTORY_OF_RELEVANT_REFS__STEP_MOCK = utils.createMockStep('Fetch history of relevant refs', 'Fetch history of relevant refs', 'CHERRYPICK'); const CHERRYPICK__CHERRYPICK__GET_VERSION_BUMP_COMMIT__STEP_MOCK = utils.createMockStep('Get version bump commit', 'Get version bump commit', 'CHERRYPICK', [], [], { diff --git a/workflow_tests/mocks/deployMocks.js b/workflow_tests/mocks/deployMocks.js index 5f8f00828e9b..9e8b978f05ac 100644 --- a/workflow_tests/mocks/deployMocks.js +++ b/workflow_tests/mocks/deployMocks.js @@ -1,13 +1,24 @@ const utils = require('../utils/utils'); const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'DEPLOY_STAGING', ['ref', 'token']); -const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_STAGING', ['GPG_PASSPHRASE', 'OS_BOTIFY_APP_ID', 'OS_BOTIFY_PRIVATE_KEY']); +const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_STAGING', [ + 'GPG_PASSPHRASE', + 'OS_BOTIFY_APP_ID', + 'OS_BOTIFY_PRIVATE_KEY', +]); const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = utils.createMockStep('Tag version', 'Tagging new version', 'DEPLOY_STAGING'); const DEPLOY_STAGING__PUSH_TAG__STEP_MOCK = utils.createMockStep('🚀 Push tags to trigger staging deploy 🚀', 'Pushing tag to trigger staging deploy', 'DEPLOY_STAGING'); const DEPLOY_STAGING_STEP_MOCKS = [DEPLOY_STAGING__CHECKOUT__STEP_MOCK, DEPLOY_STAGING__SETUP_GIT__STEP_MOCK, DEPLOY_STAGING__TAG_VERSION__STEP_MOCK, DEPLOY_STAGING__PUSH_TAG__STEP_MOCK]; const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'DEPLOY_PRODUCTION', ['ref', 'token']); -const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_PRODUCTION', ['GPG_PASSPHRASE', 'OS_BOTIFY_APP_ID', 'OS_BOTIFY_PRIVATE_KEY'], null, {OS_BOTIFY_API_TOKEN: 'os_botify_api_token'}); +const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.createMockStep( + 'Setup git for OSBotify', + 'Setting up git for OSBotify', + 'DEPLOY_PRODUCTION', + ['GPG_PASSPHRASE', 'OS_BOTIFY_APP_ID', 'OS_BOTIFY_PRIVATE_KEY'], + null, + {OS_BOTIFY_API_TOKEN: 'os_botify_api_token'}, +); const DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK = utils.createMockStep('Get current app version', 'Getting current app version', 'DEPLOY_PRODUCTION', null, null, null, { PRODUCTION_VERSION: '1.2.3', }); diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.js b/workflow_tests/mocks/finishReleaseCycleMocks.js index 551105705992..cf5b805ff479 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.js +++ b/workflow_tests/mocks/finishReleaseCycleMocks.js @@ -1,12 +1,7 @@ const utils = require('../utils/utils'); // validate -const FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'VALIDATE', - ['ref', 'token'], -); +const FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'VALIDATE', ['ref', 'token']); const FINISHRELEASECYCLE__VALIDATE__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( 'Setup Git for OSBotify', 'Setup Git for OSBotify', diff --git a/workflow_tests/mocks/lintMocks.js b/workflow_tests/mocks/lintMocks.js index ee149d454cfe..1fc5dbfd526f 100644 --- a/workflow_tests/mocks/lintMocks.js +++ b/workflow_tests/mocks/lintMocks.js @@ -4,7 +4,7 @@ const utils = require('../utils/utils'); const LINT__LINT__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'LINT', [], []); const LINT__LINT__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'LINT', [], []); const LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK = utils.createMockStep('Lint JavaScript and Typescript with ESLint', 'Lint JavaScript with ESLint', 'LINT', [], ['CI']); -const LINT__LINT__VERIFY_NO_PRETTIER__STEP_MOCK = utils.createMockStep("Verify there's no Prettier diff", "Verify theres no Prettier diff", 'LINT'); +const LINT__LINT__VERIFY_NO_PRETTIER__STEP_MOCK = utils.createMockStep("Verify there's no Prettier diff", 'Verify theres no Prettier diff', 'LINT'); const LINT__LINT__RUN_UNUSED_SEARCHER__STEP_MOCK = utils.createMockStep('Run unused style searcher', 'Run unused style searcher', 'LINT'); const LINT__LINT__STEP_MOCKS = [ LINT__LINT__CHECKOUT__STEP_MOCK, diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index d660d057259d..e1f016142c65 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -51,7 +51,12 @@ const PLATFORM_DEPLOY__ANDROID__FASTLANE_BETA__STEP_MOCK = utils.createMockStep( ]); const PLATFORM_DEPLOY__ANDROID__FASTLANE_PRODUCTION__STEP_MOCK = utils.createMockStep('Run Fastlane production', 'Running Fastlane production', 'ANDROID', null, ['VERSION']); const PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep('Archive Android sourcemaps', 'Archiving Android sourcemaps', 'ANDROID', ['name', 'path']); -const PLATFORM_DEPLOY__ANDROID__UPLOAD_ANDROID_VERSION_TO_GITHUB_ARTIFACTS__STEP_MOCK = utils.createMockStep('Upload Android version to GitHub artifacts', 'Upload Android version to GitHub artifacts', 'ANDROID', ['name', 'path']); +const PLATFORM_DEPLOY__ANDROID__UPLOAD_ANDROID_VERSION_TO_GITHUB_ARTIFACTS__STEP_MOCK = utils.createMockStep( + 'Upload Android version to GitHub artifacts', + 'Upload Android version to GitHub artifacts', + 'ANDROID', + ['name', 'path'], +); const PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_BROWSER_STACK__STEP_MOCK = utils.createMockStep( 'Upload Android version to Browser Stack', 'Uploading Android version to Browser Stack', @@ -141,7 +146,12 @@ const PLATFORM_DEPLOY__IOS__FASTLANE__STEP_MOCK = utils.createMockStep('Run Fast 'APPLE_DEMO_PASSWORD', ]); const PLATFORM_DEPLOY__IOS__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep('Archive iOS sourcemaps', 'Archiving sourcemaps', 'IOS', ['name', 'path']); -const PLATFORM_DEPLOY__IOS__UPLOAD_IOS_VERSION_TO_GITHUB_ARTIFACTS__STEP_MOCK = utils.createMockStep('Upload iOS version to GitHub artifacts', 'Upload iOS version to GitHub artifacts', 'IOS', ['name', 'path']); +const PLATFORM_DEPLOY__IOS__UPLOAD_IOS_VERSION_TO_GITHUB_ARTIFACTS__STEP_MOCK = utils.createMockStep( + 'Upload iOS version to GitHub artifacts', + 'Upload iOS version to GitHub artifacts', + 'IOS', + ['name', 'path'], +); const PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK = utils.createMockStep('Upload iOS version to Browser Stack', 'Uploading version to Browser Stack', 'IOS', null, ['BROWSERSTACK']); const PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK = utils.createMockStep('Set iOS version in ENV', 'Setting iOS version', 'IOS', null, null, null, {IOS_VERSION: '1.2.3'}); const PLATFORM_DEPLOY__IOS__RELEASE_FASTLANE__STEP_MOCK = utils.createMockStep('Run Fastlane for App Store release', 'Running Fastlane for release', 'IOS', null, ['VERSION']); From cc52b3104af7822c9ca389e41072617caf152da6 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 14:15:47 +0100 Subject: [PATCH 23/31] Add quotes Add quotes to satisfy linter See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 9b69364c2cb0..404f964881fc 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -31,7 +31,7 @@ jobs: run: brew install act - name: Set ACT_BINARY - run: echo "ACT_BINARY=$(which act)" >> $GITHUB_ENV + run: echo "ACT_BINARY=$(which act)" >> "$GITHUB_ENV" - name: Run tests run: npm run workflow-test From 398210d898435d1bcfd27e0c975a65821580843c Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Nov 2023 14:56:53 +0100 Subject: [PATCH 24/31] Remove strategy Removed strategy field from gha workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index 404f964881fc..a5a9e1b1be17 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -14,8 +14,6 @@ jobs: runs-on: ubuntu-latest env: CI: true - strategy: - fail-fast: false name: test GitHub Workflows steps: - name: Checkout From 48997af8f9e27d63493a1e73566b5b391bc53011 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 14 Nov 2023 11:59:58 +0100 Subject: [PATCH 25/31] Add wildcards Updated the paths field in the workflow with the wildcard to match all files in .github directory and subdirectories See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testGithubActionsWorkflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testGithubActionsWorkflows.yml b/.github/workflows/testGithubActionsWorkflows.yml index a5a9e1b1be17..58de3ba2d9f3 100644 --- a/.github/workflows/testGithubActionsWorkflows.yml +++ b/.github/workflows/testGithubActionsWorkflows.yml @@ -6,7 +6,7 @@ on: pull_request: types: [opened, reopened, edited, synchronize] branches-ignore: [staging, production] - paths: ['.github'] + paths: ['.github/**'] jobs: testGHWorkflows: From 4e9771287be113fb9254a956403cf6ce88aa8eb5 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 14 Nov 2023 14:04:56 +0100 Subject: [PATCH 26/31] Move actor definition Declares and defines actor value within the test See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/authorChecklist.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index 64a25c8fe1b8..2a351f98607a 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -46,8 +46,8 @@ describe('test workflow authorChecklist', () => { action: 'opened', }; describe('actor is not OSBotify', () => { - const actor = 'Dummy Author'; it('executes workflow', async () => { + const actor = 'Dummy Author'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -66,8 +66,8 @@ describe('test workflow authorChecklist', () => { }); }); describe('actor is OSBotify', () => { - const actor = 'OSBotify'; it('does not execute workflow', async () => { + const actor = 'OSBotify'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -92,8 +92,8 @@ describe('test workflow authorChecklist', () => { action: 'edited', }; describe('actor is not OSBotify', () => { - const actor = 'Dummy Author'; it('executes workflow', async () => { + const actor = 'Dummy Author'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -112,8 +112,8 @@ describe('test workflow authorChecklist', () => { }); }); describe('actor is OSBotify', () => { - const actor = 'OSBotify'; it('does not execute workflow', async () => { + const actor = 'OSBotify'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -138,8 +138,8 @@ describe('test workflow authorChecklist', () => { action: 'reopened', }; describe('actor is not OSBotify', () => { - const actor = 'Dummy Author'; it('executes workflow', async () => { + const actor = 'Dummy Author'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -158,8 +158,8 @@ describe('test workflow authorChecklist', () => { }); }); describe('actor is OSBotify', () => { - const actor = 'OSBotify'; it('does not execute workflow', async () => { + const actor = 'OSBotify'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); From 994c9f0c1e962ab3585962e9183cbe2f942e1a01 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Nov 2023 13:14:30 +0100 Subject: [PATCH 27/31] Fix workflow tests Fixed platformDeploy workflow tests after recent changes in upstream See: https://github.com/Expensify/App/issues/13604 --- .../assertions/platformDeployAssertions.js | 8 +------ workflow_tests/mocks/platformDeployMocks.js | 15 ++---------- workflow_tests/platformDeploy.test.js | 24 ++++++++++++++++--- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index d59223f14b40..62c1275174fb 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -14,13 +14,7 @@ const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = tru const assertDeployChecklistJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'DEPLOY_CHECKLIST', 'Checkout'), - utils.createStepAssertion('Setup Node', true, null, 'DEPLOY_CHECKLIST', 'Setup Node'), - utils.createStepAssertion('Set version', true, null, 'DEPLOY_CHECKLIST', 'Set version'), - utils.createStepAssertion('Create or update staging deploy', true, null, 'DEPLOY_CHECKLIST', 'Create or update staging deploy', [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'NPM_VERSION', value: '1.2.3'}, - ]), + utils.createStepAssertion('deployChecklist', true, null, 'DEPLOY_CHECKLIST', 'Run deployChecklist'), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index e1f016142c65..f7fd4c6b4beb 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -21,20 +21,9 @@ const PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS = [PLATFORM_DEPLO const PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS = [PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK]; // deployChecklist -const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DEPLOY_CHECKLIST'); -const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'DEPLOY_CHECKLIST'); -const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__SET_VERSION__STEP_MOCK = utils.createMockStep('Set version', 'Set version', 'DEPLOY_CHECKLIST', [], [], {VERSION: '1.2.3'}); -const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__CREATE_OR_UPDATE_STAGING_DEPLOY__STEP_MOCK = utils.createMockStep( - 'Create or update staging deploy', - 'Create or update staging deploy', - 'DEPLOY_CHECKLIST', - ['GITHUB_TOKEN', 'NPM_VERSION'], -); +const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCK = utils.createMockStep('deployChecklist', 'Run deployChecklist', 'DEPLOY_CHECKLIST'); const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS = [ - PLATFORM_DEPLOY__DEPLOY_CHECKLIST__CHECKOUT__STEP_MOCK, - PLATFORM_DEPLOY__DEPLOY_CHECKLIST__SETUP_NODE__STEP_MOCK, - PLATFORM_DEPLOY__DEPLOY_CHECKLIST__SET_VERSION__STEP_MOCK, - PLATFORM_DEPLOY__DEPLOY_CHECKLIST__CREATE_OR_UPDATE_STAGING_DEPLOY__STEP_MOCK, + PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCK ]; // android diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index e74b8e873001..5ce479392980 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -90,7 +90,6 @@ describe('test workflow platformDeploy', () => { ); const testMockSteps = { validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS, - deployChecklist: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, @@ -99,11 +98,18 @@ describe('test workflow platformDeploy', () => { postSlackMessageOnSuccess: mocks.PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, postGithubComment: mocks.PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, }; + const testMockJobs = { + deployChecklist: { + steps: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, + runsOn: 'ubuntu-latest', + }, + }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); @@ -166,7 +172,6 @@ describe('test workflow platformDeploy', () => { ); const testMockSteps = { validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS, - deployChecklist: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, @@ -175,11 +180,18 @@ describe('test workflow platformDeploy', () => { postSlackMessageOnSuccess: mocks.PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, postGithubComment: mocks.PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, }; + const testMockJobs = { + deployChecklist: { + steps: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, + runsOn: 'ubuntu-latest', + }, + }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertVerifyActorJobExecuted(result, 'OSBotify'); @@ -242,7 +254,6 @@ describe('test workflow platformDeploy', () => { ); const testMockSteps = { validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS, - deployChecklist: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, @@ -251,11 +262,18 @@ describe('test workflow platformDeploy', () => { postSlackMessageOnSuccess: mocks.PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, postGithubComment: mocks.PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, }; + const testMockJobs = { + deployChecklist: { + steps: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, + runsOn: 'ubuntu-latest', + }, + }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); From ff4dcb1750a2439bf4fa28b44a03e8c650885c18 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Nov 2023 13:23:17 +0100 Subject: [PATCH 28/31] Fix workflow tests Fixed authorChecklist workflow tests after recent changes in upstream See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/authorChecklist.yml | 3 ++- .../assertions/authorChecklistAssertions.js | 5 +++- workflow_tests/authorChecklist.test.js | 24 +++++++------------ workflow_tests/mocks/authorChecklistMocks.js | 3 ++- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/authorChecklist.yml b/.github/workflows/authorChecklist.yml index ecb0b87a6416..907b1e7be6ca 100644 --- a/.github/workflows/authorChecklist.yml +++ b/.github/workflows/authorChecklist.yml @@ -13,7 +13,8 @@ jobs: runs-on: ubuntu-latest if: github.actor != 'OSBotify' && github.actor != 'imgbot[bot]' steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - name: authorChecklist.js uses: ./.github/actions/javascript/authorChecklist diff --git a/workflow_tests/assertions/authorChecklistAssertions.js b/workflow_tests/assertions/authorChecklistAssertions.js index c57fe922c754..4d777933a51f 100644 --- a/workflow_tests/assertions/authorChecklistAssertions.js +++ b/workflow_tests/assertions/authorChecklistAssertions.js @@ -1,7 +1,10 @@ const utils = require('../utils/utils'); const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { - const steps = [utils.createStepAssertion('authorChecklist.js', true, null, 'CHECKLIST', 'Running authorChecklist.js', [{key: 'GITHUB_TOKEN', value: '***'}], [])]; + const steps = [ + utils.createStepAssertion('Checkout', true, null, 'CHECKLIST', 'Checkout'), + utils.createStepAssertion('authorChecklist.js', true, null, 'CHECKLIST', 'Running authorChecklist.js', [{key: 'GITHUB_TOKEN', value: '***'}], []), + ]; steps.forEach((expectedStep) => { if (didExecute) { diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index 2a351f98607a..831e7f695ba4 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -41,13 +41,12 @@ describe('test workflow authorChecklist', () => { await mockGithub.teardown(); }); describe('pull request opened', () => { - const event = 'pull_request'; + const event = 'pull_request_target'; const eventOptions = { action: 'opened', }; describe('actor is not OSBotify', () => { it('executes workflow', async () => { - const actor = 'Dummy Author'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -58,7 +57,7 @@ describe('test workflow authorChecklist', () => { const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, - actor, + actor: 'Dummy Author', logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); @@ -67,7 +66,6 @@ describe('test workflow authorChecklist', () => { }); describe('actor is OSBotify', () => { it('does not execute workflow', async () => { - const actor = 'OSBotify'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -78,7 +76,7 @@ describe('test workflow authorChecklist', () => { const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, - actor, + actor: 'OSBotify', logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); @@ -87,13 +85,12 @@ describe('test workflow authorChecklist', () => { }); }); describe('pull request edited', () => { - const event = 'pull_request'; + const event = 'pull_request_target'; const eventOptions = { action: 'edited', }; describe('actor is not OSBotify', () => { it('executes workflow', async () => { - const actor = 'Dummy Author'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -104,7 +101,7 @@ describe('test workflow authorChecklist', () => { const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, - actor, + actor: 'Dummy Author', logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); @@ -113,7 +110,6 @@ describe('test workflow authorChecklist', () => { }); describe('actor is OSBotify', () => { it('does not execute workflow', async () => { - const actor = 'OSBotify'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -124,7 +120,7 @@ describe('test workflow authorChecklist', () => { const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, - actor, + actor: 'OSBotify', logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); @@ -133,13 +129,12 @@ describe('test workflow authorChecklist', () => { }); }); describe('pull request reopened', () => { - const event = 'pull_request'; + const event = 'pull_request_target'; const eventOptions = { action: 'reopened', }; describe('actor is not OSBotify', () => { it('executes workflow', async () => { - const actor = 'Dummy Author'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -150,7 +145,7 @@ describe('test workflow authorChecklist', () => { const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, - actor, + actor: 'Dummy Author', logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); @@ -159,7 +154,6 @@ describe('test workflow authorChecklist', () => { }); describe('actor is OSBotify', () => { it('does not execute workflow', async () => { - const actor = 'OSBotify'; const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -170,7 +164,7 @@ describe('test workflow authorChecklist', () => { const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, - actor, + actor: 'OSBotify', logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); diff --git a/workflow_tests/mocks/authorChecklistMocks.js b/workflow_tests/mocks/authorChecklistMocks.js index db211f5ec1e6..b0fda86815db 100644 --- a/workflow_tests/mocks/authorChecklistMocks.js +++ b/workflow_tests/mocks/authorChecklistMocks.js @@ -1,8 +1,9 @@ const utils = require('../utils/utils'); // checklist +const AUTHORCHECKLIST__CHECKLIST__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'CHECKLIST'); const AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK = utils.createMockStep('authorChecklist.js', 'Running authorChecklist.js', 'CHECKLIST', ['GITHUB_TOKEN'], []); -const AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS = [AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK]; +const AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS = [AUTHORCHECKLIST__CHECKLIST__CHECKOUT__STEP_MOCK, AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK]; module.exports = { AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, From 7c31dd19747a9a2c40b334d537ffd4b997f573d1 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Nov 2023 13:45:10 +0100 Subject: [PATCH 29/31] Fix workflow tests Fixed deployBlocker workflow tests after recent changes in upstream See: https://github.com/Expensify/App/issues/13604 --- .../assertions/deployBlockerAssertions.js | 70 +++++++---------- workflow_tests/deployBlocker.test.js | 45 +++++++---- workflow_tests/mocks/deployBlockerMocks.js | 76 ++++++------------- 3 files changed, 81 insertions(+), 110 deletions(-) diff --git a/workflow_tests/assertions/deployBlockerAssertions.js b/workflow_tests/assertions/deployBlockerAssertions.js index 8d2d6039960e..e25ee3528fe2 100644 --- a/workflow_tests/assertions/deployBlockerAssertions.js +++ b/workflow_tests/assertions/deployBlockerAssertions.js @@ -1,50 +1,8 @@ const utils = require('../utils/utils'); -const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, didExecute = true, isSuccessful = true) => { +const assertUpdateChecklistJobExecuted = (workflowResult, didExecute = true, isSuccessful = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'DEPLOYBLOCKER', 'Checkout', [{key: 'token', value: '***'}], []), - utils.createStepAssertion( - 'Get URL, title, & number of new deploy blocker (issue)', - true, - null, - 'DEPLOYBLOCKER', - 'Get URL, title and number of new deploy blocker - issue', - [], - [{key: 'TITLE', value: issueTitle}], - ), - utils.createStepAssertion( - 'Update StagingDeployCash with new deploy blocker', - true, - null, - 'DEPLOYBLOCKER', - 'Update StagingDeployCash with new deploy blocker', - [{key: 'GITHUB_TOKEN', value: '***'}], - [], - ), - utils.createStepAssertion( - 'Give the issue/PR the Hourly, Engineering labels', - true, - null, - 'DEPLOYBLOCKER', - 'Give the issue/PR the Hourly, Engineering labels', - [ - {key: 'add-labels', value: 'Hourly, Engineering'}, - {key: 'remove-labels', value: 'Daily, Weekly, Monthly'}, - ], - [], - ), - utils.createStepAssertion( - 'Comment on deferred PR', - true, - null, - 'DEPLOYBLOCKER', - 'Comment on deferred PR', - [ - {key: 'github_token', value: '***'}, - {key: 'number', value: issueNumber}, - ], - [], - ), + utils.createStepAssertion('updateChecklist', true, null, 'UPDATECHECKLIST', 'Run updateChecklist'), ]; steps.forEach((expectedStep) => { @@ -56,6 +14,29 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } }); +}; + +const assertDeployBlockerJobExecuted = (workflowResult, didExecute = true, isSuccessful = true, failsAt = -1) => { + const steps = [ + utils.createStepAssertion('Checkout', true, null, 'DEPLOYBLOCKER', 'Checkout'), + utils.createStepAssertion('Give the issue/PR the Hourly, Engineering labels', true, null, 'DEPLOYBLOCKER', 'Give the issue/PR the Hourly, Engineering labels', [], [{key: 'GITHUB_TOKEN', value: '***'}]), + utils.createStepAssertion('Comment on deploy blocker', true, null, 'DEPLOYBLOCKER', 'Comment on deploy blocker', [], [{key: 'GITHUB_TOKEN', value: '***'}]), + ]; + + steps.forEach((expectedStep, i) => { + if (didExecute) { + if (failsAt === -1 || i < failsAt) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else if (i === failsAt) { + steps[i].status = 1; + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + }); const successSteps = [ utils.createStepAssertion( @@ -94,5 +75,6 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, }; module.exports = { + assertUpdateChecklistJobExecuted, assertDeployBlockerJobExecuted, }; diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index 1cfca11c90f5..59cffa2bbfc3 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -71,14 +71,22 @@ describe('test workflow deployBlocker', () => { const testMockSteps = { deployBlocker: mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS, }; + const testMockJobs = { + updateChecklist: { + steps: mocks.DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, + runsOn: 'ubuntu-latest', + } + } const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234'); + assertions.assertUpdateChecklistJobExecuted(result); + assertions.assertDeployBlockerJobExecuted(result); }); describe('one step fails', () => { it('announces failure on Slack', async () => { @@ -89,24 +97,23 @@ describe('test workflow deployBlocker', () => { const testMockSteps = { deployBlocker: utils.deepCopy(mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS), }; - testMockSteps.deployBlocker[2] = utils.createMockStep( - 'Update StagingDeployCash with new deploy blocker', - 'Update StagingDeployCash with new deploy blocker', - 'DEPLOYBLOCKER', - ['GITHUB_TOKEN'], - [], - {}, - {}, - false, - ); + testMockSteps.deployBlocker[1] = utils.createMockStep('Give the issue/PR the Hourly, Engineering labels', 'Give the issue/PR the Hourly, Engineering labels', 'DEPLOYBLOCKER', [], ['GITHUB_TOKEN'], null, null, false); + const testMockJobs = { + updateChecklist: { + steps: mocks.DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, + runsOn: 'ubuntu-latest', + } + } const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - - assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234', true, false); + + assertions.assertUpdateChecklistJobExecuted(result); + assertions.assertDeployBlockerJobExecuted(result, true, false, 1); }); }); }); @@ -121,14 +128,22 @@ describe('test workflow deployBlocker', () => { const testMockSteps = { deployBlocker: mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS, }; + const testMockJobs = { + updateChecklist: { + steps: mocks.DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, + runsOn: 'ubuntu-latest', + } + } const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - - assertions.assertDeployBlockerJobExecuted(result, '', '', false); + + assertions.assertUpdateChecklistJobExecuted(result, false); + assertions.assertDeployBlockerJobExecuted(result, false); }); }); }); diff --git a/workflow_tests/mocks/deployBlockerMocks.js b/workflow_tests/mocks/deployBlockerMocks.js index fbfc676f7701..9602f4fa3ee1 100644 --- a/workflow_tests/mocks/deployBlockerMocks.js +++ b/workflow_tests/mocks/deployBlockerMocks.js @@ -1,68 +1,42 @@ const utils = require('../utils/utils'); +// updateChecklist +const DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCK = utils.createMockStep('updateChecklist', 'Run updateChecklist', 'UPDATECHECKLIST'); +const DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS = [DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCK]; + // deployblocker -const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DEPLOYBLOCKER', ['token'], []); -const DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCKER_ISSUE__STEP_MOCK = utils.createMockStep( - 'Get URL, title, & number of new deploy blocker (issue)', - 'Get URL, title and number of new deploy blocker - issue', - 'DEPLOYBLOCKER', - [], - ['TITLE'], - {}, - { - // eslint-disable-next-line no-template-curly-in-string - DEPLOY_BLOCKER_URL: '${{ github.event.issue.html_url }}', - // eslint-disable-next-line no-template-curly-in-string - DEPLOY_BLOCKER_NUMBER: '${{ github.event.issue.number }}', - // eslint-disable-next-line no-template-curly-in-string - DEPLOY_BLOCKER_TITLE: '${{ github.event.issue.title }}', - }, -); -const DEPLOYBLOCKER__DEPLOYBLOCKER__UPDATE_STAGINGDEPLOYCASH_WITH_NEW_DEPLOY_BLOCKER__STEP_MOCK = utils.createMockStep( - 'Update StagingDeployCash with new deploy blocker', - 'Update StagingDeployCash with new deploy blocker', - 'DEPLOYBLOCKER', - ['GITHUB_TOKEN'], - [], -); -const DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_THE_ISSUE_OR_PR_THE_HOURLY_ENGINEERING_LABELS__STEP_MOCK = utils.createMockStep( - 'Give the issue/PR the Hourly, Engineering labels', - 'Give the issue/PR the Hourly, Engineering labels', - 'DEPLOYBLOCKER', - ['add-labels', 'remove-labels'], - [], -); +const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DEPLOYBLOCKER'); +const DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_LABELS__STEP_MOCK = utils.createMockStep('Give the issue/PR the Hourly, Engineering labels', 'Give the issue/PR the Hourly, Engineering labels', 'DEPLOYBLOCKER', [], ['GITHUB_TOKEN']); const DEPLOYBLOCKER__DEPLOYBLOCKER__POST_THE_ISSUE_IN_THE_EXPENSIFY_OPEN_SOURCE_SLACK_ROOM__STEP_MOCK = utils.createMockStep( - 'Post the issue in the #expensify-open-source slack room', - 'Post the issue in the expensify-open-source slack room', - 'DEPLOYBLOCKER', - ['status'], - ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], + 'Post the issue in the #expensify-open-source slack room', + 'Post the issue in the expensify-open-source slack room', + 'DEPLOYBLOCKER', + ['status'], + ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); -const DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEFERRED_PR__STEP_MOCK = utils.createMockStep( - 'Comment on deferred PR', - 'Comment on deferred PR', - 'DEPLOYBLOCKER', - ['github_token', 'number'], - [], +const DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEPLOY_BLOCKER__STEP_MOCK = utils.createMockStep( + 'Comment on deploy blocker', + 'Comment on deploy blocker', + 'DEPLOYBLOCKER', + [], + ['GITHUB_TOKEN'], ); const DEPLOYBLOCKER__DEPLOYBLOCKER__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( - 'Announce failed workflow in Slack', - 'Announce failed workflow in Slack', - 'DEPLOYBLOCKER', - ['SLACK_WEBHOOK'], - [], + 'Announce failed workflow in Slack', + 'Announce failed workflow in Slack', + 'DEPLOYBLOCKER', + ['SLACK_WEBHOOK'], + [], ); const DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS = [ DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK, - DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCKER_ISSUE__STEP_MOCK, - DEPLOYBLOCKER__DEPLOYBLOCKER__UPDATE_STAGINGDEPLOYCASH_WITH_NEW_DEPLOY_BLOCKER__STEP_MOCK, - DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_THE_ISSUE_OR_PR_THE_HOURLY_ENGINEERING_LABELS__STEP_MOCK, + DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_LABELS__STEP_MOCK, DEPLOYBLOCKER__DEPLOYBLOCKER__POST_THE_ISSUE_IN_THE_EXPENSIFY_OPEN_SOURCE_SLACK_ROOM__STEP_MOCK, - DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEFERRED_PR__STEP_MOCK, + DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEPLOY_BLOCKER__STEP_MOCK, DEPLOYBLOCKER__DEPLOYBLOCKER__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, ]; module.exports = { + DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS, }; From 357d4ef8e9e5c2bb4aa50a23f2a91048061260f0 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Nov 2023 13:49:06 +0100 Subject: [PATCH 30/31] Run prettier Run prettier See: https://github.com/Expensify/App/issues/13604 --- .../assertions/authorChecklistAssertions.js | 4 +- .../assertions/deployBlockerAssertions.js | 16 +++++--- .../assertions/platformDeployAssertions.js | 4 +- workflow_tests/deployBlocker.test.js | 27 ++++++++----- workflow_tests/mocks/deployBlockerMocks.js | 38 +++++++++++-------- workflow_tests/mocks/platformDeployMocks.js | 4 +- workflow_tests/platformDeploy.test.js | 2 +- 7 files changed, 56 insertions(+), 39 deletions(-) diff --git a/workflow_tests/assertions/authorChecklistAssertions.js b/workflow_tests/assertions/authorChecklistAssertions.js index 4d777933a51f..256a3534951b 100644 --- a/workflow_tests/assertions/authorChecklistAssertions.js +++ b/workflow_tests/assertions/authorChecklistAssertions.js @@ -2,8 +2,8 @@ const utils = require('../utils/utils'); const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'CHECKLIST', 'Checkout'), - utils.createStepAssertion('authorChecklist.js', true, null, 'CHECKLIST', 'Running authorChecklist.js', [{key: 'GITHUB_TOKEN', value: '***'}], []), + utils.createStepAssertion('Checkout', true, null, 'CHECKLIST', 'Checkout'), + utils.createStepAssertion('authorChecklist.js', true, null, 'CHECKLIST', 'Running authorChecklist.js', [{key: 'GITHUB_TOKEN', value: '***'}], []), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/assertions/deployBlockerAssertions.js b/workflow_tests/assertions/deployBlockerAssertions.js index e25ee3528fe2..78a3fea116b4 100644 --- a/workflow_tests/assertions/deployBlockerAssertions.js +++ b/workflow_tests/assertions/deployBlockerAssertions.js @@ -1,9 +1,7 @@ const utils = require('../utils/utils'); const assertUpdateChecklistJobExecuted = (workflowResult, didExecute = true, isSuccessful = true) => { - const steps = [ - utils.createStepAssertion('updateChecklist', true, null, 'UPDATECHECKLIST', 'Run updateChecklist'), - ]; + const steps = [utils.createStepAssertion('updateChecklist', true, null, 'UPDATECHECKLIST', 'Run updateChecklist')]; steps.forEach((expectedStep) => { if (didExecute) { @@ -19,10 +17,18 @@ const assertUpdateChecklistJobExecuted = (workflowResult, didExecute = true, isS const assertDeployBlockerJobExecuted = (workflowResult, didExecute = true, isSuccessful = true, failsAt = -1) => { const steps = [ utils.createStepAssertion('Checkout', true, null, 'DEPLOYBLOCKER', 'Checkout'), - utils.createStepAssertion('Give the issue/PR the Hourly, Engineering labels', true, null, 'DEPLOYBLOCKER', 'Give the issue/PR the Hourly, Engineering labels', [], [{key: 'GITHUB_TOKEN', value: '***'}]), + utils.createStepAssertion( + 'Give the issue/PR the Hourly, Engineering labels', + true, + null, + 'DEPLOYBLOCKER', + 'Give the issue/PR the Hourly, Engineering labels', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), utils.createStepAssertion('Comment on deploy blocker', true, null, 'DEPLOYBLOCKER', 'Comment on deploy blocker', [], [{key: 'GITHUB_TOKEN', value: '***'}]), ]; - + steps.forEach((expectedStep, i) => { if (didExecute) { if (failsAt === -1 || i < failsAt) { diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 62c1275174fb..d398bbf07fdd 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -13,9 +13,7 @@ const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = tru }; const assertDeployChecklistJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion('deployChecklist', true, null, 'DEPLOY_CHECKLIST', 'Run deployChecklist'), - ]; + const steps = [utils.createStepAssertion('deployChecklist', true, null, 'DEPLOY_CHECKLIST', 'Run deployChecklist')]; steps.forEach((expectedStep) => { if (didExecute) { diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index 59cffa2bbfc3..2fee3d01915a 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -75,8 +75,8 @@ describe('test workflow deployBlocker', () => { updateChecklist: { steps: mocks.DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, runsOn: 'ubuntu-latest', - } - } + }, + }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, @@ -97,13 +97,22 @@ describe('test workflow deployBlocker', () => { const testMockSteps = { deployBlocker: utils.deepCopy(mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS), }; - testMockSteps.deployBlocker[1] = utils.createMockStep('Give the issue/PR the Hourly, Engineering labels', 'Give the issue/PR the Hourly, Engineering labels', 'DEPLOYBLOCKER', [], ['GITHUB_TOKEN'], null, null, false); + testMockSteps.deployBlocker[1] = utils.createMockStep( + 'Give the issue/PR the Hourly, Engineering labels', + 'Give the issue/PR the Hourly, Engineering labels', + 'DEPLOYBLOCKER', + [], + ['GITHUB_TOKEN'], + null, + null, + false, + ); const testMockJobs = { updateChecklist: { steps: mocks.DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, runsOn: 'ubuntu-latest', - } - } + }, + }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, @@ -111,7 +120,7 @@ describe('test workflow deployBlocker', () => { logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), mockJobs: testMockJobs, }); - + assertions.assertUpdateChecklistJobExecuted(result); assertions.assertDeployBlockerJobExecuted(result, true, false, 1); }); @@ -132,8 +141,8 @@ describe('test workflow deployBlocker', () => { updateChecklist: { steps: mocks.DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS, runsOn: 'ubuntu-latest', - } - } + }, + }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, @@ -141,7 +150,7 @@ describe('test workflow deployBlocker', () => { logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), mockJobs: testMockJobs, }); - + assertions.assertUpdateChecklistJobExecuted(result, false); assertions.assertDeployBlockerJobExecuted(result, false); }); diff --git a/workflow_tests/mocks/deployBlockerMocks.js b/workflow_tests/mocks/deployBlockerMocks.js index 9602f4fa3ee1..4f74e0b91ebb 100644 --- a/workflow_tests/mocks/deployBlockerMocks.js +++ b/workflow_tests/mocks/deployBlockerMocks.js @@ -6,27 +6,33 @@ const DEPLOYBLOCKER__UPDATECHECKLIST__STEP_MOCKS = [DEPLOYBLOCKER__UPDATECHECKLI // deployblocker const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DEPLOYBLOCKER'); -const DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_LABELS__STEP_MOCK = utils.createMockStep('Give the issue/PR the Hourly, Engineering labels', 'Give the issue/PR the Hourly, Engineering labels', 'DEPLOYBLOCKER', [], ['GITHUB_TOKEN']); +const DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_LABELS__STEP_MOCK = utils.createMockStep( + 'Give the issue/PR the Hourly, Engineering labels', + 'Give the issue/PR the Hourly, Engineering labels', + 'DEPLOYBLOCKER', + [], + ['GITHUB_TOKEN'], +); const DEPLOYBLOCKER__DEPLOYBLOCKER__POST_THE_ISSUE_IN_THE_EXPENSIFY_OPEN_SOURCE_SLACK_ROOM__STEP_MOCK = utils.createMockStep( - 'Post the issue in the #expensify-open-source slack room', - 'Post the issue in the expensify-open-source slack room', - 'DEPLOYBLOCKER', - ['status'], - ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], + 'Post the issue in the #expensify-open-source slack room', + 'Post the issue in the expensify-open-source slack room', + 'DEPLOYBLOCKER', + ['status'], + ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); const DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEPLOY_BLOCKER__STEP_MOCK = utils.createMockStep( - 'Comment on deploy blocker', - 'Comment on deploy blocker', - 'DEPLOYBLOCKER', - [], - ['GITHUB_TOKEN'], + 'Comment on deploy blocker', + 'Comment on deploy blocker', + 'DEPLOYBLOCKER', + [], + ['GITHUB_TOKEN'], ); const DEPLOYBLOCKER__DEPLOYBLOCKER__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( - 'Announce failed workflow in Slack', - 'Announce failed workflow in Slack', - 'DEPLOYBLOCKER', - ['SLACK_WEBHOOK'], - [], + 'Announce failed workflow in Slack', + 'Announce failed workflow in Slack', + 'DEPLOYBLOCKER', + ['SLACK_WEBHOOK'], + [], ); const DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS = [ DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK, diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index f7fd4c6b4beb..2de982dfc731 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -22,9 +22,7 @@ const PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS = [PLATFORM_DEPLOY__ // deployChecklist const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCK = utils.createMockStep('deployChecklist', 'Run deployChecklist', 'DEPLOY_CHECKLIST'); -const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS = [ - PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCK -]; +const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS = [PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCK]; // android const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'ANDROID'); diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 5ce479392980..6bcd5ff5b896 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -109,7 +109,7 @@ describe('test workflow platformDeploy', () => { mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs + mockJobs: testMockJobs, }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); From 1dab7e73aaf3a5a689808dcd4d846052a26996e1 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 23 Nov 2023 12:02:29 +0100 Subject: [PATCH 31/31] Type git with lowercase Changed step names containing git to have it in lowercase See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/finishReleaseCycle.yml | 6 +++--- .../assertions/finishReleaseCycleAssertions.js | 6 +++--- workflow_tests/mocks/finishReleaseCycleMocks.js | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/finishReleaseCycle.yml b/.github/workflows/finishReleaseCycle.yml index b120d01b10d0..2285eec56065 100644 --- a/.github/workflows/finishReleaseCycle.yml +++ b/.github/workflows/finishReleaseCycle.yml @@ -18,7 +18,7 @@ jobs: ref: main token: ${{ secrets.OS_BOTIFY_TOKEN }} - - name: Setup Git for OSBotify + - name: Setup git for OSBotify uses: ./.github/actions/composite/setupGitForOSBotifyApp id: setupGitForOSBotify with: @@ -83,7 +83,7 @@ jobs: ref: staging token: ${{ secrets.OS_BOTIFY_TOKEN }} - - name: Setup Git for OSBotify + - name: Setup git for OSBotify id: setupGitForOSBotify uses: ./.github/actions/composite/setupGitForOSBotifyApp with: @@ -125,7 +125,7 @@ jobs: ref: main token: ${{ secrets.OS_BOTIFY_TOKEN }} - - name: Setup Git for OSBotify + - name: Setup git for OSBotify uses: ./.github/actions/composite/setupGitForOSBotifyApp with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} diff --git a/workflow_tests/assertions/finishReleaseCycleAssertions.js b/workflow_tests/assertions/finishReleaseCycleAssertions.js index cd90422bf995..16db65b4afe7 100644 --- a/workflow_tests/assertions/finishReleaseCycleAssertions.js +++ b/workflow_tests/assertions/finishReleaseCycleAssertions.js @@ -6,7 +6,7 @@ const assertValidateJobExecuted = (workflowResult, issueNumber = '', didExecute {key: 'ref', value: 'main'}, {key: 'token', value: '***'}, ]), - utils.createStepAssertion('Setup Git for OSBotify', true, null, 'VALIDATE', 'Setup Git for OSBotify', [ + utils.createStepAssertion('Setup git for OSBotify', true, null, 'VALIDATE', 'Setup git for OSBotify', [ {key: 'GPG_PASSPHRASE', value: '***'}, {key: 'OS_BOTIFY_APP_ID', value: '***'}, {key: 'OS_BOTIFY_PRIVATE_KEY', value: '***'}, @@ -113,7 +113,7 @@ const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true, is ], [], ), - utils.createStepAssertion('Setup Git for OSBotify', true, null, 'UPDATEPRODUCTION', 'Setup Git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'UPDATEPRODUCTION', 'Setup git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), utils.createStepAssertion('Update production branch', true, null, 'UPDATEPRODUCTION', 'Updating production branch', [], []), ]; @@ -164,7 +164,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, isSuc ], [], ), - utils.createStepAssertion('Setup Git for OSBotify', true, null, 'UPDATESTAGING', 'Setup Git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'UPDATESTAGING', 'Setup git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), utils.createStepAssertion('Update staging branch to trigger staging deploy', true, null, 'UPDATESTAGING', 'Updating staging branch', [], []), ]; diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.js b/workflow_tests/mocks/finishReleaseCycleMocks.js index cf5b805ff479..29e0842852dc 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.js +++ b/workflow_tests/mocks/finishReleaseCycleMocks.js @@ -3,8 +3,8 @@ const utils = require('../utils/utils'); // validate const FINISHRELEASECYCLE__VALIDATE__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'VALIDATE', ['ref', 'token']); const FINISHRELEASECYCLE__VALIDATE__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( - 'Setup Git for OSBotify', - 'Setup Git for OSBotify', + 'Setup git for OSBotify', + 'Setup git for OSBotify', 'VALIDATE', ['GPG_PASSPHRASE', 'OS_BOTIFY_APP_ID', 'OS_BOTIFY_PRIVATE_KEY'], [], @@ -106,8 +106,8 @@ const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ // updateproduction const FINISHRELEASECYCLE__UPDATEPRODUCTION__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'UPDATEPRODUCTION', ['ref', 'token'], []); const FINISHRELEASECYCLE__UPDATEPRODUCTION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( - 'Setup Git for OSBotify', - 'Setup Git for OSBotify', + 'Setup git for OSBotify', + 'Setup git for OSBotify', 'UPDATEPRODUCTION', ['GPG_PASSPHRASE'], [], @@ -144,8 +144,8 @@ const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS = [FINISHRELEASECYCL // updatestaging const FINISHRELEASECYCLE__UPDATESTAGING__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'UPDATESTAGING', ['ref', 'token'], []); const FINISHRELEASECYCLE__UPDATESTAGING__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( - 'Setup Git for OSBotify', - 'Setup Git for OSBotify', + 'Setup git for OSBotify', + 'Setup git for OSBotify', 'UPDATESTAGING', ['GPG_PASSPHRASE'], [],