Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13604] Run GHA workflow tests on each PR #30975

Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cb75361
Add workflow
radoslawkrzemien Nov 7, 2023
62256f7
Fix
radoslawkrzemien Nov 7, 2023
6df5949
Add trigger
radoslawkrzemien Nov 7, 2023
38f51dd
Update trigger
radoslawkrzemien Nov 7, 2023
674a2a0
Merge pull request #1 from radoslawkrzemien/@radoslawkrzemien/13604-r…
radoslawkrzemien Nov 7, 2023
9bb710e
Add step
radoslawkrzemien Nov 7, 2023
4010b80
Add step
radoslawkrzemien Nov 7, 2023
28cb3bf
Update step
radoslawkrzemien Nov 7, 2023
e40c556
Update step
radoslawkrzemien Nov 7, 2023
0cca425
Update step
radoslawkrzemien Nov 7, 2023
33d29b6
Add step
radoslawkrzemien Nov 7, 2023
6cd203e
Update step
radoslawkrzemien Nov 7, 2023
d455679
Update step
radoslawkrzemien Nov 7, 2023
ac5632f
Update step
radoslawkrzemien Nov 7, 2023
a08af4f
Fix tests
radoslawkrzemien Nov 8, 2023
a6dafa6
Fix tests
radoslawkrzemien Nov 8, 2023
a68fb46
Fix tests
radoslawkrzemien Nov 8, 2023
8ae7987
Fix tests
radoslawkrzemien Nov 8, 2023
498cffc
Fix tests
radoslawkrzemien Nov 8, 2023
214a772
Fix tests
radoslawkrzemien Nov 8, 2023
6721a95
Fix tests
radoslawkrzemien Nov 8, 2023
9737ba4
Fix tests
radoslawkrzemien Nov 8, 2023
eb18ea0
Run prettier
radoslawkrzemien Nov 8, 2023
cc52b31
Add quotes
radoslawkrzemien Nov 8, 2023
398210d
Remove strategy
radoslawkrzemien Nov 8, 2023
89a190d
Merge branch 'Expensify:main' into main
radoslawkrzemien Nov 8, 2023
889d116
Merge remote-tracking branch 'origin/main' into @radoslawkrzemien/136…
radoslawkrzemien Nov 8, 2023
48997af
Add wildcards
radoslawkrzemien Nov 14, 2023
4e97712
Move actor definition
radoslawkrzemien Nov 14, 2023
7c24f56
Merge branch 'Expensify:main' into main
radoslawkrzemien Nov 21, 2023
f1dfd28
Merge remote-tracking branch 'origin/main' into @radoslawkrzemien/136…
radoslawkrzemien Nov 21, 2023
994c9f0
Fix workflow tests
radoslawkrzemien Nov 21, 2023
ff4dcb1
Fix workflow tests
radoslawkrzemien Nov 21, 2023
7c31dd1
Fix workflow tests
radoslawkrzemien Nov 21, 2023
357d4ef
Run prettier
radoslawkrzemien Nov 21, 2023
1dab7e7
Type git with lowercase
radoslawkrzemien Nov 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/authorChecklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
with:
ref: staging
token: ${{ secrets.OS_BOTIFY_TOKEN }}

- uses: ./.github/actions/composite/setupGitForOSBotifyApp

- name: Setup git for OSBotify
uses: ./.github/actions/composite/setupGitForOSBotifyApp
id: setupGitForOSBotify
with:
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
Expand All @@ -38,7 +39,8 @@ jobs:
ref: production
token: ${{ secrets.OS_BOTIFY_TOKEN }}

- uses: ./.github/actions/composite/setupGitForOSBotifyApp
- name: Setup git for OSBotify
uses: ./.github/actions/composite/setupGitForOSBotifyApp
id: setupGitForOSBotify
with:
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/finishReleaseCycle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
ref: main
token: ${{ secrets.OS_BOTIFY_TOKEN }}

- uses: ./.github/actions/composite/setupGitForOSBotifyApp
- name: Setup Git for OSBotify
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Setup Git for OSBotify
- name: Setup git for OSBotify

NAB - others are lowercase, ideally this should match

uses: ./.github/actions/composite/setupGitForOSBotifyApp
id: setupGitForOSBotify
with:
GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/testGithubActionsWorkflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test GitHub Actions workflows

on:
workflow_dispatch:
workflow_call:
pull_request:
types: [opened, reopened, edited, 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
name: test GitHub Workflows
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
uses: Expensify/App/.github/actions/composite/setupNode@main

- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install Act
run: brew install act

- name: Set ACT_BINARY
run: echo "ACT_BINARY=$(which act)" >> "$GITHUB_ENV"

- name: Run tests
run: npm run workflow-test
5 changes: 4 additions & 1 deletion workflow_tests/assertions/authorChecklistAssertions.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion workflow_tests/assertions/cherryPickAssertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}],
),
];

Expand Down
16 changes: 14 additions & 2 deletions workflow_tests/assertions/createNewVersionAssertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,27 @@ 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,
null,
'CREATENEWVERSION',
'Generate version',
[
{key: 'GITHUB_TOKEN', value: '***'},
{key: 'GITHUB_TOKEN', value: 'os_botify_api_token'},
{key: 'SEMVER_LEVEL', value: semverLevel},
],
[],
Expand Down
16 changes: 12 additions & 4 deletions workflow_tests/assertions/deployAssertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '***'}]),
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'),
];
Expand All @@ -26,11 +30,15 @@ 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]'}]),
Expand All @@ -44,7 +52,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'}],
),
];

Expand Down
64 changes: 26 additions & 38 deletions workflow_tests/assertions/deployBlockerAssertions.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,43 @@
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('updateChecklist', true, null, 'UPDATECHECKLIST', 'Run updateChecklist')];

steps.forEach((expectedStep) => {
if (didExecute) {
if (isSuccessful) {
expect(workflowResult).toEqual(expect.arrayContaining([expectedStep]));
}
} else {
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', [{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('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: '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},
],
[],
[{key: 'GITHUB_TOKEN', value: '***'}],
),
utils.createStepAssertion('Comment on deploy blocker', true, null, 'DEPLOYBLOCKER', 'Comment on deploy blocker', [], [{key: 'GITHUB_TOKEN', value: '***'}]),
];

steps.forEach((expectedStep) => {
steps.forEach((expectedStep, i) => {
if (didExecute) {
if (isSuccessful) {
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]));
Expand Down Expand Up @@ -94,5 +81,6 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber,
};

module.exports = {
assertUpdateChecklistJobExecuted,
assertDeployBlockerJobExecuted,
};
19 changes: 15 additions & 4 deletions workflow_tests/assertions/finishReleaseCycleAssertions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
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(
Expand All @@ -11,7 +22,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},
],
[],
Expand All @@ -36,7 +47,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!'},
],
Expand All @@ -60,7 +71,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},
],
[],
Expand Down
3 changes: 2 additions & 1 deletion workflow_tests/assertions/lintAssertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
22 changes: 12 additions & 10 deletions workflow_tests/assertions/platformDeployAssertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,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'},
]),
];
const steps = [utils.createStepAssertion('deployChecklist', true, null, 'DEPLOY_CHECKLIST', 'Run deployChecklist')];

steps.forEach((expectedStep) => {
if (didExecute) {
Expand Down Expand Up @@ -63,6 +55,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: '***'},
]),
Expand Down Expand Up @@ -183,7 +179,13 @@ 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'),
Expand Down
Loading
Loading