From e47ab71edfca14cc90248c0790444fa77400cc83 Mon Sep 17 00:00:00 2001 From: Sivli Embir Date: Fri, 5 Jan 2024 10:02:02 -0800 Subject: [PATCH 1/2] npm-dev-deps - run prittier --- .eslintrc | 2 +- .github/actions/build/action.yml | 3 +- .github/actions/build/mocks.ts | 4 +- .github/actions/frontend/chromatic/README.md | 18 +-- .github/actions/frontend/chromatic/action.yml | 4 +- .github/actions/frontend/cortex/README.md | 9 +- .github/actions/frontend/cortex/action.yml | 7 +- .github/actions/frontend/cortex/mocks.ts | 4 +- .../actions/frontend/npm/publish/README.md | 11 +- .../actions/frontend/npm/publish/action.yml | 2 +- .../runtime/e2e_pending_status/README.md | 10 +- .../runtime/e2e_pending_status/action.yml | 4 +- .../frontend/runtime/e2e_prepare/README.md | 24 +-- .../frontend/runtime/e2e_prepare/action.yml | 2 +- .../runtime/e2e_prepare/test/action.test.ts | 69 ++++++--- .../runtime/e2e_prepare/test/action_test.yml | 4 +- .../runtime/e2e_prepare/test/artemis-run.json | 2 +- .../frontend/runtime/e2e_run/README.md | 70 +++++---- .../frontend/runtime/e2e_run/action.yml | 48 ++++-- .../runtime/e2e_run/test/action.test.ts | 19 ++- .../runtime/e2e_run/test/action_test.yml | 4 +- .../frontend/runtime/e2e_status/README.md | 14 +- .../frontend/runtime/e2e_status/action.yml | 4 +- .../runtime/e2e_status/test/action.test.ts | 29 +++- .../e2e_status/test/action_test_fail.yml | 4 +- .../e2e_status/test/action_test_pass.yml | 4 +- .../e2e_trigger_remote_tests/README.md | 21 +-- .../e2e_trigger_remote_tests/action.yml | 32 ++-- .../runtime/e2e_trigger_remote_tests/mocks.ts | 4 +- .../test/action.test.ts | 19 ++- .../test/action_test.yml | 8 +- .../frontend/runtime/magic_url/README.md | 18 ++- .../frontend/runtime/magic_url/action.yml | 14 +- .../runtime/migration_number/README.md | 9 +- .../runtime/migration_number/action.yml | 3 +- .../migration_number/test/action.test.ts | 19 ++- .../migration_number/test/action_test.yml | 7 +- .../runtime/remote_types_install/README.md | 5 +- .../runtime/remote_types_install/action.yml | 3 +- .../runtime/remote_types_tests/README.md | 5 +- .../runtime/remote_types_tests/action.yml | 7 +- .../runtime/remote_types_tests/mocks.ts | 4 +- .../remote_types_tests/test/action.test.ts | 41 +++-- .../test/action_test_default.yml | 2 +- .../test/action_test_skip.yml | 2 +- .github/actions/get_branch/README.md | 28 +++- .github/actions/get_branch/action.yml | 4 +- .github/actions/get_branch/mocks.ts | 4 +- .github/actions/pr_comment/README.md | 16 +- .github/actions/pr_comment/action.yml | 8 +- .github/actions/pr_comment/mocks.ts | 2 +- .../actions/pr_comment/test/action.test.ts | 74 +++++---- .../pr_comment/test/action_test_always.yml | 4 +- .../pr_comment/test/action_test_default.yml | 4 +- .../actions/promote_docker_image/README.md | 24 +-- .../actions/promote_docker_image/action.yml | 13 +- .github/actions/setup_env/README.md | 9 +- .github/actions/slack_notifier/README.md | 11 +- .github/actions/slack_notifier/action.yml | 5 +- .../slack_notifier/test/action.test.ts | 19 ++- .../slack_notifier/test/action_test.yml | 2 +- .github/actions/unique_id/README.md | 17 +- .github/actions/unique_id/action.yml | 9 +- .github/actions/validate/README.md | 7 +- .github/actions/validate/action.yml | 3 +- .github/actions/validate/mocks.ts | 4 +- .github/actions/version_artifact/README.md | 11 +- .../docs/frontend/frontend_npm_pr.md | 25 +-- .../docs/frontend/frontend_npm_release.md | 32 ++-- ...tend_runtime_application_manual_e2e_run.md | 56 ++++--- .../frontend_runtime_application_pr.md | 29 ++-- .../docs/frontend/frontend_runtime_deploy.md | 30 ++-- .../frontend_runtime_e2e_trigger_response.md | 68 ++++---- ...tend_runtime_utility_manual_e2e_trigger.md | 53 ++++--- .../frontend/frontend_runtime_utility_pr.md | 26 ++-- .github/workflows/docs/provision_only_pr.md | 20 +-- .../workflows/docs/provision_only_release.md | 22 +-- .github/workflows/frontend_npm_pr.yml | 16 +- .github/workflows/frontend_npm_release.yml | 30 +++- ...end_runtime_application_manual_e2e_run.yml | 80 ++++++---- .../frontend_runtime_application_pr.yml | 40 +++-- .github/workflows/frontend_runtime_deploy.yml | 32 ++-- .../frontend_runtime_e2e_trigger_response.yml | 75 ++++++--- ...end_runtime_utility_manual_e2e_trigger.yml | 36 +++-- .../workflows/frontend_runtime_utility_pr.yml | 36 +++-- ...o_publish_integration_collector_image.yaml | 12 +- .github/workflows/internal_pull_request.yml | 2 +- .github/workflows/internal_release.yml | 7 +- .github/workflows/provision_only_pr.yml | 10 +- .github/workflows/provision_only_release.yml | 22 ++- .../workflows/test/frontend_npm_pr.test.ts | 25 ++- .../test/frontend_npm_release.test.ts | 32 ++-- ...runtime_application_manual_e2e_run.test.ts | 145 ++++++++++++------ .../frontend_runtime_application_pr.test.ts | 54 ++++--- .../test/frontend_runtime_deploy.test.ts | 30 ++-- ...ntend_runtime_e2e_trigger_response.test.ts | 104 +++++++++---- ...runtime_utility_manual_e2e_trigger.test.ts | 102 ++++++++---- .../test/frontend_runtime_utility_pr.test.ts | 52 ++++--- .../workflows/test/provision_only_pr.test.ts | 6 +- .../test/provision_only_release.test.ts | 21 +-- README.md | 60 ++++++-- bin/generate-local-files.js | 8 +- bin/update-composite-tags.js | 15 +- tests/utils/helpers.ts | 15 +- tests/utils/mocking.ts | 84 ++++++---- tests/utils/setup.ts | 33 ++-- tsconfig.json | 4 +- vitest.config.ts | 2 +- 108 files changed, 1488 insertions(+), 939 deletions(-) diff --git a/.eslintrc b/.eslintrc index 9643bf32..74a19fc4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,4 +7,4 @@ "project": "./tsconfig.json" }, "ignorePatterns": [".eslintrc", "vitest.config.ts"] -} \ No newline at end of file +} diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 3c8a5c0f..4a659439 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,9 +1,8 @@ name: Runs build on the repo runs: - using: "composite" + using: 'composite' steps: - name: build shell: bash run: npm run build - diff --git a/.github/actions/build/mocks.ts b/.github/actions/build/mocks.ts index 48894fbf..dc323865 100644 --- a/.github/actions/build/mocks.ts +++ b/.github/actions/build/mocks.ts @@ -3,6 +3,4 @@ This file is automatically leveraged when tests are run to determine which steps should be skipped in the composite action. If these steps were not mocked, they would break the test. */ -export const BUILD_MOCK_STEPS = [ - { name: 'build' }, -]; +export const BUILD_MOCK_STEPS = [{ name: 'build' }]; diff --git a/.github/actions/frontend/chromatic/README.md b/.github/actions/frontend/chromatic/README.md index e743a0ff..d9ff65eb 100644 --- a/.github/actions/frontend/chromatic/README.md +++ b/.github/actions/frontend/chromatic/README.md @@ -1,20 +1,21 @@ # Frontend Runtime - Chromatic -This [composite action](./action.yml) is responsible for building nad publishing your Storybook to Chromatic and running visual regression tests. +This [composite action](./action.yml) is responsible for building nad publishing +your Storybook to Chromatic and running visual regression tests. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `github_token` | String | | True | Github access token -| `chromatic_project_token` | String | | True | The Chromatic API token -| `publish_chromatic` | String | | True | The Chromatic API token - +| Name | Type | Default | Required | Description | +| ------------------------- | ------ | ------- | -------- | ----------------------- | +| `github_token` | String | | True | Github access token | +| `chromatic_project_token` | String | | True | The Chromatic API token | +| `publish_chromatic` | String | | True | The Chromatic API token | + ## Outputs -No outputs provided. +No outputs provided. ## Example Usage @@ -27,4 +28,3 @@ steps: - name: validate uses: jupiterone/.github/.github/actions/frontend/runtime/chromatic ``` - diff --git a/.github/actions/frontend/chromatic/action.yml b/.github/actions/frontend/chromatic/action.yml index e701f788..eea24a55 100644 --- a/.github/actions/frontend/chromatic/action.yml +++ b/.github/actions/frontend/chromatic/action.yml @@ -10,12 +10,12 @@ inputs: required: true type: string publish_chromatic: - description: "If true, will publish to Chromatic. Otherwise will" + description: 'If true, will publish to Chromatic. Otherwise will' type: boolean default: false runs: - using: "composite" + using: 'composite' steps: - name: chromatic_inputs shell: bash diff --git a/.github/actions/frontend/cortex/README.md b/.github/actions/frontend/cortex/README.md index 788f5cf5..9cb7b126 100644 --- a/.github/actions/frontend/cortex/README.md +++ b/.github/actions/frontend/cortex/README.md @@ -1,14 +1,15 @@ # Frontend - Cortex -This [composite action](./action.yml) is responsible for running Cortex related jobs for Frontend Projects. +This [composite action](./action.yml) is responsible for running Cortex related +jobs for Frontend Projects. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------------- | --------- | --------------------------------------------------------- | -| `cortex_api_key` | String | | True | The key that allows us to push data to Cortex +| Name | Type | Default | Required | Description | +| ---------------- | ------ | ------- | -------- | --------------------------------------------- | +| `cortex_api_key` | String | | True | The key that allows us to push data to Cortex | ## Outputs diff --git a/.github/actions/frontend/cortex/action.yml b/.github/actions/frontend/cortex/action.yml index 1083fb23..d6b394d6 100644 --- a/.github/actions/frontend/cortex/action.yml +++ b/.github/actions/frontend/cortex/action.yml @@ -6,16 +6,17 @@ inputs: type: string required: true - runs: - using: "composite" + using: 'composite' steps: - name: cortex_inputs shell: bash run: | echo "cortex_api_key=${{ inputs.cortex_api_key }}" - name: push_to_cortex - run: npx --yes -p @jupiterone/web-tools-platform-analytics@latest platform-analytics all + run: + npx --yes -p @jupiterone/web-tools-platform-analytics@latest + platform-analytics all shell: bash env: CORTEX_API_KEY: ${{ inputs.cortex_api_key }} diff --git a/.github/actions/frontend/cortex/mocks.ts b/.github/actions/frontend/cortex/mocks.ts index f8d2604b..f591833e 100644 --- a/.github/actions/frontend/cortex/mocks.ts +++ b/.github/actions/frontend/cortex/mocks.ts @@ -3,6 +3,4 @@ This file is automatically leveraged when tests are run to determine which steps should be skipped in the composite action. If these steps were not mocked, they would break the test. */ -export const CORTEX_MOCK_STEPS = [ - { name: 'push_to_cortex' }, -]; +export const CORTEX_MOCK_STEPS = [{ name: 'push_to_cortex' }]; diff --git a/.github/actions/frontend/npm/publish/README.md b/.github/actions/frontend/npm/publish/README.md index 864cbdd9..c8840407 100644 --- a/.github/actions/frontend/npm/publish/README.md +++ b/.github/actions/frontend/npm/publish/README.md @@ -1,15 +1,16 @@ # Frontend NPM - Release -This [composite action](./action.yml) is responsible for deploying a frontend npm package. +This [composite action](./action.yml) is responsible for deploying a frontend +npm package. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `use_esbuild` | Boolean | False | False | If using esbuild, ensure its required build scripts are run -| `auto_token` | String | | True | Used for publishing the GitHub release and creating labels +| Name | Type | Default | Required | Description | +| ------------- | ------- | ------- | -------- | ----------------------------------------------------------- | +| `use_esbuild` | Boolean | False | False | If using esbuild, ensure its required build scripts are run | +| `auto_token` | String | | True | Used for publishing the GitHub release and creating labels | ## Outputs diff --git a/.github/actions/frontend/npm/publish/action.yml b/.github/actions/frontend/npm/publish/action.yml index 0746ee6d..4c731f6c 100644 --- a/.github/actions/frontend/npm/publish/action.yml +++ b/.github/actions/frontend/npm/publish/action.yml @@ -7,7 +7,7 @@ inputs: type: string runs: - using: "composite" + using: 'composite' steps: - name: npm_publish_inputs shell: bash diff --git a/.github/actions/frontend/runtime/e2e_pending_status/README.md b/.github/actions/frontend/runtime/e2e_pending_status/README.md index f1867d94..6a560bdb 100644 --- a/.github/actions/frontend/runtime/e2e_pending_status/README.md +++ b/.github/actions/frontend/runtime/e2e_pending_status/README.md @@ -1,14 +1,16 @@ # Frontend Runtime - E2E Pending Status -This [composite action](./action.yml) is responsible for reporting that the E2E tests have begun and are pending via a status check in the PR, providing a quick feedback loop for developers. +This [composite action](./action.yml) is responsible for reporting that the E2E +tests have begun and are pending via a status check in the PR, providing a quick +feedback loop for developers. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `github_token` | String | | True | Github access token +| Name | Type | Default | Required | Description | +| -------------- | ------ | ------- | -------- | ------------------- | +| `github_token` | String | | True | Github access token | ## Outputs diff --git a/.github/actions/frontend/runtime/e2e_pending_status/action.yml b/.github/actions/frontend/runtime/e2e_pending_status/action.yml index 5cd2a8f7..02cf7050 100644 --- a/.github/actions/frontend/runtime/e2e_pending_status/action.yml +++ b/.github/actions/frontend/runtime/e2e_pending_status/action.yml @@ -6,7 +6,7 @@ inputs: required: true runs: - using: "composite" + using: 'composite' steps: - name: e2e_pr_status_inputs shell: bash @@ -21,4 +21,4 @@ runs: sha: ${{ steps.get_branch_of_pr.outputs.head_sha }} token: ${{ inputs.github_token }} status: pending - context: 'pr / E2E Status' \ No newline at end of file + context: 'pr / E2E Status' diff --git a/.github/actions/frontend/runtime/e2e_prepare/README.md b/.github/actions/frontend/runtime/e2e_prepare/README.md index 63fbf4c3..7ea4f230 100644 --- a/.github/actions/frontend/runtime/e2e_prepare/README.md +++ b/.github/actions/frontend/runtime/e2e_prepare/README.md @@ -1,26 +1,28 @@ # Frontend Runtime - E2E Prepare -This [composite action](./action.yml) is responsible for executing [Artemis](https://github.com/JupiterOne/artemis) and obtaining the necessary information needed for logging in via the account/user created. +This [composite action](./action.yml) is responsible for executing +[Artemis](https://github.com/JupiterOne/artemis) and obtaining the necessary +information needed for logging in via the account/user created. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `e2e_artemis_config_path` | String | cypress/artemis-config.yaml | False | Used to determine the path to the artemis config file -| `userCount` | String | | False | The number of tests that you want Cypress to run in parallel (obtained via `$(echo '${{ inputs.e2e_containers }}' | jq '. | length')`) +| Name | Type | Default | Required | Description | +| ------------------------- | ------ | --------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------- | ----- | ---------- | +| `e2e_artemis_config_path` | String | cypress/artemis-config.yaml | False | Used to determine the path to the artemis config file | +| `userCount` | String | | False | The number of tests that you want Cypress to run in parallel (obtained via `$(echo '${{ inputs.e2e_containers }}' | jq '. | length')`) | ## Outputs This action returns the following outputs: -| Name | Type | Description | -| --------------------------- | ------- | --------------------------------------------------------- | -| `artemis_account_name` | String | The account name extracted from the artemis-run.json file -| `artemis_account_subdomain` | String | The account subdomain extracted from the artemis-run.json file -| `artemis_account_id` | String | The id extracted from the artemis-run.json file -| `artemis_users` | String | The users extracted from the artemis-run.json file +| Name | Type | Description | +| --------------------------- | ------ | -------------------------------------------------------------- | +| `artemis_account_name` | String | The account name extracted from the artemis-run.json file | +| `artemis_account_subdomain` | String | The account subdomain extracted from the artemis-run.json file | +| `artemis_account_id` | String | The id extracted from the artemis-run.json file | +| `artemis_users` | String | The users extracted from the artemis-run.json file | ## Example Usage diff --git a/.github/actions/frontend/runtime/e2e_prepare/action.yml b/.github/actions/frontend/runtime/e2e_prepare/action.yml index 9eaba55b..73204bd2 100644 --- a/.github/actions/frontend/runtime/e2e_prepare/action.yml +++ b/.github/actions/frontend/runtime/e2e_prepare/action.yml @@ -19,7 +19,7 @@ outputs: value: ${{ steps.artemis_info.outputs.artemis_users }} runs: - using: "composite" + using: 'composite' steps: - name: e2e_prepare_inputs shell: bash diff --git a/.github/actions/frontend/runtime/e2e_prepare/test/action.test.ts b/.github/actions/frontend/runtime/e2e_prepare/test/action.test.ts index 9a71ddff..cb33ecc1 100644 --- a/.github/actions/frontend/runtime/e2e_prepare/test/action.test.ts +++ b/.github/actions/frontend/runtime/e2e_prepare/test/action.test.ts @@ -1,6 +1,9 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; -import { getCompositeActionConfig, runCompositeAction } from 'tests/utils/setup'; +import { + getCompositeActionConfig, + runCompositeAction, +} from 'tests/utils/setup'; import { getTestResult } from 'tests/utils/helpers'; import { join } from 'node:path'; import artemisRun from './artemis-run.json'; @@ -10,15 +13,19 @@ const repoName = 'e2e_prepare'; let mockGithub: MockGithub; beforeEach(async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ - directory: __dirname, - repoName, - additionalFiles: [{ - src: join(__dirname, 'artemis-run.json'), - dest: 'artemis-run.json', - }] - })); - + mockGithub = new MockGithub( + getCompositeActionConfig({ + directory: __dirname, + repoName, + additionalFiles: [ + { + src: join(__dirname, 'artemis-run.json'), + dest: 'artemis-run.json', + }, + ], + }) + ); + await mockGithub.setup(); }); @@ -30,18 +37,40 @@ test('output of artemis_info returns correct results based off artemis-run.json' const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), repoName, - originDirectory: __dirname + originDirectory: __dirname, }); - const results_artemis_account_name = getTestResult({ results, name: 'results_artemis_account_name' }); - const results_artemis_account_subdomain = getTestResult({ results, name: 'results_artemis_account_subdomain' }); - const results_artemis_account_id = getTestResult({ results, name: 'results_artemis_account_id' }); - const results_artemis_users = getTestResult({ results, name: 'results_artemis_users' }); + const results_artemis_account_name = getTestResult({ + results, + name: 'results_artemis_account_name', + }); + const results_artemis_account_subdomain = getTestResult({ + results, + name: 'results_artemis_account_subdomain', + }); + const results_artemis_account_id = getTestResult({ + results, + name: 'results_artemis_account_id', + }); + const results_artemis_users = getTestResult({ + results, + name: 'results_artemis_users', + }); - expect(results_artemis_account_name.output).toEqual(artemisRun[0].metadata.accountName); - expect(results_artemis_account_subdomain.output).toEqual(artemisRun[0].metadata.accountSubdomain); + expect(results_artemis_account_name.output).toEqual( + artemisRun[0].metadata.accountName + ); + expect(results_artemis_account_subdomain.output).toEqual( + artemisRun[0].metadata.accountSubdomain + ); expect(results_artemis_account_id.output).toEqual(artemisRun[0].id); - expect(results_artemis_users.output).toContain(artemisRun[1].metadata.token.tokenSecret); - expect(results_artemis_users.output).toContain(artemisRun[1].metadata.token.tokenCsrf); - expect(results_artemis_users.output).toContain(artemisRun[1].metadata.groupName); + expect(results_artemis_users.output).toContain( + artemisRun[1].metadata.token.tokenSecret + ); + expect(results_artemis_users.output).toContain( + artemisRun[1].metadata.token.tokenCsrf + ); + expect(results_artemis_users.output).toContain( + artemisRun[1].metadata.groupName + ); }); diff --git a/.github/actions/frontend/runtime/e2e_prepare/test/action_test.yml b/.github/actions/frontend/runtime/e2e_prepare/test/action_test.yml index 7355844a..6474d04c 100644 --- a/.github/actions/frontend/runtime/e2e_prepare/test/action_test.yml +++ b/.github/actions/frontend/runtime/e2e_prepare/test/action_test.yml @@ -1,5 +1,5 @@ on: [push] - + jobs: e2e_prepare: runs-on: ubuntu-latest @@ -22,4 +22,4 @@ jobs: shell: bash - name: results_artemis_users run: echo ${{ steps.e2e_prepare.outputs.artemis_users }} - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/actions/frontend/runtime/e2e_prepare/test/artemis-run.json b/.github/actions/frontend/runtime/e2e_prepare/test/artemis-run.json index ac22f0ac..514ab55c 100644 --- a/.github/actions/frontend/runtime/e2e_prepare/test/artemis-run.json +++ b/.github/actions/frontend/runtime/e2e_prepare/test/artemis-run.json @@ -16,4 +16,4 @@ } } } -] \ No newline at end of file +] diff --git a/.github/actions/frontend/runtime/e2e_run/README.md b/.github/actions/frontend/runtime/e2e_run/README.md index d0b4a88f..5a02f3e4 100644 --- a/.github/actions/frontend/runtime/e2e_run/README.md +++ b/.github/actions/frontend/runtime/e2e_run/README.md @@ -1,41 +1,42 @@ # Frontend Runtime - E2E Run -This [composite action](./action.yml) is responsible for running the `E2E tests` defined in a repo. +This [composite action](./action.yml) is responsible for running the `E2E tests` +defined in a repo. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------------- | --------- | --------------------------------------------------------- | -| `artemis_account_name` | String | | True | The account name extracted from the artemis-run.json file -| `artemis_account_subdomain` | String | | True | The account subdomain extracted from the artemis-run.json file -| `artemis_account_id` | String | | True | The id extracted from the artemis-run.json file -| `artemis_users` | String | | True | The users extracted from the artemis-run.json file -| `commit_info_sha` | String | github.sha | True | The sha associated with the PR that triggered the e2e_run -| `commit_info_pr_number` | String | github.event.pull_request.number | True | The PR number associated with the PR that triggered the e2e_run -| `commit_info_pr_title` | String | github.event.pull_request.title | True | The PR title associated with the PR that triggered the e2e_run -| `commit_info_branch` | String | github.event.pull_request.head.ref | True | The branch name associated with the PR that triggered the e2e_run -| `commit_info_author` | String | $(git show -s --pretty=%an) | False | The author name associated with the PR that triggered the e2e_run -| `commit_info_repo_name` | String | github.event.repository.name | True | The repo name associated with the PR that triggered the e2e_run -| `cypress_container` | String | | True | The index of the Cypress container being used (see the [docs](https://github.com/cypress-io/github-action#parallel) on running tests in parallel) -| `cypress_mailinator_api_key`| String | | False | The [mailinator api key](https://www.mailinator.com/api/) needed when going through the default login flow -| `cypress_record_key` | String | | True | The [record key](https://docs.cypress.io/guides/cloud/account-management/projects) associated with the project in Cypress -| `cypress_project_id` | String | | True | The [project ID](https://docs.cypress.io/guides/cloud/account-management/projects) associated with the project in Cypress -| `cypress_password` | String | | False | The password of the E2E username (if applicable) -| `e2e_filter_tags` | String | | True | Tests will be filtered based on the tags defined here (see the [docs](https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/tags.md) on leveraging tags) -| `e2e_pass_on_error` | String | | False | Pass the workflow even if the E2E test fail -| `github_token` | String | | True | Github access token -| `migration_number` | String | | True | The migration number defined in the root package.json -| `spec_to_run` | String | cypress/e2e/**/*.feature | False | Used to determine which test to run - +| Name | Type | Default | Required | Description | +| ---------------------------- | ------ | ---------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `artemis_account_name` | String | | True | The account name extracted from the artemis-run.json file | +| `artemis_account_subdomain` | String | | True | The account subdomain extracted from the artemis-run.json file | +| `artemis_account_id` | String | | True | The id extracted from the artemis-run.json file | +| `artemis_users` | String | | True | The users extracted from the artemis-run.json file | +| `commit_info_sha` | String | github.sha | True | The sha associated with the PR that triggered the e2e_run | +| `commit_info_pr_number` | String | github.event.pull_request.number | True | The PR number associated with the PR that triggered the e2e_run | +| `commit_info_pr_title` | String | github.event.pull_request.title | True | The PR title associated with the PR that triggered the e2e_run | +| `commit_info_branch` | String | github.event.pull_request.head.ref | True | The branch name associated with the PR that triggered the e2e_run | +| `commit_info_author` | String | $(git show -s --pretty=%an) | False | The author name associated with the PR that triggered the e2e_run | +| `commit_info_repo_name` | String | github.event.repository.name | True | The repo name associated with the PR that triggered the e2e_run | +| `cypress_container` | String | | True | The index of the Cypress container being used (see the [docs](https://github.com/cypress-io/github-action#parallel) on running tests in parallel) | +| `cypress_mailinator_api_key` | String | | False | The [mailinator api key](https://www.mailinator.com/api/) needed when going through the default login flow | +| `cypress_record_key` | String | | True | The [record key](https://docs.cypress.io/guides/cloud/account-management/projects) associated with the project in Cypress | +| `cypress_project_id` | String | | True | The [project ID](https://docs.cypress.io/guides/cloud/account-management/projects) associated with the project in Cypress | +| `cypress_password` | String | | False | The password of the E2E username (if applicable) | +| `e2e_filter_tags` | String | | True | Tests will be filtered based on the tags defined here (see the [docs](https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/tags.md) on leveraging tags) | +| `e2e_pass_on_error` | String | | False | Pass the workflow even if the E2E test fail | +| `github_token` | String | | True | Github access token | +| `migration_number` | String | | True | The migration number defined in the root package.json | +| `spec_to_run` | String | cypress/e2e/\*_/_.feature | False | Used to determine which test to run | + ## Outputs This action returns the following outputs: -| Name | Type | Description | -| --------------------------- | ------- | --------------------------------------------------------- | -| `test_passed` | String | The status of the e2e_run (true if passed, false if not) +| Name | Type | Description | +| ------------- | ------ | -------------------------------------------------------- | +| `test_passed` | String | The status of the e2e_run (true if passed, false if not) | ## Example Usage @@ -46,9 +47,11 @@ steps: - name: validate uses: jupiterone/.github/.github/actions/frontend/runtime/e2e_run with: - artemis_account_name: ${{ needs.e2e_prepare.outputs.artemis_account_name }} + artemis_account_name: + ${{ needs.e2e_prepare.outputs.artemis_account_name }} artemis_account_id: ${{ needs.e2e_prepare.outputs.artemis_account_id }} - artemis_account_subdomain: ${{ needs.e2e_prepare.outputs.artemis_account_subdomain }} + artemis_account_subdomain: + ${{ needs.e2e_prepare.outputs.artemis_account_subdomain }} artemis_users: ${{ needs.e2e_prepare.outputs.artemis_users }} cypress_container: ${{ matrix.containers }} cypress_tag: ${{ github.event.repository.name }},${{ github.event_name }} @@ -64,14 +67,15 @@ steps: spec_to_run: ${{ inputs.spec_to_run }} ``` - ### Triggered Externally -The e2e_run can be triggered by another repo (see `frontend_runtime_e2e_trigger_response.yml`). As such it's necessary to make the `commit_info_*` props configurable to ensure the run in Cypress reflects the appropriate details of the PR it's associated with. +The e2e*run can be triggered by another repo (see +`frontend_runtime_e2e_trigger_response.yml`). As such it's necessary to make the +`commit_info*\*` props configurable to ensure the run in Cypress reflects the +appropriate details of the PR it's associated with. ```yaml -permissions: - write-all +permissions: write-all steps: - name: validate uses: jupiterone/.github/.github/actions/frontend/runtime/e2e_run diff --git a/.github/actions/frontend/runtime/e2e_run/action.yml b/.github/actions/frontend/runtime/e2e_run/action.yml index b05a9fca..bbcee5b0 100644 --- a/.github/actions/frontend/runtime/e2e_run/action.yml +++ b/.github/actions/frontend/runtime/e2e_run/action.yml @@ -10,34 +10,41 @@ inputs: type: string required: true artemis_account_subdomain: - description: 'The account subdomain extracted from the artemis-run.json file' + description: + 'The account subdomain extracted from the artemis-run.json file' type: string required: true artemis_users: description: 'The users extracted from the artemis-run.json file' type: string required: true - commit_info_sha: - description: 'The commit sha associated with the repo that triggered the e2e_run' + commit_info_sha: + description: + 'The commit sha associated with the repo that triggered the e2e_run' type: string required: true commit_info_pr_number: - description: 'The PR number associated with the repo that triggered the e2e_run' + description: + 'The PR number associated with the repo that triggered the e2e_run' type: string required: true commit_info_pr_title: - description: 'The PR title sha associated with the repo that triggered the e2e_run' + description: + 'The PR title sha associated with the repo that triggered the e2e_run' type: string required: true commit_info_branch: - description: 'The branch associated with the repo that triggered the e2e_run' + description: + 'The branch associated with the repo that triggered the e2e_run' type: string required: true commit_info_author: - description: 'The author associated with the repo that triggered the e2e_run' + description: + 'The author associated with the repo that triggered the e2e_run' type: string commit_info_repo_name: - description: 'The repo name associated with the repo that triggered the e2e_run' + description: + 'The repo name associated with the repo that triggered the e2e_run' type: string required: true cypress_container: @@ -45,7 +52,8 @@ inputs: type: string default: 1 cypress_mailinator_api_key: - description: 'The mailinator api key needed when going through the default login flow' + description: + 'The mailinator api key needed when going through the default login flow' type: string required: true cypress_record_key: @@ -83,7 +91,8 @@ inputs: default: 2 type: number ci_build_id: - description: 'Used to link separate machines running tests into a single parallel run' + description: + 'Used to link separate machines running tests into a single parallel run' required: true outputs: @@ -91,7 +100,7 @@ outputs: value: ${{ steps.test_results.outputs.test_passed }} runs: - using: "composite" + using: 'composite' steps: - name: e2e_run_inputs shell: bash @@ -136,14 +145,18 @@ runs: # It's important this is unique to the commit/repo this is running against ci-build-id: ${{ inputs.ci_build_id }} browser: chrome - tag: ${{ inputs.commit_info_repo_name || github.event.repository.name }},${{ github.event_name }} + tag: + ${{ inputs.commit_info_repo_name || github.event.repository.name + }},${{ github.event_name }} env: # https://github.com/cypress-io/cypress/issues/25357#issuecomment-1426992422 ELECTRON_EXTRA_LAUNCH_ARGS: '--disable-gpu' CYPRESS_BROWSER: chrome COMMIT_INFO_MESSAGE: ${{ inputs.commit_info_pr_title }} COMMIT_INFO_BRANCH: ${{ inputs.commit_info_branch }} - COMMIT_INFO_AUTHOR: ${{ inputs.commit_info_author || steps.get_author_name.outputs.commit_info_author }} + COMMIT_INFO_AUTHOR: + ${{ inputs.commit_info_author || + steps.get_author_name.outputs.commit_info_author }} COMMIT_INFO_SHA: ${{ inputs.commit_info_sha || github.sha }} CYPRESS_CONTAINER: ${{ inputs.cypress_container }} CYPRESS_MAILINATOR_API_KEY: ${{ inputs.cypress_mailinator_api_key }} @@ -170,11 +183,16 @@ runs: shell: bash # Need to check previous TEST_PASSED to ensure it hasn't already failed # important if multiple containers are in use to ensure the correct status is reported - if: ${{ contains(steps.cypress_run.outcome, 'success') || contains(steps.mock_step.outcome, 'success') && !contains(env.TEST_PASSED, false) }} + if: + ${{ contains(steps.cypress_run.outcome, 'success') || + contains(steps.mock_step.outcome, 'success') && + !contains(env.TEST_PASSED, false) }} run: echo "TEST_PASSED=true" >> $GITHUB_ENV - name: set_failure_vars shell: bash - if: ${{ !contains(steps.cypress_run.outcome, 'success') || contains(steps.mock_step.outcome, 'success') }} + if: + ${{ !contains(steps.cypress_run.outcome, 'success') || + contains(steps.mock_step.outcome, 'success') }} run: echo "TEST_PASSED=false" >> $GITHUB_ENV - name: test_results id: test_results diff --git a/.github/actions/frontend/runtime/e2e_run/test/action.test.ts b/.github/actions/frontend/runtime/e2e_run/test/action.test.ts index 26e1dc35..12c11b24 100644 --- a/.github/actions/frontend/runtime/e2e_run/test/action.test.ts +++ b/.github/actions/frontend/runtime/e2e_run/test/action.test.ts @@ -1,6 +1,9 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; -import { getCompositeActionConfig, runCompositeAction } from 'tests/utils/setup'; +import { + getCompositeActionConfig, + runCompositeAction, +} from 'tests/utils/setup'; import { getTestResult } from 'tests/utils/helpers'; import { E2E_RUN_MOCK_STEPS } from '../mocks'; @@ -9,8 +12,10 @@ const repoName = 'e2e_run'; let mockGithub: MockGithub; beforeEach(async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ directory: __dirname, repoName })); - + mockGithub = new MockGithub( + getCompositeActionConfig({ directory: __dirname, repoName }) + ); + await mockGithub.setup(); }); @@ -22,12 +27,12 @@ test('output of test_passed is true when cypress_run is successful', async () => const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), repoName, - originDirectory: __dirname + originDirectory: __dirname, }); const result = getTestResult({ results, - name: 'e2e_run_status' + name: 'e2e_run_status', }); expect(result.output).toEqual('e2e_run status is true'); @@ -41,12 +46,12 @@ test('stops at cypress_run step if tests fail', async () => { mockSteps: [ ...E2E_RUN_MOCK_STEPS, { name: 'cypress_run', mockWith: 'exit 1' }, - ] + ], }); const result = getTestResult({ results, - name: 'test_results' + name: 'test_results', }); // The test_results step is never hit diff --git a/.github/actions/frontend/runtime/e2e_run/test/action_test.yml b/.github/actions/frontend/runtime/e2e_run/test/action_test.yml index ead779c9..e382e42f 100644 --- a/.github/actions/frontend/runtime/e2e_run/test/action_test.yml +++ b/.github/actions/frontend/runtime/e2e_run/test/action_test.yml @@ -1,5 +1,5 @@ on: [push] - + jobs: e2e_run: runs-on: ubuntu-latest @@ -15,4 +15,4 @@ jobs: repo_spec: test_spec - name: e2e_run_status run: echo e2e_run status is ${{ steps.e2e_run.outputs.test_passed }} - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/actions/frontend/runtime/e2e_status/README.md b/.github/actions/frontend/runtime/e2e_status/README.md index 711d4d0a..a7be7726 100644 --- a/.github/actions/frontend/runtime/e2e_status/README.md +++ b/.github/actions/frontend/runtime/e2e_status/README.md @@ -1,15 +1,19 @@ # Frontend Runtime - E2E Status -This [composite action](./action.yml) is responsible for reporting the status of the E2E run as both a comment on the PR as well as updating the status check. Specifically it is configurable to allow a PR to still be merged even if the E2E tests fail (if `e2e_pass_on_error: true`). By default this job is never reached if E2E tests fail and `e2e_pass_on_error` is set to `false`. +This [composite action](./action.yml) is responsible for reporting the status of +the E2E run as both a comment on the PR as well as updating the status check. +Specifically it is configurable to allow a PR to still be merged even if the E2E +tests fail (if `e2e_pass_on_error: true`). By default this job is never reached +if E2E tests fail and `e2e_pass_on_error` is set to `false`. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `github_token` | String | | True | Github access token -| `e2e_pass_on_error` | Boolean | False | False | Pass the workflow even if the E2E test fail. Should be defined as an input at the workflow level. +| Name | Type | Default | Required | Description | +| ------------------- | ------- | ------- | -------- | ------------------------------------------------------------------------------------------------- | +| `github_token` | String | | True | Github access token | +| `e2e_pass_on_error` | Boolean | False | False | Pass the workflow even if the E2E test fail. Should be defined as an input at the workflow level. | ## Outputs diff --git a/.github/actions/frontend/runtime/e2e_status/action.yml b/.github/actions/frontend/runtime/e2e_status/action.yml index 105ae383..74afba9c 100644 --- a/.github/actions/frontend/runtime/e2e_status/action.yml +++ b/.github/actions/frontend/runtime/e2e_status/action.yml @@ -10,7 +10,7 @@ inputs: default: false runs: - using: "composite" + using: 'composite' steps: - name: e2e_status_inputs shell: bash @@ -49,4 +49,4 @@ runs: with: token: ${{ inputs.github_token }} status: success - context: 'pr / E2E Status' \ No newline at end of file + context: 'pr / E2E Status' diff --git a/.github/actions/frontend/runtime/e2e_status/test/action.test.ts b/.github/actions/frontend/runtime/e2e_status/test/action.test.ts index 472adeff..22fc5a89 100644 --- a/.github/actions/frontend/runtime/e2e_status/test/action.test.ts +++ b/.github/actions/frontend/runtime/e2e_status/test/action.test.ts @@ -1,6 +1,9 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; -import { getCompositeActionConfig, runCompositeAction } from 'tests/utils/setup'; +import { + getCompositeActionConfig, + runCompositeAction, +} from 'tests/utils/setup'; import { getTestResult } from 'tests/utils/helpers'; const repoName = 'e2e_status'; @@ -12,14 +15,20 @@ afterEach(async () => { }); test('force_status_as_success is not called when e2e_passed is false', async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ directory: __dirname, repoName, actionTriggeringComposite: 'action_test_fail.yml' })); - + mockGithub = new MockGithub( + getCompositeActionConfig({ + directory: __dirname, + repoName, + actionTriggeringComposite: 'action_test_fail.yml', + }) + ); + await mockGithub.setup(); const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), repoName, - originDirectory: __dirname + originDirectory: __dirname, }); const result = getTestResult({ results, name: 'force_status_as_success' }); @@ -28,14 +37,20 @@ test('force_status_as_success is not called when e2e_passed is false', async () }); test('e2e_pass_on_error allows force_status_as_success to be called when e2e_passed is false', async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ directory: __dirname, repoName, actionTriggeringComposite: 'action_test_pass.yml' })); - + mockGithub = new MockGithub( + getCompositeActionConfig({ + directory: __dirname, + repoName, + actionTriggeringComposite: 'action_test_pass.yml', + }) + ); + await mockGithub.setup(); const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), repoName, - originDirectory: __dirname + originDirectory: __dirname, }); const result = getTestResult({ results, name: 'force_status_as_success' }); diff --git a/.github/actions/frontend/runtime/e2e_status/test/action_test_fail.yml b/.github/actions/frontend/runtime/e2e_status/test/action_test_fail.yml index e392c069..42bc7093 100644 --- a/.github/actions/frontend/runtime/e2e_status/test/action_test_fail.yml +++ b/.github/actions/frontend/runtime/e2e_status/test/action_test_fail.yml @@ -1,5 +1,5 @@ on: [push] - + jobs: e2e_status: runs-on: ubuntu-latest @@ -11,4 +11,4 @@ jobs: - id: e2e_run uses: ./e2e_status with: - e2e_passed: false \ No newline at end of file + e2e_passed: false diff --git a/.github/actions/frontend/runtime/e2e_status/test/action_test_pass.yml b/.github/actions/frontend/runtime/e2e_status/test/action_test_pass.yml index bbad67db..3e4ad33d 100644 --- a/.github/actions/frontend/runtime/e2e_status/test/action_test_pass.yml +++ b/.github/actions/frontend/runtime/e2e_status/test/action_test_pass.yml @@ -1,5 +1,5 @@ on: [push] - + jobs: e2e_status: runs-on: ubuntu-latest @@ -12,4 +12,4 @@ jobs: uses: ./e2e_status with: e2e_passed: false - e2e_pass_on_error: true \ No newline at end of file + e2e_pass_on_error: true diff --git a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/README.md b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/README.md index f15a0241..52b14f7e 100644 --- a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/README.md +++ b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/README.md @@ -1,25 +1,26 @@ # Frontend Runtime - Trigger Remote E2E Tests -This [composite action](./action.yml) is responsible for triggering tests in an external repo and then waiting for the results. +This [composite action](./action.yml) is responsible for triggering tests in an +external repo and then waiting for the results. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------------- | --------- | --------------------------------------------------------- | -| `e2e_pass_on_error` | String | False | False | Pass the workflow even if the E2E test fail -| `e2e_auto` | String | | True | A J1 token for kicking off cypress tests -| `repo_name` | String | | True | The name of the repo to target -| `repo_spec` | String | | True | The name of the spec(s) to target +| Name | Type | Default | Required | Description | +| ------------------- | ------ | ------- | -------- | ------------------------------------------- | +| `e2e_pass_on_error` | String | False | False | Pass the workflow even if the E2E test fail | +| `e2e_auto` | String | | True | A J1 token for kicking off cypress tests | +| `repo_name` | String | | True | The name of the repo to target | +| `repo_spec` | String | | True | The name of the spec(s) to target | ## Outputs This action takes the following inputs: -| Name | Type | Description | -| --------------------------- | ------- | --------------------------------------------------------- | -| `test_passed` | String | The status of the e2e_run (true if passed, false if not) +| Name | Type | Description | +| ------------- | ------ | -------------------------------------------------------- | +| `test_passed` | String | The status of the e2e_run (true if passed, false if not) | ## Example Usage diff --git a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/action.yml b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/action.yml index 927bdb0a..f434bcc2 100644 --- a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/action.yml +++ b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/action.yml @@ -2,21 +2,21 @@ name: Triggers tests in other repos and waits for the results inputs: e2e_pass_on_error: - description: "Pass the workflow even if the E2E test fail" + description: 'Pass the workflow even if the E2E test fail' required: false default: false type: boolean e2e_auto: - description: "A J1 token for kicking off cypress tests" + description: 'A J1 token for kicking off cypress tests' required: true repo_name: - description: "The name of the repo to target" + description: 'The name of the repo to target' required: true repo_spec: - description: "The name of the spec(s) to target" + description: 'The name of the spec(s) to target' required: true pr_branch: - description: "The name of the branch associated with this trigger" + description: 'The name of the branch associated with this trigger' required: true outputs: @@ -24,7 +24,7 @@ outputs: value: ${{ steps.test_results.outputs.test_passed }} runs: - using: "composite" + using: 'composite' steps: - name: e2e_trigger_remote_tests_inputs shell: bash @@ -49,7 +49,14 @@ runs: # This is the name of the file in the external repo that we're kicking the tests off in, do not change this! workflow_file_name: e2e_trigger.yml propagate_failure: ${{ !fromJSON(inputs.e2e_pass_on_error) }} - client_payload: '{"spec_to_run":"${{ inputs.repo_spec }}","external_pr_number":"${{ github.event.issue.number }}","external_pr_title":"${{ github.event.issue.title }}","external_pr_repo_name":"${{ github.event.repository.name }}","external_pr_branch":"${{ inputs.pr_branch }}","external_pr_author":"${{ steps.get_author_name.outputs.commit_info_author }}","external_pr_sha":"${{ github.sha }}"}' + client_payload: + '{"spec_to_run":"${{ inputs.repo_spec }}","external_pr_number":"${{ + github.event.issue.number }}","external_pr_title":"${{ + github.event.issue.title }}","external_pr_repo_name":"${{ + github.event.repository.name }}","external_pr_branch":"${{ + inputs.pr_branch }}","external_pr_author":"${{ + steps.get_author_name.outputs.commit_info_author + }}","external_pr_sha":"${{ github.sha }}"}' # We have to manually output an exit code of 0 to ensure the action passes if e2e_pass_on_error is true - name: pass_with_failures shell: bash @@ -59,14 +66,19 @@ runs: shell: bash # Need to check previous TEST_PASSED to ensure it hasn't already failed # important if multiple containers are in use to ensure the correct status is reported - if: ${{ contains(steps.cypress_run.outcome, 'success') || contains(steps.mock_step.outcome, 'success') && !contains(env.TEST_PASSED, false) }} + if: + ${{ contains(steps.cypress_run.outcome, 'success') || + contains(steps.mock_step.outcome, 'success') && + !contains(env.TEST_PASSED, false) }} run: echo "TEST_PASSED=true" >> $GITHUB_ENV - name: set_failure_vars shell: bash - if: ${{ !contains(steps.cypress_run.outcome, 'success') || contains(steps.mock_step.outcome, 'success') }} + if: + ${{ !contains(steps.cypress_run.outcome, 'success') || + contains(steps.mock_step.outcome, 'success') }} run: echo "TEST_PASSED=false" >> $GITHUB_ENV - name: test_results id: test_results shell: bash run: | - echo "test_passed=${{ env.TEST_PASSED }}" >> $GITHUB_OUTPUT \ No newline at end of file + echo "test_passed=${{ env.TEST_PASSED }}" >> $GITHUB_OUTPUT diff --git a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/mocks.ts b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/mocks.ts index 38e9e13d..47fecbf5 100644 --- a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/mocks.ts +++ b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/mocks.ts @@ -3,6 +3,4 @@ This file is automatically leveraged when tests are run to determine which steps should be skipped in the composite action. If these steps were not mocked, they would break the test. */ -export const E2E_TRIGGER_MOCK_STEPS = [ - { name: 'cypress_run' }, -]; +export const E2E_TRIGGER_MOCK_STEPS = [{ name: 'cypress_run' }]; diff --git a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/test/action.test.ts b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/test/action.test.ts index 28afc0dd..ccb1211d 100644 --- a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/test/action.test.ts +++ b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/test/action.test.ts @@ -1,6 +1,9 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; -import { getCompositeActionConfig, runCompositeAction } from 'tests/utils/setup'; +import { + getCompositeActionConfig, + runCompositeAction, +} from 'tests/utils/setup'; import { getTestResult } from 'tests/utils/helpers'; import { E2E_TRIGGER_MOCK_STEPS } from './mocks'; @@ -9,8 +12,10 @@ const repoName = 'e2e_trigger_remote_tests'; let mockGithub: MockGithub; beforeEach(async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ directory: __dirname, repoName })); - + mockGithub = new MockGithub( + getCompositeActionConfig({ directory: __dirname, repoName }) + ); + await mockGithub.setup(); }); @@ -22,12 +27,12 @@ test('output of test_passed is true when cypress_run is successful', async () => const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), repoName, - originDirectory: __dirname + originDirectory: __dirname, }); const result = getTestResult({ results, - name: 'e2e_run_status' + name: 'e2e_run_status', }); expect(result.output).toEqual('e2e_run status is true'); @@ -41,12 +46,12 @@ test('stops at cypress_run step if tests fail', async () => { mockSteps: [ ...E2E_TRIGGER_MOCK_STEPS, { name: 'cypress_run', mockWith: 'exit 1' }, - ] + ], }); const result = getTestResult({ results, - name: 'test_results' + name: 'test_results', }); // The test_results step is never hit diff --git a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/test/action_test.yml b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/test/action_test.yml index cd19dc44..250c90e3 100644 --- a/.github/actions/frontend/runtime/e2e_trigger_remote_tests/test/action_test.yml +++ b/.github/actions/frontend/runtime/e2e_trigger_remote_tests/test/action_test.yml @@ -1,5 +1,5 @@ on: [push] - + jobs: e2e_trigger_remote_tests: runs-on: ubuntu-latest @@ -14,5 +14,7 @@ jobs: repo_name: test_repo repo_spec: test_spec - name: e2e_run_status - run: echo e2e_run status is ${{ steps.e2e_trigger_remote_tests_results.outputs.test_passed }} - shell: bash \ No newline at end of file + run: + echo e2e_run status is ${{ + steps.e2e_trigger_remote_tests_results.outputs.test_passed }} + shell: bash diff --git a/.github/actions/frontend/runtime/magic_url/README.md b/.github/actions/frontend/runtime/magic_url/README.md index cb04e89e..580ad307 100644 --- a/.github/actions/frontend/runtime/magic_url/README.md +++ b/.github/actions/frontend/runtime/magic_url/README.md @@ -1,18 +1,20 @@ # Frontend Runtime - Magic Url -This [composite action](./action.yml) is responsible for deploying the built artifacts to the appropriate S3 bucket, and then showing a `magic url link` in the PR as a status update. +This [composite action](./action.yml) is responsible for deploying the built +artifacts to the appropriate S3 bucket, and then showing a `magic url link` in +the PR as a status update. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `migration_number` | String | | True | The migration number defined in the root package.json -| `magic_url_route` | String | '/' | False | The relative route the magic url should go to -| `github_token` | String | | True | Github access token -| `pr_number` | String | | True | The number associated with the PR that is triggering this action - +| Name | Type | Default | Required | Description | +| ------------------ | ------ | ------- | -------- | ---------------------------------------------------------------- | +| `migration_number` | String | | True | The migration number defined in the root package.json | +| `magic_url_route` | String | '/' | False | The relative route the magic url should go to | +| `github_token` | String | | True | Github access token | +| `pr_number` | String | | True | The number associated with the PR that is triggering this action | + ## Outputs No outputs provided. diff --git a/.github/actions/frontend/runtime/magic_url/action.yml b/.github/actions/frontend/runtime/magic_url/action.yml index ab3ad609..6ccb80ef 100644 --- a/.github/actions/frontend/runtime/magic_url/action.yml +++ b/.github/actions/frontend/runtime/magic_url/action.yml @@ -9,17 +9,18 @@ inputs: description: 'The migration number defined in the root package.json' required: true type: string - magic_url_route: + magic_url_route: description: 'The relative route the magic url should go to' type: string default: '/' - pr_number: - description: 'The number associated with the PR that is triggering this action' + pr_number: + description: + 'The number associated with the PR that is triggering this action' type: string required: true runs: - using: "composite" + using: 'composite' steps: - name: magic_url_inputs shell: bash @@ -50,4 +51,7 @@ runs: token: ${{ inputs.github_token }} status: success context: 'Magic URL' - targetUrl: https://apps.dev.jupiterone.io${{ inputs.magic_url_route }}?magic2=%7B%22${{ github.event.repository.name }}%40${{ inputs.migration_number }}%22:%22PR-${{ inputs.pr_number }}%22%7D \ No newline at end of file + targetUrl: + https://apps.dev.jupiterone.io${{ inputs.magic_url_route + }}?magic2=%7B%22${{ github.event.repository.name }}%40${{ + inputs.migration_number }}%22:%22PR-${{ inputs.pr_number }}%22%7D diff --git a/.github/actions/frontend/runtime/migration_number/README.md b/.github/actions/frontend/runtime/migration_number/README.md index 1a2557e3..c2892ff4 100644 --- a/.github/actions/frontend/runtime/migration_number/README.md +++ b/.github/actions/frontend/runtime/migration_number/README.md @@ -1,6 +1,7 @@ # Frontend Runtime - Extract Migration Number -This [composite action](./action.yml) is responsible for extracting the `migration` number from the root `package.json` file. +This [composite action](./action.yml) is responsible for extracting the +`migration` number from the root `package.json` file. ## Inputs @@ -10,9 +11,9 @@ No inputs necessary. This action returns the following outputs: -| Name | Type | Description | -| --------------------------- | ------- | ------------------------------------------------------------- | -| `migration` | String | Returns the migration number defined in the root package.json +| Name | Type | Description | +| ----------- | ------ | ------------------------------------------------------------- | +| `migration` | String | Returns the migration number defined in the root package.json | ## Example Usage diff --git a/.github/actions/frontend/runtime/migration_number/action.yml b/.github/actions/frontend/runtime/migration_number/action.yml index 81eb298c..89afae71 100644 --- a/.github/actions/frontend/runtime/migration_number/action.yml +++ b/.github/actions/frontend/runtime/migration_number/action.yml @@ -5,11 +5,10 @@ outputs: value: ${{ steps.get_migration_number.outputs.migration }} runs: - using: "composite" + using: 'composite' steps: - id: get_migration_number name: get_migration_number shell: bash run: | echo "migration=$(jq -r .config.migration < package.json)" >> $GITHUB_OUTPUT - diff --git a/.github/actions/frontend/runtime/migration_number/test/action.test.ts b/.github/actions/frontend/runtime/migration_number/test/action.test.ts index 384fd1cc..0728c289 100644 --- a/.github/actions/frontend/runtime/migration_number/test/action.test.ts +++ b/.github/actions/frontend/runtime/migration_number/test/action.test.ts @@ -1,6 +1,9 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; -import { getCompositeActionConfig, runCompositeAction } from 'tests/utils/setup'; +import { + getCompositeActionConfig, + runCompositeAction, +} from 'tests/utils/setup'; import mockPackageJson from 'tests/package.json'; import { getTestResult } from 'tests/utils/helpers'; @@ -9,8 +12,10 @@ const repoName = 'migration_number'; let mockGithub: MockGithub; beforeEach(async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ directory: __dirname, repoName })); - + mockGithub = new MockGithub( + getCompositeActionConfig({ directory: __dirname, repoName }) + ); + await mockGithub.setup(); }); @@ -22,10 +27,12 @@ test('migration number from package.json is returned', async () => { const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), repoName, - originDirectory: __dirname + originDirectory: __dirname, }); const result = getTestResult({ results, name: 'print_migration_number' }); - expect(result.output).toEqual(`migration_number ${mockPackageJson.config.migration}`); -}); \ No newline at end of file + expect(result.output).toEqual( + `migration_number ${mockPackageJson.config.migration}` + ); +}); diff --git a/.github/actions/frontend/runtime/migration_number/test/action_test.yml b/.github/actions/frontend/runtime/migration_number/test/action_test.yml index b7e688b4..27be7dd2 100644 --- a/.github/actions/frontend/runtime/migration_number/test/action_test.yml +++ b/.github/actions/frontend/runtime/migration_number/test/action_test.yml @@ -1,5 +1,5 @@ on: [push] - + jobs: migration_number: runs-on: ubuntu-latest @@ -12,5 +12,6 @@ jobs: - id: migration_number uses: ./migration_number - name: print_migration_number - run: echo migration_number ${{ steps.migration_number.outputs.migration }} - shell: bash \ No newline at end of file + run: + echo migration_number ${{ steps.migration_number.outputs.migration }} + shell: bash diff --git a/.github/actions/frontend/runtime/remote_types_install/README.md b/.github/actions/frontend/runtime/remote_types_install/README.md index 05eca0f9..484008b8 100644 --- a/.github/actions/frontend/runtime/remote_types_install/README.md +++ b/.github/actions/frontend/runtime/remote_types_install/README.md @@ -1,10 +1,11 @@ # Frontend Runtime - Install Remote Types -This [composite action](./action.yml) is responsible for installing the remote types for a runtime. +This [composite action](./action.yml) is responsible for installing the remote +types for a runtime. ## Inputs -No inputs necessary. +No inputs necessary. ## Outputs diff --git a/.github/actions/frontend/runtime/remote_types_install/action.yml b/.github/actions/frontend/runtime/remote_types_install/action.yml index 26b1eed4..ca3e70e7 100644 --- a/.github/actions/frontend/runtime/remote_types_install/action.yml +++ b/.github/actions/frontend/runtime/remote_types_install/action.yml @@ -1,9 +1,8 @@ name: Installs the remote-types if applicable runs: - using: "composite" + using: 'composite' steps: - name: install_remote_types run: npm run postinstall --if-present && npm run dependencies --if-present shell: bash - diff --git a/.github/actions/frontend/runtime/remote_types_tests/README.md b/.github/actions/frontend/runtime/remote_types_tests/README.md index 57ec0a8e..2d0dbfa0 100644 --- a/.github/actions/frontend/runtime/remote_types_tests/README.md +++ b/.github/actions/frontend/runtime/remote_types_tests/README.md @@ -1,10 +1,11 @@ # Frontend Runtime - Test Remote Types -This [composite action](./action.yml) is responsible for testing the remote types for a runtime and identifying breaking changes. +This [composite action](./action.yml) is responsible for testing the remote +types for a runtime and identifying breaking changes. ## Inputs -No inputs necessary. +No inputs necessary. ## Outputs diff --git a/.github/actions/frontend/runtime/remote_types_tests/action.yml b/.github/actions/frontend/runtime/remote_types_tests/action.yml index 232c59f7..eddea14f 100644 --- a/.github/actions/frontend/runtime/remote_types_tests/action.yml +++ b/.github/actions/frontend/runtime/remote_types_tests/action.yml @@ -1,7 +1,9 @@ -name: Run the remote-types test to look for breaking changes made. Will skip the test if "skip remote-type-check" is found. +name: + Run the remote-types test to look for breaking changes made. Will skip the + test if "skip remote-type-check" is found. runs: - using: "composite" + using: 'composite' steps: # Check if we should skip validating runtime types - name: remote_type_check_skip @@ -20,4 +22,3 @@ runs: run: | npx -p @jupiterone/web-tools-remote-types@latest remote-types test echo "No breaking changes found"; - diff --git a/.github/actions/frontend/runtime/remote_types_tests/mocks.ts b/.github/actions/frontend/runtime/remote_types_tests/mocks.ts index e6b56a6e..ea20cee7 100644 --- a/.github/actions/frontend/runtime/remote_types_tests/mocks.ts +++ b/.github/actions/frontend/runtime/remote_types_tests/mocks.ts @@ -3,6 +3,4 @@ This file is automatically leveraged when tests are run to determine which steps should be skipped in the composite action. If these steps were not mocked, they would break the test. */ -export const REMOTE_TYPES_TESTS_MOCK_STEPS = [ - { name: 'remote_type_test' }, -]; +export const REMOTE_TYPES_TESTS_MOCK_STEPS = [{ name: 'remote_type_test' }]; diff --git a/.github/actions/frontend/runtime/remote_types_tests/test/action.test.ts b/.github/actions/frontend/runtime/remote_types_tests/test/action.test.ts index 61ef8016..1ab33922 100644 --- a/.github/actions/frontend/runtime/remote_types_tests/test/action.test.ts +++ b/.github/actions/frontend/runtime/remote_types_tests/test/action.test.ts @@ -1,6 +1,9 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; -import { getCompositeActionConfig, runCompositeAction } from 'tests/utils/setup'; +import { + getCompositeActionConfig, + runCompositeAction, +} from 'tests/utils/setup'; import { getTestResult } from 'tests/utils/helpers'; const repoName = 'validate'; @@ -12,18 +15,20 @@ afterEach(async () => { }); test('remote types test is called', async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ - directory: __dirname, - repoName, - actionTriggeringComposite: 'action_test_default.yml' - })); - + mockGithub = new MockGithub( + getCompositeActionConfig({ + directory: __dirname, + repoName, + actionTriggeringComposite: 'action_test_default.yml', + }) + ); + await mockGithub.setup(); const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), repoName, - originDirectory: __dirname + originDirectory: __dirname, }); const result = getTestResult({ results, name: 'remote_type_test' }); @@ -32,21 +37,23 @@ test('remote types test is called', async () => { }); test('remote types test is skipped if HAS_SKIP is present', async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ - directory: __dirname, - repoName, - actionTriggeringComposite: 'action_test_skip.yml' - })); - + mockGithub = new MockGithub( + getCompositeActionConfig({ + directory: __dirname, + repoName, + actionTriggeringComposite: 'action_test_skip.yml', + }) + ); + await mockGithub.setup(); - + const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), repoName, - originDirectory: __dirname + originDirectory: __dirname, }); const result = getTestResult({ results, name: 'remote_type_test' }); expect(result).toBeUndefined(); -}); \ No newline at end of file +}); diff --git a/.github/actions/frontend/runtime/remote_types_tests/test/action_test_default.yml b/.github/actions/frontend/runtime/remote_types_tests/test/action_test_default.yml index 9b8965d2..f9825837 100644 --- a/.github/actions/frontend/runtime/remote_types_tests/test/action_test_default.yml +++ b/.github/actions/frontend/runtime/remote_types_tests/test/action_test_default.yml @@ -10,4 +10,4 @@ jobs: with: path: validate - id: validate - uses: ./validate \ No newline at end of file + uses: ./validate diff --git a/.github/actions/frontend/runtime/remote_types_tests/test/action_test_skip.yml b/.github/actions/frontend/runtime/remote_types_tests/test/action_test_skip.yml index f45fc4e5..32cf30ab 100644 --- a/.github/actions/frontend/runtime/remote_types_tests/test/action_test_skip.yml +++ b/.github/actions/frontend/runtime/remote_types_tests/test/action_test_skip.yml @@ -12,4 +12,4 @@ jobs: - id: validate uses: ./validate env: - HAS_SKIP: true \ No newline at end of file + HAS_SKIP: true diff --git a/.github/actions/get_branch/README.md b/.github/actions/get_branch/README.md index 51eed5dd..71f2ba40 100644 --- a/.github/actions/get_branch/README.md +++ b/.github/actions/get_branch/README.md @@ -1,8 +1,16 @@ # Get Branch -This [composite action](./action.yml) is responsible for returning the name of the pull request branch the comment belongs to. - -This is useful for workflows that use pull request comments that are triggered using the `issue_comment` event. The issue_comment event runs on the default branch (usually main or master) of the repository, and **not on the branch of the pull request**. This means that if you are using the issue_comment event to trigger a workflow that performs actions on the branch of the pull request, you will need to take additional steps to reference the correct branch. This action lets you determine the branch associated with the PR, and then in the checkout action reference the appropriate branch (via `with: ref`). +This [composite action](./action.yml) is responsible for returning the name of +the pull request branch the comment belongs to. + +This is useful for workflows that use pull request comments that are triggered +using the `issue_comment` event. The issue_comment event runs on the default +branch (usually main or master) of the repository, and **not on the branch of +the pull request**. This means that if you are using the issue_comment event to +trigger a workflow that performs actions on the branch of the pull request, you +will need to take additional steps to reference the correct branch. This action +lets you determine the branch associated with the PR, and then in the checkout +action reference the appropriate branch (via `with: ref`). ## Inputs @@ -12,16 +20,18 @@ No inputs necessary. This action returns the following outputs: -| Name | Type | Description | -| --------------------------- | ------- | ------------------------------------------------------------- | -| `name` | String | The name of the pull request branch the comment belongs to. +| Name | Type | Description | +| ------ | ------ | ----------------------------------------------------------- | +| `name` | String | The name of the pull request branch the comment belongs to. | ## Example Usage ```yaml jobs: get_branch: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} outputs: name: ${{ steps.get_branch.outputs.name }} steps: @@ -30,7 +40,9 @@ jobs: uses: jupiterone/.github/.github/actions/get_branch@v3 example_job: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch] steps: - uses: actions/checkout@v3 diff --git a/.github/actions/get_branch/action.yml b/.github/actions/get_branch/action.yml index 0dd5098d..2c651835 100644 --- a/.github/actions/get_branch/action.yml +++ b/.github/actions/get_branch/action.yml @@ -5,8 +5,8 @@ outputs: value: ${{ steps.comment_branch.outputs.head_ref }} runs: - using: "composite" + using: 'composite' steps: - id: comment_branch name: comment_branch - uses: xt0rted/pull-request-comment-branch@v2 \ No newline at end of file + uses: xt0rted/pull-request-comment-branch@v2 diff --git a/.github/actions/get_branch/mocks.ts b/.github/actions/get_branch/mocks.ts index a30cc4c8..40f9004e 100644 --- a/.github/actions/get_branch/mocks.ts +++ b/.github/actions/get_branch/mocks.ts @@ -3,6 +3,4 @@ This file is automatically leveraged when tests are run to determine which steps should be skipped in the composite action. If these steps were not mocked, they would break the test. */ -export const E2E_GET_BRANCH_MOCK_STEPS = [ - { name: 'comment_branch' }, -]; +export const E2E_GET_BRANCH_MOCK_STEPS = [{ name: 'comment_branch' }]; diff --git a/.github/actions/pr_comment/README.md b/.github/actions/pr_comment/README.md index 1948a8a9..ec381f53 100644 --- a/.github/actions/pr_comment/README.md +++ b/.github/actions/pr_comment/README.md @@ -1,19 +1,21 @@ # PR Comment -This [composite action](./action.yml) is responsible for leaving a comment on a PR. By default it will only leave a comment once of the same message (i.e. no duplicates), however this can be overridden. +This [composite action](./action.yml) is responsible for leaving a comment on a +PR. By default it will only leave a comment once of the same message (i.e. no +duplicates), however this can be overridden. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `message` | String | | True | The message to leave in the PR comment -| `run_once` | Boolean | True | False | Determines whether to leave one comment or add one on each call - +| Name | Type | Default | Required | Description | +| ---------- | ------- | ------- | -------- | --------------------------------------------------------------- | +| `message` | String | | True | The message to leave in the PR comment | +| `run_once` | Boolean | True | False | Determines whether to leave one comment or add one on each call | + ## Outputs -No outputs provided. +No outputs provided. ## Example Usage diff --git a/.github/actions/pr_comment/action.yml b/.github/actions/pr_comment/action.yml index d4debfbd..87a0cb19 100644 --- a/.github/actions/pr_comment/action.yml +++ b/.github/actions/pr_comment/action.yml @@ -9,7 +9,7 @@ inputs: default: true runs: - using: "composite" + using: 'composite' steps: - name: pr_comment_inputs shell: bash @@ -24,7 +24,9 @@ runs: body-includes: ${{ inputs.message }} direction: last - name: add_pr_comment_once - if: ${{ fromJSON(inputs.run_once) && !contains(steps.find_comment.outputs.comment-body, inputs.message) }} + if: + ${{ fromJSON(inputs.run_once) && + !contains(steps.find_comment.outputs.comment-body, inputs.message) }} uses: actions/github-script@v6 with: script: | @@ -48,4 +50,4 @@ runs: owner: context.repo.owner, repo: context.repo.repo, body - }) \ No newline at end of file + }) diff --git a/.github/actions/pr_comment/mocks.ts b/.github/actions/pr_comment/mocks.ts index c6826d61..ff3f089f 100644 --- a/.github/actions/pr_comment/mocks.ts +++ b/.github/actions/pr_comment/mocks.ts @@ -6,5 +6,5 @@ mocked, they would break the test. export const PR_COMMENT_MOCK_STEPS = [ { name: 'find_comment' }, { name: 'add_pr_comment_once' }, - { name: 'add_pr_comment_always' } + { name: 'add_pr_comment_always' }, ]; diff --git a/.github/actions/pr_comment/test/action.test.ts b/.github/actions/pr_comment/test/action.test.ts index 90a4e14b..71b4a4c6 100644 --- a/.github/actions/pr_comment/test/action.test.ts +++ b/.github/actions/pr_comment/test/action.test.ts @@ -1,6 +1,9 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; -import { getCompositeActionConfig, runCompositeAction } from 'tests/utils/setup'; +import { + getCompositeActionConfig, + runCompositeAction, +} from 'tests/utils/setup'; import { getTestResult } from 'tests/utils/helpers'; import { PR_COMMENT_MOCK_STEPS } from '../mocks'; @@ -13,16 +16,18 @@ afterEach(async () => { }); test('default flow assuming a new comment has been added', async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ - directory: __dirname, - repoName, - actionTriggeringComposite: 'action_test_default.yml' - })); + mockGithub = new MockGithub( + getCompositeActionConfig({ + directory: __dirname, + repoName, + actionTriggeringComposite: 'action_test_default.yml', + }) + ); await mockGithub.setup(); // This is a different comment than the one in the action_test_default.yml - const comment = "This is a test comment"; + const comment = 'This is a test comment'; const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), @@ -30,29 +35,34 @@ test('default flow assuming a new comment has been added', async () => { originDirectory: __dirname, mockSteps: [ ...PR_COMMENT_MOCK_STEPS, - { name: 'find_comment', mockWith: `echo "comment-body=${comment}" >> "$GITHUB_OUTPUT"` }, - ] + { + name: 'find_comment', + mockWith: `echo "comment-body=${comment}" >> "$GITHUB_OUTPUT"`, + }, + ], }); const result = getTestResult({ results, - name: 'add_pr_comment_once' + name: 'add_pr_comment_once', }); expect(result).toBeDefined(); }); test('attempting to add the same comment twice when run_once is true', async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ - directory: __dirname, - repoName, - actionTriggeringComposite: 'action_test_default.yml' - })); + mockGithub = new MockGithub( + getCompositeActionConfig({ + directory: __dirname, + repoName, + actionTriggeringComposite: 'action_test_default.yml', + }) + ); await mockGithub.setup(); // This is the same comment left in the action_test_default.yml - const comment = "hello world"; + const comment = 'hello world'; const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), @@ -60,29 +70,34 @@ test('attempting to add the same comment twice when run_once is true', async () originDirectory: __dirname, mockSteps: [ ...PR_COMMENT_MOCK_STEPS, - { name: 'find_comment', mockWith: `echo "comment-body=${comment}" >> "$GITHUB_OUTPUT"` }, - ] + { + name: 'find_comment', + mockWith: `echo "comment-body=${comment}" >> "$GITHUB_OUTPUT"`, + }, + ], }); const result = getTestResult({ results, - name: 'add_pr_comment_once' + name: 'add_pr_comment_once', }); expect(result).not.toBeDefined(); }); test('a comment is left even when there is a duplicate when run_once is false', async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ - directory: __dirname, - repoName, - actionTriggeringComposite: 'action_test_always.yml' - })); + mockGithub = new MockGithub( + getCompositeActionConfig({ + directory: __dirname, + repoName, + actionTriggeringComposite: 'action_test_always.yml', + }) + ); await mockGithub.setup(); // This is the same comment left in the action_test_default.yml - const comment = "hello world"; + const comment = 'hello world'; const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), @@ -90,13 +105,16 @@ test('a comment is left even when there is a duplicate when run_once is false', originDirectory: __dirname, mockSteps: [ ...PR_COMMENT_MOCK_STEPS, - { name: 'find_comment', mockWith: `echo "comment-body=${comment}" >> "$GITHUB_OUTPUT"` }, - ] + { + name: 'find_comment', + mockWith: `echo "comment-body=${comment}" >> "$GITHUB_OUTPUT"`, + }, + ], }); const result = getTestResult({ results, - name: 'add_pr_comment_always' + name: 'add_pr_comment_always', }); expect(result).toBeDefined(); diff --git a/.github/actions/pr_comment/test/action_test_always.yml b/.github/actions/pr_comment/test/action_test_always.yml index c2351165..6a5b7773 100644 --- a/.github/actions/pr_comment/test/action_test_always.yml +++ b/.github/actions/pr_comment/test/action_test_always.yml @@ -1,5 +1,5 @@ on: [push] - + jobs: pr_comment: runs-on: ubuntu-latest @@ -13,4 +13,4 @@ jobs: uses: ./pr_comment with: run_once: false - message: "hello world" \ No newline at end of file + message: 'hello world' diff --git a/.github/actions/pr_comment/test/action_test_default.yml b/.github/actions/pr_comment/test/action_test_default.yml index 10d021df..88196cb9 100644 --- a/.github/actions/pr_comment/test/action_test_default.yml +++ b/.github/actions/pr_comment/test/action_test_default.yml @@ -1,5 +1,5 @@ on: [push] - + jobs: pr_comment: runs-on: ubuntu-latest @@ -12,4 +12,4 @@ jobs: - id: pr_comment uses: ./pr_comment with: - message: "hello world" \ No newline at end of file + message: 'hello world' diff --git a/.github/actions/promote_docker_image/README.md b/.github/actions/promote_docker_image/README.md index 61adfabf..60c1e766 100644 --- a/.github/actions/promote_docker_image/README.md +++ b/.github/actions/promote_docker_image/README.md @@ -1,21 +1,23 @@ # Promote Docker Image -This [composite action](./action.yml) is responsible copying docker images from one ECR registry to another (typically from jupiterone-infra to the destination environment where the app is run). +This [composite action](./action.yml) is responsible copying docker images from +one ECR registry to another (typically from jupiterone-infra to the destination +environment where the app is run). ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `project_name` | String | | True | The project name -| `codeowner` | String | | True | The designated project codeowners (CODEOWNERS file) -| `image_name` | String | | True | The name of the image to copy -| `source_account_id` | String | | False | The AWS account id of the source ECR registry -| `source_region` | String | | False | The AWS region of the source ECR registry -| `target_account_id` | String | | True | The AWS account id of the target ECR registry -| `target_region` | String | | True | The AWS region of the target ECR registry -| `target_environment` | String | | True | The target Jupiterone environment to deploy to +| Name | Type | Default | Required | Description | +| -------------------- | ------ | ------- | -------- | --------------------------------------------------- | +| `project_name` | String | | True | The project name | +| `codeowner` | String | | True | The designated project codeowners (CODEOWNERS file) | +| `image_name` | String | | True | The name of the image to copy | +| `source_account_id` | String | | False | The AWS account id of the source ECR registry | +| `source_region` | String | | False | The AWS region of the source ECR registry | +| `target_account_id` | String | | True | The AWS account id of the target ECR registry | +| `target_region` | String | | True | The AWS region of the target ECR registry | +| `target_environment` | String | | True | The target Jupiterone environment to deploy to | ## Outputs diff --git a/.github/actions/promote_docker_image/action.yml b/.github/actions/promote_docker_image/action.yml index 89984705..95551bcd 100644 --- a/.github/actions/promote_docker_image/action.yml +++ b/.github/actions/promote_docker_image/action.yml @@ -1,4 +1,5 @@ -name: Promotes built Docker images to target environment registries for consumption +name: + Promotes built Docker images to target environment registries for consumption inputs: project_name: @@ -12,7 +13,7 @@ inputs: description: A comma separated list of image tags to promote. source_account_id: required: false - default: "081157560428" + default: '081157560428' source_region: required: false default: us-east-1 @@ -25,12 +26,13 @@ inputs: default: dev runs: - using: "composite" + using: 'composite' steps: - name: configure_source_account_aws_credentials uses: aws-actions/configure-aws-credentials@v3 with: - role-to-assume: arn:aws:iam::${{ inputs.source_account_id }}:role/github-main-role + role-to-assume: + arn:aws:iam::${{ inputs.source_account_id }}:role/github-main-role role-session-name: main-role-session-${{ inputs.image_name }} aws-region: us-east-1 - name: ecr_login @@ -52,7 +54,8 @@ runs: - name: configure_target_account_aws_credentials uses: aws-actions/configure-aws-credentials@v3 with: - role-to-assume: arn:aws:iam::${{ inputs.target_account_id }}:role/github-main-role + role-to-assume: + arn:aws:iam::${{ inputs.target_account_id }}:role/github-main-role role-session-name: main-role-session-${{ inputs.image_name }} aws-region: us-east-1 - name: copy_to_target_registry diff --git a/.github/actions/setup_env/README.md b/.github/actions/setup_env/README.md index 0b8c95e2..08f0b84c 100644 --- a/.github/actions/setup_env/README.md +++ b/.github/actions/setup_env/README.md @@ -1,14 +1,15 @@ # Setup Environment -This [composite action](./action.yml) is responsible for setting up node and installing production dependencies. +This [composite action](./action.yml) is responsible for setting up node and +installing production dependencies. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `use_dev` | Boolean | False | False | If true, will install dev dependencies. +| Name | Type | Default | Required | Description | +| --------- | ------- | ------- | -------- | --------------------------------------- | +| `use_dev` | Boolean | False | False | If true, will install dev dependencies. | ## Outputs diff --git a/.github/actions/slack_notifier/README.md b/.github/actions/slack_notifier/README.md index c08e33d9..cf7b77b9 100644 --- a/.github/actions/slack_notifier/README.md +++ b/.github/actions/slack_notifier/README.md @@ -1,15 +1,16 @@ # Code QL -This [composite action](./action.yml) is responsible for sending Github workflow build results to Slack to increase visibilty of build pipeline status. +This [composite action](./action.yml) is responsible for sending Github workflow +build results to Slack to increase visibilty of build pipeline status. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `slack_bot_token` | String | | True | The Oauth token for the Github Slack Send Slack app. -| `slack_channel_id` | String | | True | The ID of the Slack channel to send notifications to. +| Name | Type | Default | Required | Description | +| ------------------ | ------ | ------- | -------- | ----------------------------------------------------- | +| `slack_bot_token` | String | | True | The Oauth token for the Github Slack Send Slack app. | +| `slack_channel_id` | String | | True | The ID of the Slack channel to send notifications to. | ## Outputs diff --git a/.github/actions/slack_notifier/action.yml b/.github/actions/slack_notifier/action.yml index cb5f9bbe..6ab778bb 100644 --- a/.github/actions/slack_notifier/action.yml +++ b/.github/actions/slack_notifier/action.yml @@ -1,5 +1,6 @@ name: Slack Notifier -description: Send Slack updates to the provided channel upon workflow completion. +description: + Send Slack updates to the provided channel upon workflow completion. inputs: slack_bot_token: @@ -11,7 +12,7 @@ inputs: required: true runs: - using: "composite" + using: 'composite' steps: - name: set_status_emoji id: setEmoji diff --git a/.github/actions/slack_notifier/test/action.test.ts b/.github/actions/slack_notifier/test/action.test.ts index 7ee63ded..2528148d 100644 --- a/.github/actions/slack_notifier/test/action.test.ts +++ b/.github/actions/slack_notifier/test/action.test.ts @@ -1,6 +1,9 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; -import { getCompositeActionConfig, runCompositeAction } from 'tests/utils/setup'; +import { + getCompositeActionConfig, + runCompositeAction, +} from 'tests/utils/setup'; import { getTestResult } from 'tests/utils/helpers'; const repoName = 'slack_notifier'; @@ -8,7 +11,9 @@ const repoName = 'slack_notifier'; let mockGithub: MockGithub; beforeEach(async () => { - mockGithub = new MockGithub(getCompositeActionConfig({ directory: __dirname, repoName })); + mockGithub = new MockGithub( + getCompositeActionConfig({ directory: __dirname, repoName }) + ); await mockGithub.setup(); }); @@ -17,21 +22,21 @@ afterEach(async () => { await mockGithub.teardown(); }); -const slackBotToken = "mytoken"; -const slackChannelId = "mychannelid"; +const slackBotToken = 'mytoken'; +const slackChannelId = 'mychannelid'; test('Inputs are set correctly', async () => { const results = await runCompositeAction({ act: new Act(mockGithub.repo.getPath(repoName)), repoName, - originDirectory: __dirname + originDirectory: __dirname, }); const result = getTestResult({ results, - name: 'prepare_inputs' + name: 'prepare_inputs', }); const expectedOutput = `slack_bot_token=${slackBotToken}\nslack_channel_id=${slackChannelId}`; - expect(result.output).toEqual(expectedOutput) + expect(result.output).toEqual(expectedOutput); }); diff --git a/.github/actions/slack_notifier/test/action_test.yml b/.github/actions/slack_notifier/test/action_test.yml index abeef043..8949bf6c 100644 --- a/.github/actions/slack_notifier/test/action_test.yml +++ b/.github/actions/slack_notifier/test/action_test.yml @@ -11,4 +11,4 @@ jobs: - uses: ./slack_notifier with: slack_bot_token: 'mytoken' - slack_channel_id: 'mychannelid' \ No newline at end of file + slack_channel_id: 'mychannelid' diff --git a/.github/actions/unique_id/README.md b/.github/actions/unique_id/README.md index 60244819..1397c336 100644 --- a/.github/actions/unique_id/README.md +++ b/.github/actions/unique_id/README.md @@ -1,22 +1,23 @@ # Unique ID -This [composite action](./action.yml) is responsible for generating a unique ID using a timestamp and the current commit SHA. +This [composite action](./action.yml) is responsible for generating a unique ID +using a timestamp and the current commit SHA. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | --------------------------------------------------------- | -| `sha` | String | | True | The github.sha which is the SHA for a temporary commit created for validating the pull request - +| Name | Type | Default | Required | Description | +| ----- | ------ | ------- | -------- | ---------------------------------------------------------------------------------------------- | +| `sha` | String | | True | The github.sha which is the SHA for a temporary commit created for validating the pull request | + ## Outputs This action returns the following outputs: -| Name | Type | Description | -| --------------------------- | ------- | --------------------------------------------------------- | -| `unique_id` | String | An ID that is unique to both the repo and commit +| Name | Type | Description | +| ----------- | ------ | ------------------------------------------------ | +| `unique_id` | String | An ID that is unique to both the repo and commit | ## Example Usage diff --git a/.github/actions/unique_id/action.yml b/.github/actions/unique_id/action.yml index 772eee9e..7b1f3184 100644 --- a/.github/actions/unique_id/action.yml +++ b/.github/actions/unique_id/action.yml @@ -3,7 +3,9 @@ name: Returns a unique ID inputs: sha: type: string - description: 'The github.sha which is the SHA for a temporary commit created for validating the pull request' + description: + 'The github.sha which is the SHA for a temporary commit created for + validating the pull request' required: true outputs: @@ -11,7 +13,7 @@ outputs: value: ${{ steps.unique_id.outputs.value }} runs: - using: "composite" + using: 'composite' steps: - name: unique_id id: unique_id @@ -19,4 +21,5 @@ runs: # take the current commit + timestamp together # the typical value would be something like # "sha-5d3fe...35d3-time-1620841214" - run: echo "value=sha-${{ inputs.sha }}-time-$(date +"%s")" >> $GITHUB_OUTPUT + run: + echo "value=sha-${{ inputs.sha }}-time-$(date +"%s")" >> $GITHUB_OUTPUT diff --git a/.github/actions/validate/README.md b/.github/actions/validate/README.md index 59fee30f..487fd82a 100644 --- a/.github/actions/validate/README.md +++ b/.github/actions/validate/README.md @@ -1,10 +1,13 @@ # Frontend Runtime - Validate -This [composite action](./action.yml) is responsible for running the `validation` command in a frontend repo. Additionally it is responsible for running the `remote-types test` command if applicable to determine if any breaking changes were made. +This [composite action](./action.yml) is responsible for running the +`validation` command in a frontend repo. Additionally it is responsible for +running the `remote-types test` command if applicable to determine if any +breaking changes were made. ## Inputs -No inputs necessary. +No inputs necessary. ## Outputs diff --git a/.github/actions/validate/action.yml b/.github/actions/validate/action.yml index a8b3ba3a..79395c9c 100644 --- a/.github/actions/validate/action.yml +++ b/.github/actions/validate/action.yml @@ -1,9 +1,8 @@ name: Runs validation on the repo runs: - using: "composite" + using: 'composite' steps: - name: validate shell: bash run: npm run validate:ci - diff --git a/.github/actions/validate/mocks.ts b/.github/actions/validate/mocks.ts index c08d2d17..1dc4bea2 100644 --- a/.github/actions/validate/mocks.ts +++ b/.github/actions/validate/mocks.ts @@ -3,6 +3,4 @@ This file is automatically leveraged when tests are run to determine which steps should be skipped in the composite action. If these steps were not mocked, they would break the test. */ -export const VALIDATE_MOCK_STEPS = [ - { name: 'validate' }, -]; +export const VALIDATE_MOCK_STEPS = [{ name: 'validate' }]; diff --git a/.github/actions/version_artifact/README.md b/.github/actions/version_artifact/README.md index 4c591bab..c10736a2 100644 --- a/.github/actions/version_artifact/README.md +++ b/.github/actions/version_artifact/README.md @@ -1,12 +1,13 @@ # Version Artifact This [composite action](./action.yml) is responsible for versioning artifacts. -This does does not include non-npm packages as they have their own -version and release flow. This action will create a new commit with the updated -version and push it back to the main branch. It will also create a new tag, -release, and update the changelog. +This does does not include non-npm packages as they have their own version and +release flow. This action will create a new commit with the updated version and +push it back to the main branch. It will also create a new tag, release, and +update the changelog. -**Note:** Monorepos are not supported and NPM packages should use Auto Shipit instead. +**Note:** Monorepos are not supported and NPM packages should use Auto Shipit +instead. ## Inputs diff --git a/.github/workflows/docs/frontend/frontend_npm_pr.md b/.github/workflows/docs/frontend/frontend_npm_pr.md index 007a9895..0372e494 100644 --- a/.github/workflows/docs/frontend/frontend_npm_pr.md +++ b/.github/workflows/docs/frontend/frontend_npm_pr.md @@ -1,25 +1,27 @@ # Default flow for an NPM package when a PR is opened -This is the [default workflow](../../frontend_npm_pr.yml) that is run when a `PR is opened` for an `npm package`. It is meant to test the quality and safety of the code being committed. +This is the [default workflow](../../frontend_npm_pr.yml) that is run when a +`PR is opened` for an `npm package`. It is meant to test the quality and safety +of the code being committed. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner -| `use_validate` | Boolean | True | False | Run validation, in most case we want this -| `use_chromatic` | Boolean | False | False | Run VRT Storybook tests with chromatic - +| Name | Type | Default | Required | Description | +| ----------------- | ------- | ------- | -------- | --------------------------------------------------------------------------------------- | +| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | +| `use_validate` | Boolean | True | False | Run validation, in most case we want this | +| `use_chromatic` | Boolean | False | False | Run VRT Storybook tests with chromatic | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token -| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token +| Name | Required | Description | +| ------------------------- | -------- | -------------------------- | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | +| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token | ## Example Usage @@ -71,4 +73,3 @@ graph LR; A --> B; A --> C; ``` - diff --git a/.github/workflows/docs/frontend/frontend_npm_release.md b/.github/workflows/docs/frontend/frontend_npm_release.md index 509f66a8..e0125132 100644 --- a/.github/workflows/docs/frontend/frontend_npm_release.md +++ b/.github/workflows/docs/frontend/frontend_npm_release.md @@ -1,27 +1,29 @@ # Default flow for an NPM package when its merged to mai -This is the [default workflow](../../frontend_npm_release.yml) that is run when a `PR is merged to main` for an `npm package`. It is meant to release the package and capture information in Cortex related to the package. +This is the [default workflow](../../frontend_npm_release.yml) that is run when +a `PR is merged to main` for an `npm package`. It is meant to release the +package and capture information in Cortex related to the package. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner -| `use_chromatic` | Boolean | False | False | Run VRT Storybook tests with chromatic -| `use_cortex` | Boolean | True | False | Runs the Cortex job. We eventually want to make this required but we need to make sure we don't break the pipeline. - +| Name | Type | Default | Required | Description | +| ----------------- | ------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------- | +| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | +| `use_chromatic` | Boolean | False | False | Run VRT Storybook tests with chromatic | +| `use_cortex` | Boolean | True | False | Runs the Cortex job. We eventually want to make this required but we need to make sure we don't break the pipeline. | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token -| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token -| `AUTO_GITHUB_PAT_TOKEN` | True | This is a GitHuh PAT that let's auto write back to main after npm versioning -| `CORTEX_API_KEY` | False | A key that allows us to push data to Cortex +| Name | Required | Description | +| ------------------------- | -------- | ---------------------------------------------------------------------------- | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | +| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token | +| `AUTO_GITHUB_PAT_TOKEN` | True | This is a GitHuh PAT that let's auto write back to main after npm versioning | +| `CORTEX_API_KEY` | False | A key that allows us to push data to Cortex | ## Example Usage @@ -35,7 +37,7 @@ jobs: uses: jupiterone/.github/.github/workflows/frontend_npm_release.yml@v# secrets: NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - AUTO_GITHUB_PAT_TOKEN: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }} + AUTO_GITHUB_PAT_TOKEN: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }} ``` #### Diagram @@ -64,7 +66,7 @@ jobs: use_chromatic: true secrets: NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - AUTO_GITHUB_PAT_TOKEN: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }} + AUTO_GITHUB_PAT_TOKEN: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }} CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} ``` diff --git a/.github/workflows/docs/frontend/frontend_runtime_application_manual_e2e_run.md b/.github/workflows/docs/frontend/frontend_runtime_application_manual_e2e_run.md index b60f8780..10f214fb 100644 --- a/.github/workflows/docs/frontend/frontend_runtime_application_manual_e2e_run.md +++ b/.github/workflows/docs/frontend/frontend_runtime_application_manual_e2e_run.md @@ -1,11 +1,14 @@ # Default workflow for running E2E tests when a PR comment is left - -This is the [default workflow](../../frontend_runtime_application_manual_e2e_run.yml) that is leveraged to trigger E2E tests for for an `application runtime`. Specifically, when a PR is opened and a comment of `/run-e2e-tests` is left, it will trigger an E2E test run. +This is the +[default workflow](../../frontend_runtime_application_manual_e2e_run.yml) that +is leveraged to trigger E2E tests for for an `application runtime`. +Specifically, when a PR is opened and a comment of `/run-e2e-tests` is left, it +will trigger an E2E test run. **Note:** -You will notice that each job checks out the branch repo as shown here. +You will notice that each job checks out the branch repo as shown here. ```yaml - uses: actions/checkout@v3 @@ -13,36 +16,37 @@ You will notice that each job checks out the branch repo as shown here. ref: ${{ needs.get_branch.outputs.ref }} ``` -Please read about why this is necessary in the [get_branch README](../../../actions/get_branch/README.md). +Please read about why this is necessary in the +[get_branch README](../../../actions/get_branch/README.md). ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner -| `use_magic_url` | Boolean | True | False | Deploy to dev via a query param, required for normal SPAs -| `use_e2e` | Boolean | False | False | Run E2E test, in most case we want this -| `e2e_filter_tags` | String | | False | Tests will be filtered based on the tags defined here -| `e2e_containers` | String | '["1"]' | False | The number of tests that you want Cypress to run in parallel. For example to run your tests via 3 containers you would set the value to the following: '["1", "2", "3"]'. -| `e2e_pass_on_error` | Boolean | False | False | Pass the workflow even if the E2E test fail -| `e2e_artemis_config_path` | String | cypress/artemis-config.yaml | False | Used to determine the path to the artemis config file -| `spec_to_run` | String | cypress/e2e/**/*.feature | False | Used to determine which test to run -| `magic_url_route` | String | '/' | False | The relative route the magic url should go to -| `auto_cancel_after_failures` | Number | 2 | False | Cancel the tests after this many failures - +| Name | Type | Default | Required | Description | +| ---------------------------- | ------- | --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | +| `use_magic_url` | Boolean | True | False | Deploy to dev via a query param, required for normal SPAs | +| `use_e2e` | Boolean | False | False | Run E2E test, in most case we want this | +| `e2e_filter_tags` | String | | False | Tests will be filtered based on the tags defined here | +| `e2e_containers` | String | '["1"]' | False | The number of tests that you want Cypress to run in parallel. For example to run your tests via 3 containers you would set the value to the following: '["1", "2", "3"]'. | +| `e2e_pass_on_error` | Boolean | False | False | Pass the workflow even if the E2E test fail | +| `e2e_artemis_config_path` | String | cypress/artemis-config.yaml | False | Used to determine the path to the artemis config file | +| `spec_to_run` | String | cypress/e2e/\*_/_.feature | False | Used to determine which test to run | +| `magic_url_route` | String | '/' | False | The relative route the magic url should go to | +| `auto_cancel_after_failures` | Number | 2 | False | Cancel the tests after this many failures | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token -| `CYPRESS_RECORD_KEY` | True | The record key associated with the project in Cypress. -| `CYPRESS_PROJECT_ID` | True | The project ID associated with the project in Cypress -| `CYPRESS_PASSWORD` | False | The password of the E2E username -| `DOCKER_HUB_SRE` | True | The password to login to docker hub sre +| Name | Required | Description | +| -------------------- | -------- | ------------------------------------------------------ | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | +| `CYPRESS_RECORD_KEY` | True | The record key associated with the project in Cypress. | +| `CYPRESS_PROJECT_ID` | True | The project ID associated with the project in Cypress | +| `CYPRESS_PASSWORD` | False | The password of the E2E username | +| `DOCKER_HUB_SRE` | True | The password to login to docker hub sre | ## Example Usage @@ -59,7 +63,9 @@ on: jobs: e2e_run: # Check if the comments come from pull request and contains '/run-e2e-test' - if: github.event.issue.pull_request && contains(github.event.comment.body, '/run-e2e-tests') + if: + github.event.issue.pull_request && contains(github.event.comment.body, + '/run-e2e-tests') uses: jupiterone/.github/.github/workflows/frontend_runtime_application_manual_e2e_run.yml@v# secrets: NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/docs/frontend/frontend_runtime_application_pr.md b/.github/workflows/docs/frontend/frontend_runtime_application_pr.md index 8d4e965e..22047899 100644 --- a/.github/workflows/docs/frontend/frontend_runtime_application_pr.md +++ b/.github/workflows/docs/frontend/frontend_runtime_application_pr.md @@ -1,28 +1,29 @@ # Default workflow for a runtime application when a PR is opened - -This is the [default workflow](../../frontend_runtime_application_pr.yml) that is run when a `PR is opened` for an `application runtime`. It is meant to test the quality and safety of the code being committed. +This is the [default workflow](../../frontend_runtime_application_pr.yml) that +is run when a `PR is opened` for an `application runtime`. It is meant to test +the quality and safety of the code being committed. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner -| `use_validate` | Boolean | True | False | Run validation, in most case we want this -| `use_chromatic` | Boolean | False | False | Run VRT Storybook tests with chromatic -| `use_magic_url` | Boolean | True | False | Deploy to dev via a query param, required for normal SPAs -| `magic_url_route` | String | '/' | False | The relative route the magic url should go to - +| Name | Type | Default | Required | Description | +| ----------------- | ------- | ------- | -------- | --------------------------------------------------------------------------------------- | +| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | +| `use_validate` | Boolean | True | False | Run validation, in most case we want this | +| `use_chromatic` | Boolean | False | False | Run VRT Storybook tests with chromatic | +| `use_magic_url` | Boolean | True | False | Deploy to dev via a query param, required for normal SPAs | +| `magic_url_route` | String | '/' | False | The relative route the magic url should go to | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token -| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token +| Name | Required | Description | +| ------------------------- | -------- | -------------------------- | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | +| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token | ## Example Usage diff --git a/.github/workflows/docs/frontend/frontend_runtime_deploy.md b/.github/workflows/docs/frontend/frontend_runtime_deploy.md index 35b74995..746d2e6f 100644 --- a/.github/workflows/docs/frontend/frontend_runtime_deploy.md +++ b/.github/workflows/docs/frontend/frontend_runtime_deploy.md @@ -1,28 +1,30 @@ # Frontend Runtime Deploy +This is the [default workflow](../../frontend_runtime_application_pr.yml) that +is run when a `PR is merged to main` for a `runtime`. -This is the [default workflow](../../frontend_runtime_application_pr.yml) that is run when a `PR is merged to main` for a `runtime`. - -**NOTE:** Our current workflow mostly goes through Jenkins at the moment. However the long term goal is to transition our entire deploy flow to Github actions, where the following flow becomes single source of truth. +**NOTE:** Our current workflow mostly goes through Jenkins at the moment. +However the long term goal is to transition our entire deploy flow to Github +actions, where the following flow becomes single source of truth. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner -| `publish_chromatic` | Boolean | True | False | If true, will publish to Chromatic - +| Name | Type | Default | Required | Description | +| ------------------- | ------- | ------- | -------- | --------------------------------------------------------------------------------------- | +| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | +| `publish_chromatic` | Boolean | True | False | If true, will publish to Chromatic | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token -| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token -| `CORTEX_API_KEY` | True | A key that allows us to push data to Cortex +| Name | Required | Description | +| ------------------------- | -------- | ------------------------------------------- | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | +| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token | +| `CORTEX_API_KEY` | True | A key that allows us to push data to Cortex | ## Example Usage @@ -60,7 +62,7 @@ jobs: deploy: uses: jupiterone/.github/.github/workflows/frontend_runtime_deploy.yml@v# with: - publish_chromatic: true + publish_chromatic: true secrets: NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} CORTEX_API_KEY: ${{ secrets.CORTEX_API_KEY }} diff --git a/.github/workflows/docs/frontend/frontend_runtime_e2e_trigger_response.md b/.github/workflows/docs/frontend/frontend_runtime_e2e_trigger_response.md index 3f536034..e71d7a4f 100644 --- a/.github/workflows/docs/frontend/frontend_runtime_e2e_trigger_response.md +++ b/.github/workflows/docs/frontend/frontend_runtime_e2e_trigger_response.md @@ -1,33 +1,34 @@ # PR flow running E2E tests when triggered by an external repo -This is the [default workflow](../../frontend_runtime_application_pr.yml) that is run when E2E tests are triggered by an external repo. +This is the [default workflow](../../frontend_runtime_application_pr.yml) that +is run when E2E tests are triggered by an external repo. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | false | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner -| `spec_to_run` | String | cypress/e2e/**/*.feature | False | Used to determine which test to run -| `external_pr_number` | String | | True | Used by the e2e_trigger to pass in the PR number associated with the PR that triggered the flow -| `external_pr_title` | String | | True | Used by the e2e_trigger to give builds in Cypress the correct title associated with the PR that triggered the flow -| `external_pr_branch` | String | | True | Used by the e2e_trigger to give builds in Cypress the correct branch name -| `external_pr_author` | String | | True | Used by the e2e_trigger to give builds in Cypress the correct author name associated with the owner of the PR -| `external_pr_sha` | String | | True | Used by the e2e_trigger to pass in the PR number associated with the PR that triggered the flow -| `external_pr_repo_name` | String | | True | Used by the e2e_trigger to tag builds in Cypress with the appropriate repo name associated with the repo that triggered the flow - +| Name | Type | Default | Required | Description | +| ----------------------- | ------ | ------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- | +| `fallback_runner` | String | false | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | +| `spec_to_run` | String | cypress/e2e/\*_/_.feature | False | Used to determine which test to run | +| `external_pr_number` | String | | True | Used by the e2e_trigger to pass in the PR number associated with the PR that triggered the flow | +| `external_pr_title` | String | | True | Used by the e2e_trigger to give builds in Cypress the correct title associated with the PR that triggered the flow | +| `external_pr_branch` | String | | True | Used by the e2e_trigger to give builds in Cypress the correct branch name | +| `external_pr_author` | String | | True | Used by the e2e_trigger to give builds in Cypress the correct author name associated with the owner of the PR | +| `external_pr_sha` | String | | True | Used by the e2e_trigger to pass in the PR number associated with the PR that triggered the flow | +| `external_pr_repo_name` | String | | True | Used by the e2e_trigger to tag builds in Cypress with the appropriate repo name associated with the repo that triggered the flow | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token -| `CYPRESS_RECORD_KEY` | False | The record key associated with the project in Cypress. -| `CYPRESS_PROJECT_ID` | False | The project ID associated with the project in Cypress -| `CYPRESS_PASSWORD` | False | The password of the E2E username -| `DOCKER_HUB_SRE` | True | The password to login to docker hub sre +| Name | Required | Description | +| -------------------- | -------- | ------------------------------------------------------ | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | +| `CYPRESS_RECORD_KEY` | False | The record key associated with the project in Cypress. | +| `CYPRESS_PROJECT_ID` | False | The project ID associated with the project in Cypress | +| `CYPRESS_PASSWORD` | False | The password of the E2E username | +| `DOCKER_HUB_SRE` | True | The password to login to docker hub sre | ## Example Usage @@ -40,32 +41,45 @@ on: workflow_dispatch: inputs: external_pr_number: - description: 'Used by the e2e_trigger to pass in the associated PR number (used to run test against the correct magic url)' + description: + 'Used by the e2e_trigger to pass in the associated PR number (used to + run test against the correct magic url)' type: string external_pr_title: - description: 'Used by the e2e_trigger to tag builds in Cypress with the appropriate tag name (used to associate a PR with a test run)' + description: + 'Used by the e2e_trigger to tag builds in Cypress with the appropriate + tag name (used to associate a PR with a test run)' type: string external_pr_branch: - description: 'Used by the e2e_trigger to give builds in Cypress the correct branch name' + description: + 'Used by the e2e_trigger to give builds in Cypress the correct branch + name' type: string external_pr_author: - description: 'Used by the e2e_trigger to give builds in Cypress the correct author name associated with the owner of the PR' + description: + 'Used by the e2e_trigger to give builds in Cypress the correct author + name associated with the owner of the PR' type: string external_pr_sha: - description: 'Used by the e2e_trigger to give builds in Cypress the correct SHA associated with the PR that triggered the flow' + description: + 'Used by the e2e_trigger to give builds in Cypress the correct SHA + associated with the PR that triggered the flow' type: string external_pr_repo_name: - description: 'Used by the e2e_trigger to tag builds in Cypress with the appropriate repo name (used to associate a repo with a test run)' + description: + 'Used by the e2e_trigger to tag builds in Cypress with the appropriate + repo name (used to associate a repo with a test run)' type: string externally_triggered: description: 'True if E2E tests are triggered from another repo' default: true type: boolean spec_to_run: - description: 'Used by the e2e_trigger to inform another repo which test to run' + description: + 'Used by the e2e_trigger to inform another repo which test to run' type: string default: 'cypress/e2e/**/*.feature' - + jobs: trigger_response: uses: jupiterone/.github/.github/workflows/frontend_runtime_e2e_trigger_response.yml@v# diff --git a/.github/workflows/docs/frontend/frontend_runtime_utility_manual_e2e_trigger.md b/.github/workflows/docs/frontend/frontend_runtime_utility_manual_e2e_trigger.md index 1e253751..8eb85e9e 100644 --- a/.github/workflows/docs/frontend/frontend_runtime_utility_manual_e2e_trigger.md +++ b/.github/workflows/docs/frontend/frontend_runtime_utility_manual_e2e_trigger.md @@ -1,10 +1,14 @@ # Default workflow for triggering E2E tests when a PR comment is left -This is the [default workflow](../../frontend_runtime_utility_manual_e2e_trigger.yml) that is leveraged to trigger E2E tests for for a `utility runtime`. Specifically, when a PR is opened and a comment of `/run-e2e-tests` is left, it will trigger E2E tests in other repos. +This is the +[default workflow](../../frontend_runtime_utility_manual_e2e_trigger.yml) that +is leveraged to trigger E2E tests for for a `utility runtime`. Specifically, +when a PR is opened and a comment of `/run-e2e-tests` is left, it will trigger +E2E tests in other repos. **Note:** -You will notice that each job checks out the branch repo as shown here. +You will notice that each job checks out the branch repo as shown here. ```yaml - uses: actions/checkout@v3 @@ -12,39 +16,41 @@ You will notice that each job checks out the branch repo as shown here. ref: ${{ needs.get_branch.outputs.ref }} ``` -Please read about why this is necessary in the [get_branch README](../../../actions/get_branch/README.md). +Please read about why this is necessary in the +[get_branch README](../../../actions/get_branch/README.md). ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner -| `e2e_pass_on_error` | Boolean | false | False | Pass the workflow even if the E2E test fail -| `repos_to_test` | String | | False | The relative route the magic url should go to - +| Name | Type | Default | Required | Description | +| ------------------- | ------- | ------- | -------- | --------------------------------------------------------------------------------------- | +| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | +| `e2e_pass_on_error` | Boolean | false | False | Pass the workflow even if the E2E test fail | +| `repos_to_test` | String | | False | The relative route the magic url should go to | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token -| `E2E_AUTO` | False | A J1 token for kicking off cypress tests in other repos +| Name | Required | Description | +| ----------- | -------- | ------------------------------------------------------- | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | +| `E2E_AUTO` | False | A J1 token for kicking off cypress tests in other repos | ## Example Usage ### Default Flow In the flow below, we use the `repos_to_test` to kick off tests in: -- `web-navbar` repo - Targets two tests in the `integrations` directory, -those containing the text `query-engine` and `searchbar`. + +- `web-navbar` repo - Targets two tests in the `integrations` directory, those + containing the text `query-engine` and `searchbar`. - `web-settings` repo - Targets one test in the `integrations directory.` -Using this approach you can see how one repo that shares code with other -repos is able to target tests in those repos to ensure when it updates -the shared code, it's not breaking the implementation of that shared code. +Using this approach you can see how one repo that shares code with other repos +is able to target tests in those repos to ensure when it updates the shared +code, it's not breaking the implementation of that shared code. #### Usage @@ -57,13 +63,18 @@ on: jobs: trigger_e2e_tests: # Check if the comments come from pull request and contains '/run-e2e-test' - if: github.event.issue.pull_request && contains(github.event.comment.body, '/run-e2e-tests') + if: + github.event.issue.pull_request && contains(github.event.comment.body, + '/run-e2e-tests') uses: jupiterone/.github/.github/workflows/frontend_runtime_utility_manual_e2e_trigger.yml@v# with: repos_to_test: >- [ - {"repo":{"name":"web-navbar", "spec":"cypress/e2e/integrations/*(?:query-engine|searchbar)*.feature" }}, - {"repo":{"name":"web-settings", "spec":"cypress/e2e/integrations/web-query-engine.feature" }} + {"repo":{"name":"web-navbar", + "spec":"cypress/e2e/integrations/*(?:query-engine|searchbar)*.feature" + }}, + {"repo":{"name":"web-settings", + "spec":"cypress/e2e/integrations/web-query-engine.feature" }} ] secrets: NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/docs/frontend/frontend_runtime_utility_pr.md b/.github/workflows/docs/frontend/frontend_runtime_utility_pr.md index d19a2dd9..01ae9483 100644 --- a/.github/workflows/docs/frontend/frontend_runtime_utility_pr.md +++ b/.github/workflows/docs/frontend/frontend_runtime_utility_pr.md @@ -1,26 +1,27 @@ # Default workflow for a utility runtime when a PR is opened - -This is the [default workflow](../../frontend_runtime_utility_pr.yml) that is run when a `PR is opened` for a `utility runtime`. It is meant to test the quality and safety of the code being committed. +This is the [default workflow](../../frontend_runtime_utility_pr.yml) that is +run when a `PR is opened` for a `utility runtime`. It is meant to test the +quality and safety of the code being committed. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner -| `use_validate` | Boolean | True | False | Run validation, in most case we want this -| `use_chromatic` | Boolean | false | False | Run VRT Storybook tests with chromatic - +| Name | Type | Default | Required | Description | +| ----------------- | ------- | ------- | -------- | --------------------------------------------------------------------------------------- | +| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | +| `use_validate` | Boolean | True | False | Run validation, in most case we want this | +| `use_chromatic` | Boolean | false | False | Run VRT Storybook tests with chromatic | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token -| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token +| Name | Required | Description | +| ------------------------- | -------- | -------------------------- | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | +| `CHROMATIC_PROJECT_TOKEN` | False | The Chromatic API token | ## Example Usage @@ -82,4 +83,3 @@ graph LR; A --> E; B --> C; ``` - diff --git a/.github/workflows/docs/provision_only_pr.md b/.github/workflows/docs/provision_only_pr.md index 93238520..866240a9 100644 --- a/.github/workflows/docs/provision_only_pr.md +++ b/.github/workflows/docs/provision_only_pr.md @@ -1,23 +1,24 @@ # Default workflow for a provision only repo when a PR is opened - -This is the [default workflow](../../provision_only_pr.yml) that is run when a `PR is opened` for an `provision only` repo. It is meant to test the quality and safety of the code being committed. +This is the [default workflow](../../provision_only_pr.yml) that is run when a +`PR is opened` for an `provision only` repo. It is meant to test the quality and +safety of the code being committed. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner - +| Name | Type | Default | Required | Description | +| ----------------- | ------ | ------- | -------- | --------------------------------------------------------------------------------------- | +| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token +| Name | Required | Description | +| ----------- | -------- | -------------------------- | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | ## Example Usage @@ -42,4 +43,3 @@ graph LR; A --> B; ``` - diff --git a/.github/workflows/docs/provision_only_release.md b/.github/workflows/docs/provision_only_release.md index e02ab1ed..51243595 100644 --- a/.github/workflows/docs/provision_only_release.md +++ b/.github/workflows/docs/provision_only_release.md @@ -1,23 +1,26 @@ # Default workflow for a provision only repo when a PR is merged to main triggering the release flow -This is the [default workflow](../../provision_only_release.yml) that is run when a `PR is merge` for an `provision only` repo. This workflow will create a new commit with the updated version and push it back to the main branch. It will also create a new tag, release, and update the changelog. +This is the [default workflow](../../provision_only_release.yml) that is run +when a `PR is merge` for an `provision only` repo. This workflow will create a +new commit with the updated version and push it back to the main branch. It will +also create a new tag, release, and update the changelog. ## Inputs This action takes the following inputs: -| Name | Type | Default | Required | Description | -| --------------------------- | ------- | ---------------------------- | --------- | -------------------------------------------------------------------------------------- | -| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner - +| Name | Type | Default | Required | Description | +| ----------------- | ------ | ------- | -------- | --------------------------------------------------------------------------------------- | +| `fallback_runner` | String | False | False | If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner | + ## Secrets This action takes the following secrets: -| Name | Required | Description | -| --------------------------- | --------- | ----------------------------------------- | -| `NPM_TOKEN` | True | A J1 npm.com Publish token -| `AUTO_GITHUB_PAT_TOKEN` | True | This is a GitHuh PAT that let's auto write back to main after npm versioning +| Name | Required | Description | +| ----------------------- | -------- | ---------------------------------------------------------------------------- | +| `NPM_TOKEN` | True | A J1 npm.com Publish token | +| `AUTO_GITHUB_PAT_TOKEN` | True | This is a GitHuh PAT that let's auto write back to main after npm versioning | ## Example Usage @@ -45,4 +48,3 @@ graph LR; A --> B; B --> D; ``` - diff --git a/.github/workflows/frontend_npm_pr.yml b/.github/workflows/frontend_npm_pr.yml index d1517161..2f0aef1c 100644 --- a/.github/workflows/frontend_npm_pr.yml +++ b/.github/workflows/frontend_npm_pr.yml @@ -4,15 +4,17 @@ on: workflow_call: inputs: fallback_runner: - description: "If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will leverage ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean use_validate: - description: "Run validation, in most case we want this" + description: 'Run validation, in most case we want this' default: true type: boolean use_chromatic: - description: "Run VRT Storybook tests with chromatic" + description: 'Run VRT Storybook tests with chromatic' default: false type: boolean secrets: @@ -34,7 +36,9 @@ jobs: validate: # Name targeted by branch protections, do not change name: Validate - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} if: ${{ inputs.use_validate }} steps: - uses: actions/checkout@v3 @@ -50,7 +54,9 @@ jobs: chromatic_upload: # Name targeted by branch protections, do not change name: Visual Regression - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} if: ${{ inputs.use_chromatic }} steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/frontend_npm_release.yml b/.github/workflows/frontend_npm_release.yml index 72836636..44e95bde 100644 --- a/.github/workflows/frontend_npm_release.yml +++ b/.github/workflows/frontend_npm_release.yml @@ -4,15 +4,19 @@ on: workflow_call: inputs: fallback_runner: - description: "If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will leverage ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean use_chromatic: - description: "Run VRT Storybook tests with chromatic" + description: 'Run VRT Storybook tests with chromatic' default: false type: boolean use_cortex: - description: "Runs the Cortex job. We eventually want to make this required but we need to make sure we don't break the pipeline." + description: + "Runs the Cortex job. We eventually want to make this required but we + need to make sure we don't break the pipeline." default: true type: boolean secrets: @@ -23,7 +27,9 @@ on: description: 'The Chromatic API token' required: false AUTO_GITHUB_PAT_TOKEN: - description: "This is a GitHuh PAT that let's auto write back to main after npm versioning" + description: + "This is a GitHuh PAT that let's auto write back to main after npm + versioning" required: true CORTEX_API_KEY: description: 'A key that allows us to push data to Cortex' @@ -41,7 +47,9 @@ jobs: validate: # Name targeted by branch protections, do not change name: Validate - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} steps: - uses: actions/checkout@v3 - name: setup_env @@ -54,7 +62,9 @@ jobs: uses: jupiterone/.github/.github/actions/build@v3.0.42 chromatic_publish: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: validate if: ${{ inputs.use_chromatic }} steps: @@ -73,7 +83,9 @@ jobs: chromatic_project_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} publish: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: validate steps: - uses: actions/checkout@v3 @@ -90,7 +102,9 @@ jobs: auto_token: ${{ secrets.AUTO_GITHUB_PAT_TOKEN }} cortex: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: validate if: ${{ inputs.use_cortex }} steps: diff --git a/.github/workflows/frontend_runtime_application_manual_e2e_run.yml b/.github/workflows/frontend_runtime_application_manual_e2e_run.yml index b0820d35..0f537b01 100644 --- a/.github/workflows/frontend_runtime_application_manual_e2e_run.yml +++ b/.github/workflows/frontend_runtime_application_manual_e2e_run.yml @@ -1,21 +1,28 @@ -name: Default workflow for a runtime application when E2E tests get triggred by a comment on the PR +name: + Default workflow for a runtime application when E2E tests get triggred by a + comment on the PR on: workflow_call: inputs: fallback_runner: - description: "If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will leverage ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean e2e_filter_tags: - description: "Tests will be filtered based on the tags defined here" - type: string + description: 'Tests will be filtered based on the tags defined here' + type: string e2e_containers: - description: "The number of tests that you want Cypress to run in parallel. For example to run your tests via 3 containers you would set the value to the following: '[`1`, `2`, `3`]'." + description: + "The number of tests that you want Cypress to run in parallel. For + example to run your tests via 3 containers you would set the value to + the following: '[`1`, `2`, `3`]'." type: string default: '["1"]' e2e_pass_on_error: - description: "Pass the workflow even if the E2E test fail" + description: 'Pass the workflow even if the E2E test fail' type: boolean default: false e2e_artemis_config_path: @@ -26,7 +33,7 @@ on: description: 'Used to determine which test to run' type: string default: 'cypress/e2e/**/*.feature' - magic_url_route: + magic_url_route: description: 'The relative route the magic url should go to' type: string default: '/' @@ -36,19 +43,19 @@ on: type: number secrets: NPM_TOKEN: - description: "A J1 npm.com Publish token" + description: 'A J1 npm.com Publish token' required: true CYPRESS_RECORD_KEY: - description: "The record key associated with the project in Cypress" + description: 'The record key associated with the project in Cypress' required: true CYPRESS_PROJECT_ID: - description: "The project ID associated with the project in Cypress" + description: 'The project ID associated with the project in Cypress' required: true CYPRESS_PASSWORD: - description: "The password of the E2E username" + description: 'The password of the E2E username' required: false DOCKER_HUB_SRE: - description: "The password to login to docker hub sre" + description: 'The password to login to docker hub sre' required: true env: @@ -60,7 +67,9 @@ concurrency: jobs: get_branch: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} outputs: name: ${{ steps.get_branch.outputs.name }} steps: @@ -70,7 +79,9 @@ jobs: uses: jupiterone/.github/.github/actions/get_branch@v3.0.42 e2e_pending_status: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch] steps: - uses: actions/checkout@v3 @@ -82,7 +93,9 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} migration_number: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch] outputs: migration: ${{ steps.migration_number.outputs.migration }} @@ -95,7 +108,9 @@ jobs: uses: jupiterone/.github/.github/actions/frontend/runtime/migration_number@v3.0.42 magic_url: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch, migration_number] permissions: id-token: write @@ -122,7 +137,9 @@ jobs: pr_number: ${{ github.event.issue.number }} e2e_prepare: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch] permissions: id-token: write @@ -130,9 +147,11 @@ jobs: issues: read pull-requests: read outputs: - artemis_account_name: ${{ steps.e2e_prepare.outputs.artemis_account_name }} + artemis_account_name: + ${{ steps.e2e_prepare.outputs.artemis_account_name }} artemis_account_id: ${{ steps.e2e_prepare.outputs.artemis_account_id }} - artemis_account_subdomain: ${{ steps.e2e_prepare.outputs.artemis_account_subdomain }} + artemis_account_subdomain: + ${{ steps.e2e_prepare.outputs.artemis_account_subdomain }} artemis_users: ${{ steps.e2e_prepare.outputs.artemis_users }} steps: - uses: actions/checkout@v3 @@ -150,7 +169,9 @@ jobs: user_count: $(echo '${{ inputs.e2e_containers }}' | jq '. | length') unique_id: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch] outputs: unique_id: ${{ steps.unique_id.outputs.unique_id }} @@ -166,7 +187,9 @@ jobs: e2e_run: # Note this is the only job that leverages amd64 - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-amd64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-amd64' }} container: # Available containers here: https://hub.docker.com/r/cypress/browsers/tags image: cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1 @@ -179,7 +202,7 @@ jobs: needs: [get_branch, e2e_prepare, migration_number, magic_url, unique_id] strategy: # when one test fails, DO NOT cancel the other containers, because this will kill Cypress processes - # leaving Cypress Cloud hanging: https://github.com/cypress-io/github-action/issues/48 + # leaving Cypress Cloud hanging: https://github.com/cypress-io/github-action/issues/48 fail-fast: false matrix: # run copies of the current job in parallel @@ -198,9 +221,12 @@ jobs: timeout-minutes: 120 with: ci_build_id: ${{ needs.unique_id.outputs.unique_id }} - artemis_account_name: ${{ needs.e2e_prepare.outputs.artemis_account_name }} - artemis_account_id: ${{ needs.e2e_prepare.outputs.artemis_account_id }} - artemis_account_subdomain: ${{ needs.e2e_prepare.outputs.artemis_account_subdomain }} + artemis_account_name: + ${{ needs.e2e_prepare.outputs.artemis_account_name }} + artemis_account_id: + ${{ needs.e2e_prepare.outputs.artemis_account_id }} + artemis_account_subdomain: + ${{ needs.e2e_prepare.outputs.artemis_account_subdomain }} artemis_users: ${{ needs.e2e_prepare.outputs.artemis_users }} cypress_container: ${{ matrix.containers }} cypress_mailinator_api_key: ${{ secrets.CYPRESS_MAILINATOR_API_KEY }} @@ -221,7 +247,9 @@ jobs: e2e_status: name: E2E Status - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch, e2e_pending_status, e2e_run] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/frontend_runtime_application_pr.yml b/.github/workflows/frontend_runtime_application_pr.yml index 813cc09c..f70e3eb1 100644 --- a/.github/workflows/frontend_runtime_application_pr.yml +++ b/.github/workflows/frontend_runtime_application_pr.yml @@ -4,27 +4,29 @@ on: workflow_call: inputs: fallback_runner: - description: "If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will leverage ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean use_validate: - description: "Run validation, in most case we want this" + description: 'Run validation, in most case we want this' default: true type: boolean use_chromatic: - description: "Run VRT Storybook tests with chromatic" + description: 'Run VRT Storybook tests with chromatic' default: false type: boolean - magic_url_route: + magic_url_route: description: 'The relative route the magic url should go to' type: string default: '/' secrets: NPM_TOKEN: - description: "A J1 npm.com Publish token" + description: 'A J1 npm.com Publish token' required: true CHROMATIC_PROJECT_TOKEN: - description: "The Chromatic API token" + description: 'The Chromatic API token' required: false env: @@ -36,16 +38,22 @@ concurrency: jobs: pr_comment: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} steps: - uses: actions/checkout@v3 - name: pr_comment uses: jupiterone/.github/.github/actions/pr_comment@v3.0.42 with: - message: To run E2E tests leave a comment on the PR in the form of '/run-e2e-tests' + message: + To run E2E tests leave a comment on the PR in the form of + '/run-e2e-tests' migration_number: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} outputs: migration: ${{ steps.migration_number.outputs.migration }} steps: @@ -57,7 +65,9 @@ jobs: validate: # Name targeted by branch protections, do not change name: Validate - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} if: ${{ inputs.use_validate }} steps: - uses: actions/checkout@v3 @@ -71,11 +81,13 @@ jobs: uses: jupiterone/.github/.github/actions/frontend/runtime/remote_types_install@v3.0.42 - name: validate uses: jupiterone/.github/.github/actions/validate@v3.0.42 - + chromatic_upload: # Name targeted by branch protections, do not change name: Visual Regression - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} if: ${{ inputs.use_chromatic }} steps: - uses: actions/checkout@v3 @@ -92,7 +104,9 @@ jobs: chromatic_project_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} magic_url: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [migration_number] permissions: id-token: write diff --git a/.github/workflows/frontend_runtime_deploy.yml b/.github/workflows/frontend_runtime_deploy.yml index 12c36946..05dc9587 100644 --- a/.github/workflows/frontend_runtime_deploy.yml +++ b/.github/workflows/frontend_runtime_deploy.yml @@ -1,34 +1,40 @@ -name: Default workflow for a runtime when a PR is merged to main triggering the deploy flow +name: + Default workflow for a runtime when a PR is merged to main triggering the + deploy flow on: workflow_call: inputs: fallback_runner: - description: "If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will leverage ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean publish_chromatic: - description: "If true, will publish to Chromatic" + description: 'If true, will publish to Chromatic' type: boolean secrets: NPM_TOKEN: - description: "A J1 npm.com Publish token" + description: 'A J1 npm.com Publish token' required: true CORTEX_API_KEY: - description: "A key that allows us to push data to Cortex" + description: 'A key that allows us to push data to Cortex' required: true CHROMATIC_PROJECT_TOKEN: - description: "A token that allows us to publish to Chromatic" + description: 'A token that allows us to publish to Chromatic' required: false env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - + jobs: validate: # Name targeted by branch protections, do not change name: Validate - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} steps: - uses: actions/checkout@v3 with: @@ -43,9 +49,11 @@ jobs: uses: jupiterone/.github/.github/actions/validate@v3.0.42 - name: build uses: jupiterone/.github/.github/actions/build@v3.0.42 - + chromatic_publish: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: validate if: ${{ inputs.publish_chromatic }} steps: @@ -64,7 +72,9 @@ jobs: publish_chromatic: true cortex: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: validate steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/frontend_runtime_e2e_trigger_response.yml b/.github/workflows/frontend_runtime_e2e_trigger_response.yml index c821cab7..96cf4cbf 100644 --- a/.github/workflows/frontend_runtime_e2e_trigger_response.yml +++ b/.github/workflows/frontend_runtime_e2e_trigger_response.yml @@ -1,11 +1,15 @@ # This file is extended by the e2e_trigger.yml in each application repo -name: Default workflow for running tests in an application repo when triggered by an external repo +name: + Default workflow for running tests in an application repo when triggered by an + external repo on: workflow_call: inputs: fallback_runner: - description: "If true will levarege ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will levarege ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean spec_to_run: @@ -13,44 +17,56 @@ on: type: string default: 'cypress/e2e/**/*.feature' external_pr_number: - description: 'Used by the e2e_trigger to pass in the PR number associated with the PR that triggered the flow' + description: + 'Used by the e2e_trigger to pass in the PR number associated with the + PR that triggered the flow' type: string required: true external_pr_title: - description: 'Used by the e2e_trigger to give builds in Cypress the correct title associated with the PR that triggered the flow' + description: + 'Used by the e2e_trigger to give builds in Cypress the correct title + associated with the PR that triggered the flow' type: string required: true external_pr_branch: - description: 'Used by the e2e_trigger to give builds in Cypress the correct branch name' + description: + 'Used by the e2e_trigger to give builds in Cypress the correct branch + name' type: string required: true external_pr_author: - description: 'Used by the e2e_trigger to give builds in Cypress the correct author name associated with the owner of the PR' + description: + 'Used by the e2e_trigger to give builds in Cypress the correct author + name associated with the owner of the PR' type: string required: true external_pr_sha: - description: 'Used by the e2e_trigger to give builds in Cypress the correct SHA associated with the PR that triggered the flow' + description: + 'Used by the e2e_trigger to give builds in Cypress the correct SHA + associated with the PR that triggered the flow' type: string required: true external_pr_repo_name: - description: 'Used by the e2e_trigger to tag builds in Cypress with the appropriate repo name associated with the repo that triggered the flow' + description: + 'Used by the e2e_trigger to tag builds in Cypress with the appropriate + repo name associated with the repo that triggered the flow' type: string required: true secrets: NPM_TOKEN: - description: "A J1 npm.com Publish token" + description: 'A J1 npm.com Publish token' required: true CYPRESS_RECORD_KEY: - description: "The record key associated with the project in Cypress" + description: 'The record key associated with the project in Cypress' required: false CYPRESS_PROJECT_ID: - description: "The project ID associated with the project in Cypress" + description: 'The project ID associated with the project in Cypress' required: false CYPRESS_PASSWORD: - description: "The password of the E2E username" + description: 'The password of the E2E username' required: false DOCKER_HUB_SRE: - description: "The password to login to docker hub sre" + description: 'The password to login to docker hub sre' required: true env: @@ -62,7 +78,9 @@ concurrency: jobs: migration_number: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} outputs: migration: ${{ steps.migration_number.outputs.migration }} steps: @@ -76,15 +94,19 @@ jobs: uses: jupiterone/.github/.github/actions/frontend/runtime/migration_number@v3.0.42 e2e_prepare: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [migration_number] permissions: id-token: write contents: read outputs: - artemis_account_name: ${{ steps.e2e_prepare.outputs.artemis_account_name }} + artemis_account_name: + ${{ steps.e2e_prepare.outputs.artemis_account_name }} artemis_account_id: ${{ steps.e2e_prepare.outputs.artemis_account_id }} - artemis_account_subdomain: ${{ steps.e2e_prepare.outputs.artemis_account_subdomain }} + artemis_account_subdomain: + ${{ steps.e2e_prepare.outputs.artemis_account_subdomain }} artemis_users: ${{ steps.e2e_prepare.outputs.artemis_users }} steps: - uses: actions/checkout@v3 @@ -97,7 +119,9 @@ jobs: uses: jupiterone/.github/.github/actions/frontend/runtime/e2e_prepare@v3.0.42 unique_id: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} outputs: unique_id: ${{ steps.unique_id.outputs.unique_id }} steps: @@ -110,7 +134,9 @@ jobs: e2e_run: # Note this is the only job that leverages amd64 - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-amd64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-amd64' }} container: # Available containers here: https://hub.docker.com/r/cypress/browsers/tags image: cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1 @@ -122,7 +148,7 @@ jobs: needs: [migration_number, e2e_prepare, unique_id] strategy: # when one test fails, DO NOT cancel the other containers, because this will kill Cypress processes - # leaving Cypress Cloud hanging: https://github.com/cypress-io/github-action/issues/48 + # leaving Cypress Cloud hanging: https://github.com/cypress-io/github-action/issues/48 fail-fast: false outputs: test_passed: ${{ steps.e2e_run.outputs.test_passed }} @@ -138,9 +164,12 @@ jobs: timeout-minutes: 120 with: ci_build_id: ${{ needs.unique_id.outputs.unique_id }} - artemis_account_name: ${{ needs.e2e_prepare.outputs.artemis_account_name }} - artemis_account_id: ${{ needs.e2e_prepare.outputs.artemis_account_id }} - artemis_account_subdomain: ${{ needs.e2e_prepare.outputs.artemis_account_subdomain }} + artemis_account_name: + ${{ needs.e2e_prepare.outputs.artemis_account_name }} + artemis_account_id: + ${{ needs.e2e_prepare.outputs.artemis_account_id }} + artemis_account_subdomain: + ${{ needs.e2e_prepare.outputs.artemis_account_subdomain }} artemis_users: ${{ needs.e2e_prepare.outputs.artemis_users }} cypress_record_key: ${{ secrets.CYPRESS_RECORD_KEY }} cypress_project_id: ${{ secrets.CYPRESS_PROJECT_ID }} diff --git a/.github/workflows/frontend_runtime_utility_manual_e2e_trigger.yml b/.github/workflows/frontend_runtime_utility_manual_e2e_trigger.yml index d7d97b77..d80d93f9 100644 --- a/.github/workflows/frontend_runtime_utility_manual_e2e_trigger.yml +++ b/.github/workflows/frontend_runtime_utility_manual_e2e_trigger.yml @@ -4,22 +4,24 @@ on: workflow_call: inputs: fallback_runner: - description: "If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will leverage ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean e2e_pass_on_error: - description: "Pass the workflow even if the E2E test fail" + description: 'Pass the workflow even if the E2E test fail' type: boolean default: false repos_to_test: - description: "Kick off a n+ spec files within n+ repos" + description: 'Kick off a n+ spec files within n+ repos' type: string secrets: NPM_TOKEN: - description: "A J1 npm.com Publish token" + description: 'A J1 npm.com Publish token' required: true E2E_AUTO: - description: "A J1 token for kicking off cypress tests" + description: 'A J1 token for kicking off cypress tests' required: false env: @@ -31,7 +33,9 @@ concurrency: jobs: get_branch: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} outputs: name: ${{ steps.get_branch.outputs.name }} steps: @@ -41,7 +45,9 @@ jobs: uses: jupiterone/.github/.github/actions/get_branch@v3.0.42 e2e_pending_status: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch] steps: - uses: actions/checkout@v3 @@ -53,7 +59,9 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} migration_number: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch] outputs: migration: ${{ steps.migration_number.outputs.migration }} @@ -66,7 +74,9 @@ jobs: uses: jupiterone/.github/.github/actions/frontend/runtime/migration_number@v3.0.42 magic_url: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch, migration_number] permissions: id-token: write @@ -94,7 +104,9 @@ jobs: pr_number: ${{ github.event.issue.number }} e2e_trigger_remote_tests: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch, magic_url] strategy: matrix: @@ -122,7 +134,9 @@ jobs: e2e_status: name: E2E Status - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [get_branch, e2e_pending_status, e2e_trigger_remote_tests] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/frontend_runtime_utility_pr.yml b/.github/workflows/frontend_runtime_utility_pr.yml index 26bdf8bc..21e632d3 100644 --- a/.github/workflows/frontend_runtime_utility_pr.yml +++ b/.github/workflows/frontend_runtime_utility_pr.yml @@ -4,23 +4,25 @@ on: workflow_call: inputs: fallback_runner: - description: "If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will leverage ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean use_validate: - description: "Run validation, in most case we want this" + description: 'Run validation, in most case we want this' default: true type: boolean use_chromatic: - description: "Run VRT Storybook tests with chromatic" + description: 'Run VRT Storybook tests with chromatic' default: false type: boolean secrets: NPM_TOKEN: - description: "A J1 npm.com Publish token" + description: 'A J1 npm.com Publish token' required: true CHROMATIC_PROJECT_TOKEN: - description: "The Chromatic API token" + description: 'The Chromatic API token' required: false env: @@ -32,16 +34,22 @@ concurrency: jobs: pr_comment: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} steps: - uses: actions/checkout@v3 - name: pr_comment uses: jupiterone/.github/.github/actions/pr_comment@v3.0.42 with: - message: To run E2E tests leave a comment on the PR in the form of '/run-e2e-tests' + message: + To run E2E tests leave a comment on the PR in the form of + '/run-e2e-tests' migration_number: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} outputs: migration: ${{ steps.migration_number.outputs.migration }} steps: @@ -53,7 +61,9 @@ jobs: validate: # Name targeted by branch protections, do not change name: Validate - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} if: ${{ inputs.use_validate }} steps: - uses: actions/checkout@v3 @@ -73,7 +83,9 @@ jobs: chromatic_upload: # Name targeted by branch protections, do not change name: Visual Regression - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} if: ${{ inputs.use_chromatic }} steps: - uses: actions/checkout@v3 @@ -90,7 +102,9 @@ jobs: chromatic_project_token: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} magic_url: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} needs: [migration_number] permissions: id-token: write diff --git a/.github/workflows/halo_publish_integration_collector_image.yaml b/.github/workflows/halo_publish_integration_collector_image.yaml index 2bf70233..3473ad92 100644 --- a/.github/workflows/halo_publish_integration_collector_image.yaml +++ b/.github/workflows/halo_publish_integration_collector_image.yaml @@ -16,12 +16,12 @@ on: default: ${{ github.repository }} required: false secrets: - GHCR_USERNAME: - description: 'GHCR Username to authenticate and publish with' - required: true - GHCR_PASSWORD: - description: 'GHCR password to authenticate and publish with' - required: true + GHCR_USERNAME: + description: 'GHCR Username to authenticate and publish with' + required: true + GHCR_PASSWORD: + description: 'GHCR password to authenticate and publish with' + required: true jobs: build: diff --git a/.github/workflows/internal_pull_request.yml b/.github/workflows/internal_pull_request.yml index 2ac94218..592c1f34 100644 --- a/.github/workflows/internal_pull_request.yml +++ b/.github/workflows/internal_pull_request.yml @@ -20,4 +20,4 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - run: npm ci - - run: npm run validate \ No newline at end of file + - run: npm run validate diff --git a/.github/workflows/internal_release.yml b/.github/workflows/internal_release.yml index 4f852d23..a33ebfc9 100644 --- a/.github/workflows/internal_release.yml +++ b/.github/workflows/internal_release.yml @@ -37,7 +37,7 @@ jobs: echo "version=$(jq -r .version < package.json)" >> $GITHUB_OUTPUT - name: semver_versions id: semver_versions - uses: "WyriHaximus/github-action-next-semvers@v1" + uses: 'WyriHaximus/github-action-next-semvers@v1' with: version: ${{ steps.package_json.outputs.version }} - name: patch_version @@ -80,15 +80,14 @@ jobs: git push --follow-tags --set-upstream origin main # Parse the current version so we can extract only the major part of the semver (1 from 1.0.0) - name: current_semver_parser - id: current_semver_parser + id: current_semver_parser uses: booxmedialtd/ws-action-parse-semver@v1 with: input_string: ${{ steps.package_json.outputs.version }} - # We reset the major tag so workflow consumers automatically receive these changes + # We reset the major tag so workflow consumers automatically receive these changes - name: reset_major_tag if: ${{ env.NEW_VERSION != steps.current_semver_parser.outputs.major }} run: | echo "Major tag v${{ steps.current_semver_parser.outputs.major }} is being reset to the latest" git tag -af v${{ steps.current_semver_parser.outputs.major }} -m "Resetting v${{ steps.current_semver_parser.outputs.major }} tag" git push origin v${{ steps.current_semver_parser.outputs.major }} --force - diff --git a/.github/workflows/provision_only_pr.yml b/.github/workflows/provision_only_pr.yml index 1acf4e46..707c0b10 100644 --- a/.github/workflows/provision_only_pr.yml +++ b/.github/workflows/provision_only_pr.yml @@ -4,12 +4,14 @@ on: workflow_call: inputs: fallback_runner: - description: "If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will leverage ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean secrets: NPM_TOKEN: - description: "A J1 npm.com Publish token" + description: 'A J1 npm.com Publish token' required: true env: @@ -23,7 +25,9 @@ jobs: validate: # Name targeted by branch protections, do not change name: Validate - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} steps: - uses: actions/checkout@v3 with: diff --git a/.github/workflows/provision_only_release.yml b/.github/workflows/provision_only_release.yml index 0be4d8bb..b0376c41 100644 --- a/.github/workflows/provision_only_release.yml +++ b/.github/workflows/provision_only_release.yml @@ -1,18 +1,24 @@ -name: Default workflow for a provision only repo when a PR is merged to main triggering the release flow +name: + Default workflow for a provision only repo when a PR is merged to main + triggering the release flow on: workflow_call: inputs: fallback_runner: - description: "If true will leverage ubuntu-latest, otherwise will fall back to the J1 in-house runner" + description: + 'If true will leverage ubuntu-latest, otherwise will fall back to the + J1 in-house runner' default: false type: boolean secrets: NPM_TOKEN: - description: "A J1 npm.com Publish token" + description: 'A J1 npm.com Publish token' required: true AUTO_GITHUB_PAT_TOKEN: - description: "This is a GitHuh PAT that let's auto write back to main after npm versioning" + description: + "This is a GitHuh PAT that let's auto write back to main after npm + versioning" required: true env: @@ -26,7 +32,9 @@ jobs: validate: # Name targeted by branch protections, do not change name: Validate - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-arm64' }} steps: - uses: actions/checkout@v3 with: @@ -40,7 +48,9 @@ jobs: uses: jupiterone/.github/.github/actions/validate@v3.0.42 version_artifact: - runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-amd64' }} + runs-on: + ${{ (inputs.fallback_runner && 'ubuntu-latest') || + 'scaleset-jupiterone-infra-amd64' }} needs: validate steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/test/frontend_npm_pr.test.ts b/.github/workflows/test/frontend_npm_pr.test.ts index 95ffd6c3..a870d476 100644 --- a/.github/workflows/test/frontend_npm_pr.test.ts +++ b/.github/workflows/test/frontend_npm_pr.test.ts @@ -9,7 +9,7 @@ const repoName = 'frontend_npm_pr'; beforeEach(async () => { mockGithub = new MockGithub(getWorkflowConfig({ repoName })); - + await mockGithub.setup(); }); @@ -19,10 +19,7 @@ afterEach(async () => { test('validate inputs and secrets', async () => { const act = new Act(mockGithub.repo.getPath(repoName)); - const mockSecrets = [ - 'NPM_TOKEN', - 'CHROMATIC_PROJECT_TOKEN', - ]; + const mockSecrets = ['NPM_TOKEN', 'CHROMATIC_PROJECT_TOKEN']; setSecrets({ act, mockSecrets }); @@ -32,7 +29,7 @@ test('validate inputs and secrets', async () => { // chromatic_upload const chromatic_inputs = getTestResult({ results, name: 'chromatic_inputs' }); - + expect(chromatic_inputs.output).toContain(`chromatic_project_token=***`); }); @@ -41,10 +38,10 @@ test('default flow', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate', - 'security' - ] }); + const jobs_found = getTestResults({ + results, + names: ['validate', 'security'], + }); expect(jobs_found.length).toEqual(1); }); @@ -56,9 +53,7 @@ test('when use_chromatic is true', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'chromatic_upload' - ] }); + const jobs_found = getTestResults({ results, names: ['chromatic_upload'] }); expect(jobs_found.length).toEqual(1); }); @@ -70,9 +65,7 @@ test('when use_validate is false', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate' - ] }); + const jobs_found = getTestResults({ results, names: ['validate'] }); expect(jobs_found.length).toEqual(0); }); diff --git a/.github/workflows/test/frontend_npm_release.test.ts b/.github/workflows/test/frontend_npm_release.test.ts index cd40a117..34362fe3 100644 --- a/.github/workflows/test/frontend_npm_release.test.ts +++ b/.github/workflows/test/frontend_npm_release.test.ts @@ -9,7 +9,7 @@ const repoName = 'frontend_npm_release'; beforeEach(async () => { mockGithub = new MockGithub(getWorkflowConfig({ repoName })); - + await mockGithub.setup(); }); @@ -22,7 +22,7 @@ test('validate inputs and secrets', async () => { const mockSecrets = [ 'CHROMATIC_PROJECT_TOKEN', 'AUTO_GITHUB_PAT_TOKEN', - 'CORTEX_API_KEY' + 'CORTEX_API_KEY', ]; setSecrets({ act, mockSecrets }); @@ -33,12 +33,15 @@ test('validate inputs and secrets', async () => { // chromatic_upload const chromatic_inputs = getTestResult({ results, name: 'chromatic_inputs' }); - + expect(chromatic_inputs.output).toContain(`chromatic_project_token=***`); // npm_publish - const npm_publish_inputs = getTestResult({ results, name: 'npm_publish_inputs' }); - + const npm_publish_inputs = getTestResult({ + results, + name: 'npm_publish_inputs', + }); + expect(npm_publish_inputs.output).toContain(`auto_token=***`); // cortex @@ -52,11 +55,10 @@ test('default flow', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate', - 'publish', - 'cortex' - ] }); + const jobs_found = getTestResults({ + results, + names: ['validate', 'publish', 'cortex'], + }); expect(jobs_found.length).toEqual(3); }); @@ -68,12 +70,10 @@ test('when use_chromatic is true', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate', - 'chromatic_publish', - 'publish', - 'cortex' - ] }); + const jobs_found = getTestResults({ + results, + names: ['validate', 'chromatic_publish', 'publish', 'cortex'], + }); expect(jobs_found.length).toEqual(4); }); diff --git a/.github/workflows/test/frontend_runtime_application_manual_e2e_run.test.ts b/.github/workflows/test/frontend_runtime_application_manual_e2e_run.test.ts index b6ece9dc..bbf899a7 100644 --- a/.github/workflows/test/frontend_runtime_application_manual_e2e_run.test.ts +++ b/.github/workflows/test/frontend_runtime_application_manual_e2e_run.test.ts @@ -1,7 +1,12 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; import { getWorkflowConfig, runWorkflow } from 'tests/utils/setup'; -import { getTestResult, getTestResults, setInputs, setSecrets } from 'tests/utils/helpers'; +import { + getTestResult, + getTestResults, + setInputs, + setSecrets, +} from 'tests/utils/helpers'; import mockPackageJson from 'tests/package.json'; import mockArtemisRun from '~/actions/frontend/runtime/e2e_prepare/test/artemis-run.json'; import { resolve } from 'node:path'; @@ -18,18 +23,32 @@ const mockArtemisData = { users: { tokenSecret: mockArtemisRun[1].metadata.token.tokenSecret, tokenCsrf: mockArtemisRun[1].metadata.token.tokenCsrf, - groupName: mockArtemisRun[1].metadata.groupName - } + groupName: mockArtemisRun[1].metadata.groupName, + }, }; beforeEach(async () => { - mockGithub = new MockGithub(getWorkflowConfig({ repoName, additionalFiles: [ - { - src: resolve(cwd(), '.github', 'actions', 'frontend', 'runtime', 'e2e_prepare', 'test', 'artemis-run.json'), - dest: 'artemis-run.json', - } - ] })); - + mockGithub = new MockGithub( + getWorkflowConfig({ + repoName, + additionalFiles: [ + { + src: resolve( + cwd(), + '.github', + 'actions', + 'frontend', + 'runtime', + 'e2e_prepare', + 'test', + 'artemis-run.json' + ), + dest: 'artemis-run.json', + }, + ], + }) + ); + await mockGithub.setup(); }); @@ -44,7 +63,7 @@ test('validate inputs and secrets', async () => { 'CYPRESS_RECORD_KEY', 'CYPRESS_PROJECT_ID', 'CYPRESS_PASSWORD', - 'DOCKER_HUB_SRE' + 'DOCKER_HUB_SRE', ]; const mockInputs = { magic_url_route: 'magic_url_route_test', @@ -52,7 +71,7 @@ test('validate inputs and secrets', async () => { e2e_containers: '["1", "2"]', e2e_filter_tags: 'e2e_filter_tags_test', e2e_pass_on_error: true, - spec_to_run: 'spec_to_run_test' + spec_to_run: 'spec_to_run_test', }; setSecrets({ act, mockSecrets }); @@ -63,30 +82,60 @@ test('validate inputs and secrets', async () => { // magic_url const magic_url_inputs = getTestResult({ results, name: 'magic_url_inputs' }); - expect(magic_url_inputs.output).toContain(`migration=${mockPackageJson.config.migration}`); - expect(magic_url_inputs.output).toContain(`magic_url_route=${mockInputs.magic_url_route}`); + expect(magic_url_inputs.output).toContain( + `migration=${mockPackageJson.config.migration}` + ); + expect(magic_url_inputs.output).toContain( + `magic_url_route=${mockInputs.magic_url_route}` + ); // e2e_prepare - const e2e_prepare_inputs = getTestResult({ results, name: 'e2e_prepare_inputs' }); - - expect(e2e_prepare_inputs.output).toContain(`e2e_artemis_config_path=${mockInputs.e2e_artemis_config_path}`); - expect(e2e_prepare_inputs.output).toContain(`user_count=${JSON.parse(mockInputs.e2e_containers).length}`); + const e2e_prepare_inputs = getTestResult({ + results, + name: 'e2e_prepare_inputs', + }); + + expect(e2e_prepare_inputs.output).toContain( + `e2e_artemis_config_path=${mockInputs.e2e_artemis_config_path}` + ); + expect(e2e_prepare_inputs.output).toContain( + `user_count=${JSON.parse(mockInputs.e2e_containers).length}` + ); // e2e_run const e2e_run_inputs = getTestResult({ results, name: 'e2e_run_inputs' }); - expect(e2e_run_inputs.output).toContain(`artemis_account_name=${mockArtemisData.accountName}`); - expect(e2e_run_inputs.output).toContain(`artemis_account_subdomain=${mockArtemisData.accountSubdomain}`); - expect(e2e_run_inputs.output).toContain(`artemis_account_id=${mockArtemisData.id}`); - expect(e2e_run_inputs.output).toContain(`artemis_users=[${JSON.stringify(mockArtemisData.users).replace(/"([^"]+)"/g, '$1')}]`); + expect(e2e_run_inputs.output).toContain( + `artemis_account_name=${mockArtemisData.accountName}` + ); + expect(e2e_run_inputs.output).toContain( + `artemis_account_subdomain=${mockArtemisData.accountSubdomain}` + ); + expect(e2e_run_inputs.output).toContain( + `artemis_account_id=${mockArtemisData.id}` + ); + expect(e2e_run_inputs.output).toContain( + `artemis_users=[${JSON.stringify(mockArtemisData.users).replace( + /"([^"]+)"/g, + '$1' + )}]` + ); expect(e2e_run_inputs.output).toContain(`cypress_mailinator_api_key=***`); expect(e2e_run_inputs.output).toContain(`cypress_record_key=***`); expect(e2e_run_inputs.output).toContain(`cypress_project_id=***`); expect(e2e_run_inputs.output).toContain(`cypress_password=***`); - expect(e2e_run_inputs.output).toContain(`e2e_filter_tags=${mockInputs.e2e_filter_tags}`); - expect(e2e_run_inputs.output).toContain(`e2e_pass_on_error=${mockInputs.e2e_pass_on_error}`); - expect(e2e_run_inputs.output).toContain(`migration_number=${mockPackageJson.config.migration}`); - expect(e2e_run_inputs.output).toContain(`spec_to_run=${mockInputs.spec_to_run}`); + expect(e2e_run_inputs.output).toContain( + `e2e_filter_tags=${mockInputs.e2e_filter_tags}` + ); + expect(e2e_run_inputs.output).toContain( + `e2e_pass_on_error=${mockInputs.e2e_pass_on_error}` + ); + expect(e2e_run_inputs.output).toContain( + `migration_number=${mockPackageJson.config.migration}` + ); + expect(e2e_run_inputs.output).toContain( + `spec_to_run=${mockInputs.spec_to_run}` + ); }); test('flow with e2e_pass_on_error set to true to make tests non blocking', async () => { @@ -95,24 +144,32 @@ test('flow with e2e_pass_on_error set to true to make tests non blocking', async act.setSecret('DOCKER_HUB_SRE', 'DOCKER_HUB_SRE'); act.setInput('e2e_pass_on_error', 'true'); - const results = await runWorkflow({ act, repoName, mockGithub, mockSteps: { - e2e_pending_status: [ { name: 'e2e_pending_status', mockWith: 'echo ""' } ], - migration_number: [ { name: 'migration_number', mockWith: 'echo ""' } ], - magic_url: [ { name: 'magic_url', mockWith: 'echo ""' } ], - e2e_prepare: [ { name: 'e2e_prepare', mockWith: 'echo ""' } ], - // Purposefully fail to test e2e_pass_on_error - e2e_run: [ { name: 'e2e_prepare', mockWith: 'echo "exit 1"' } ], - }}); - - const jobs_found = getTestResults({ results, names: [ - 'e2e_pending_status', - 'migration_number', - 'magic_url', - 'e2e_prepare', - 'unique_id', - 'e2e_run', - 'e2e_status' - ] }); + const results = await runWorkflow({ + act, + repoName, + mockGithub, + mockSteps: { + e2e_pending_status: [{ name: 'e2e_pending_status', mockWith: 'echo ""' }], + migration_number: [{ name: 'migration_number', mockWith: 'echo ""' }], + magic_url: [{ name: 'magic_url', mockWith: 'echo ""' }], + e2e_prepare: [{ name: 'e2e_prepare', mockWith: 'echo ""' }], + // Purposefully fail to test e2e_pass_on_error + e2e_run: [{ name: 'e2e_prepare', mockWith: 'echo "exit 1"' }], + }, + }); + + const jobs_found = getTestResults({ + results, + names: [ + 'e2e_pending_status', + 'migration_number', + 'magic_url', + 'e2e_prepare', + 'unique_id', + 'e2e_run', + 'e2e_status', + ], + }); expect(jobs_found.length).toEqual(7); }); diff --git a/.github/workflows/test/frontend_runtime_application_pr.test.ts b/.github/workflows/test/frontend_runtime_application_pr.test.ts index 69881ae6..d8c3f662 100644 --- a/.github/workflows/test/frontend_runtime_application_pr.test.ts +++ b/.github/workflows/test/frontend_runtime_application_pr.test.ts @@ -1,7 +1,12 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; import { getWorkflowConfig, runWorkflow } from 'tests/utils/setup'; -import { getTestResult, getTestResults, setInputs, setSecrets } from 'tests/utils/helpers'; +import { + getTestResult, + getTestResults, + setInputs, + setSecrets, +} from 'tests/utils/helpers'; import mockPackageJson from 'tests/package.json'; let mockGithub: MockGithub; @@ -10,7 +15,7 @@ const repoName = 'frontend_runtime_application_pr'; beforeEach(async () => { mockGithub = new MockGithub(getWorkflowConfig({ repoName })); - + await mockGithub.setup(); }); @@ -20,11 +25,9 @@ afterEach(async () => { test('validate inputs and secrets', async () => { const act = new Act(mockGithub.repo.getPath(repoName)); - const mockSecrets = [ - 'CHROMATIC_PROJECT_TOKEN' - ]; + const mockSecrets = ['CHROMATIC_PROJECT_TOKEN']; const mockInputs = { - magic_url_route: 'magic_url_route_test' + magic_url_route: 'magic_url_route_test', }; setSecrets({ act, mockSecrets }); @@ -36,19 +39,28 @@ test('validate inputs and secrets', async () => { // chromatic_upload const chromatic_inputs = getTestResult({ results, name: 'chromatic_inputs' }); - + expect(chromatic_inputs.output).toContain(`chromatic_project_token=***`); // magic_url const magic_url_inputs = getTestResult({ results, name: 'magic_url_inputs' }); - expect(magic_url_inputs.output).toContain(`migration=${mockPackageJson.config.migration}`); - expect(magic_url_inputs.output).toContain(`magic_url_route=${mockInputs.magic_url_route}`); + expect(magic_url_inputs.output).toContain( + `migration=${mockPackageJson.config.migration}` + ); + expect(magic_url_inputs.output).toContain( + `magic_url_route=${mockInputs.magic_url_route}` + ); // pr_comment - const pr_comment_inputs = getTestResult({ results, name: 'pr_comment_inputs' }); - - expect(pr_comment_inputs.output).toContain(`message=To run E2E tests leave a comment`); + const pr_comment_inputs = getTestResult({ + results, + name: 'pr_comment_inputs', + }); + + expect(pr_comment_inputs.output).toContain( + `message=To run E2E tests leave a comment` + ); }); test('default flow', async () => { @@ -56,12 +68,10 @@ test('default flow', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'pr_comment', - 'migration_number', - 'validate', - 'magic_url' - ] }); + const jobs_found = getTestResults({ + results, + names: ['pr_comment', 'migration_number', 'validate', 'magic_url'], + }); expect(jobs_found.length).toEqual(4); }); @@ -73,9 +83,7 @@ test('when use_validate is false', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate' - ] }); + const jobs_found = getTestResults({ results, names: ['validate'] }); expect(jobs_found.length).toEqual(0); }); @@ -87,9 +95,7 @@ test('when use_chromatic is true', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'chromatic_upload' - ] }); + const jobs_found = getTestResults({ results, names: ['chromatic_upload'] }); expect(jobs_found.length).toEqual(1); }); diff --git a/.github/workflows/test/frontend_runtime_deploy.test.ts b/.github/workflows/test/frontend_runtime_deploy.test.ts index a7e25d65..7dcc95b8 100644 --- a/.github/workflows/test/frontend_runtime_deploy.test.ts +++ b/.github/workflows/test/frontend_runtime_deploy.test.ts @@ -9,7 +9,7 @@ let mockGithub: MockGithub; beforeEach(async () => { mockGithub = new MockGithub(getWorkflowConfig({ repoName })); - + await mockGithub.setup(); }); @@ -19,23 +19,23 @@ afterEach(async () => { test('validate inputs and secrets', async () => { const act = new Act(mockGithub.repo.getPath(repoName)); - - setSecrets({ act, mockSecrets: [ - 'CORTEX_API_KEY', - 'CHROMATIC_PROJECT_TOKEN' - ] }); + + setSecrets({ + act, + mockSecrets: ['CORTEX_API_KEY', 'CHROMATIC_PROJECT_TOKEN'], + }); act.setInput('publish_chromatic', 'true'); const results = await runWorkflow({ act, repoName, mockGithub }); // cortex const cortex_inputs = getTestResult({ results, name: 'cortex_inputs' }); - + expect(cortex_inputs.output).toContain(`cortex_api_key=***`); // chromatic_upload const chromatic_inputs = getTestResult({ results, name: 'chromatic_inputs' }); - + expect(chromatic_inputs.output).toContain(`chromatic_project_token=***`); }); @@ -44,10 +44,7 @@ test('default flow', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate', - 'cortex' - ] }); + const jobs_found = getTestResults({ results, names: ['validate', 'cortex'] }); expect(jobs_found.length).toEqual(2); }); @@ -59,11 +56,10 @@ test('flow with chromatic turned on', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate', - 'cortex', - 'chromatic_publish' - ] }); + const jobs_found = getTestResults({ + results, + names: ['validate', 'cortex', 'chromatic_publish'], + }); expect(jobs_found.length).toEqual(3); }); diff --git a/.github/workflows/test/frontend_runtime_e2e_trigger_response.test.ts b/.github/workflows/test/frontend_runtime_e2e_trigger_response.test.ts index b480c401..7b949208 100644 --- a/.github/workflows/test/frontend_runtime_e2e_trigger_response.test.ts +++ b/.github/workflows/test/frontend_runtime_e2e_trigger_response.test.ts @@ -1,7 +1,12 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; import { getWorkflowConfig, runWorkflow } from 'tests/utils/setup'; -import { getTestResult, getTestResults, setInputs, setSecrets } from 'tests/utils/helpers'; +import { + getTestResult, + getTestResults, + setInputs, + setSecrets, +} from 'tests/utils/helpers'; import mockPackageJson from 'tests/package.json'; import mockArtemisRun from '~/actions/frontend/runtime/e2e_prepare/test/artemis-run.json'; import { resolve } from 'node:path'; @@ -18,18 +23,32 @@ const mockArtemisData = { users: { tokenSecret: mockArtemisRun[1].metadata.token.tokenSecret, tokenCsrf: mockArtemisRun[1].metadata.token.tokenCsrf, - groupName: mockArtemisRun[1].metadata.groupName - } + groupName: mockArtemisRun[1].metadata.groupName, + }, }; beforeEach(async () => { - mockGithub = new MockGithub(getWorkflowConfig({ repoName, additionalFiles: [ - { - src: resolve(cwd(), '.github', 'actions', 'frontend', 'runtime', 'e2e_prepare', 'test', 'artemis-run.json'), - dest: 'artemis-run.json', - } - ] })); - + mockGithub = new MockGithub( + getWorkflowConfig({ + repoName, + additionalFiles: [ + { + src: resolve( + cwd(), + '.github', + 'actions', + 'frontend', + 'runtime', + 'e2e_prepare', + 'test', + 'artemis-run.json' + ), + dest: 'artemis-run.json', + }, + ], + }) + ); + await mockGithub.setup(); }); @@ -43,7 +62,7 @@ test('validate inputs and secrets', async () => { 'CYPRESS_RECORD_KEY', 'CYPRESS_PROJECT_ID', 'CYPRESS_PASSWORD', - 'DOCKER_HUB_SRE' + 'DOCKER_HUB_SRE', ]; const mockInputs = { spec_to_run: 'spec_to_run_test', @@ -52,7 +71,7 @@ test('validate inputs and secrets', async () => { external_pr_title: 'external_pr_title_test', external_pr_branch: 'external_pr_branch_test', external_pr_author: 'external_pr_author_test', - external_pr_repo_name: 'external_pr_repo_name_test' + external_pr_repo_name: 'external_pr_repo_name_test', }; setSecrets({ act, mockSecrets }); @@ -63,21 +82,48 @@ test('validate inputs and secrets', async () => { // e2e_run const e2e_run_inputs = getTestResult({ results, name: 'e2e_run_inputs' }); - expect(e2e_run_inputs.output).toContain(`artemis_account_name=${mockArtemisData.accountName}`); - expect(e2e_run_inputs.output).toContain(`artemis_account_subdomain=${mockArtemisData.accountSubdomain}`); - expect(e2e_run_inputs.output).toContain(`artemis_account_id=${mockArtemisData.id}`); - expect(e2e_run_inputs.output).toContain(`artemis_users=[${JSON.stringify(mockArtemisData.users).replace(/"([^"]+)"/g, '$1')}]`); + expect(e2e_run_inputs.output).toContain( + `artemis_account_name=${mockArtemisData.accountName}` + ); + expect(e2e_run_inputs.output).toContain( + `artemis_account_subdomain=${mockArtemisData.accountSubdomain}` + ); + expect(e2e_run_inputs.output).toContain( + `artemis_account_id=${mockArtemisData.id}` + ); + expect(e2e_run_inputs.output).toContain( + `artemis_users=[${JSON.stringify(mockArtemisData.users).replace( + /"([^"]+)"/g, + '$1' + )}]` + ); expect(e2e_run_inputs.output).toContain(`cypress_record_key=***`); expect(e2e_run_inputs.output).toContain(`cypress_project_id=***`); expect(e2e_run_inputs.output).toContain(`cypress_password=***`); - expect(e2e_run_inputs.output).toContain(`migration_number=${mockPackageJson.config.migration}`); - expect(e2e_run_inputs.output).toContain(`spec_to_run=${mockInputs.spec_to_run}`); - expect(e2e_run_inputs.output).toContain(`commit_info_sha=${mockInputs.external_pr_sha}`); - expect(e2e_run_inputs.output).toContain(`commit_info_pr_number=${mockInputs.external_pr_number}`); - expect(e2e_run_inputs.output).toContain(`commit_info_pr_title=${mockInputs.external_pr_title}`); - expect(e2e_run_inputs.output).toContain(`commit_info_branch=${mockInputs.external_pr_branch}`); - expect(e2e_run_inputs.output).toContain(`commit_info_author=${mockInputs.external_pr_author}`); - expect(e2e_run_inputs.output).toContain(`commit_info_repo_name=${mockInputs.external_pr_repo_name}`); + expect(e2e_run_inputs.output).toContain( + `migration_number=${mockPackageJson.config.migration}` + ); + expect(e2e_run_inputs.output).toContain( + `spec_to_run=${mockInputs.spec_to_run}` + ); + expect(e2e_run_inputs.output).toContain( + `commit_info_sha=${mockInputs.external_pr_sha}` + ); + expect(e2e_run_inputs.output).toContain( + `commit_info_pr_number=${mockInputs.external_pr_number}` + ); + expect(e2e_run_inputs.output).toContain( + `commit_info_pr_title=${mockInputs.external_pr_title}` + ); + expect(e2e_run_inputs.output).toContain( + `commit_info_branch=${mockInputs.external_pr_branch}` + ); + expect(e2e_run_inputs.output).toContain( + `commit_info_author=${mockInputs.external_pr_author}` + ); + expect(e2e_run_inputs.output).toContain( + `commit_info_repo_name=${mockInputs.external_pr_repo_name}` + ); }); test('default flow', async () => { @@ -87,12 +133,10 @@ test('default flow', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'migration_number', - 'e2e_prepare', - 'unique_id', - 'e2e_run' - ] }); + const jobs_found = getTestResults({ + results, + names: ['migration_number', 'e2e_prepare', 'unique_id', 'e2e_run'], + }); expect(jobs_found.length).toEqual(4); }); diff --git a/.github/workflows/test/frontend_runtime_utility_manual_e2e_trigger.test.ts b/.github/workflows/test/frontend_runtime_utility_manual_e2e_trigger.test.ts index 341b47d4..e766367f 100644 --- a/.github/workflows/test/frontend_runtime_utility_manual_e2e_trigger.test.ts +++ b/.github/workflows/test/frontend_runtime_utility_manual_e2e_trigger.test.ts @@ -1,7 +1,12 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; import { getWorkflowConfig, runWorkflow } from 'tests/utils/setup'; -import { getTestResult, getTestResults, setInputs, setSecrets } from 'tests/utils/helpers'; +import { + getTestResult, + getTestResults, + setInputs, + setSecrets, +} from 'tests/utils/helpers'; import { resolve } from 'node:path'; import { cwd } from 'node:process'; @@ -10,13 +15,27 @@ const repoName = 'frontend_runtime_utility_manual_e2e_trigger'; let mockGithub: MockGithub; beforeEach(async () => { - mockGithub = new MockGithub(getWorkflowConfig({ repoName, additionalFiles: [ - { - src: resolve(cwd(), '.github', 'actions', 'frontend', 'runtime', 'e2e_prepare', 'test', 'artemis-run.json'), - dest: 'artemis-run.json', - } - ] })); - + mockGithub = new MockGithub( + getWorkflowConfig({ + repoName, + additionalFiles: [ + { + src: resolve( + cwd(), + '.github', + 'actions', + 'frontend', + 'runtime', + 'e2e_prepare', + 'test', + 'artemis-run.json' + ), + dest: 'artemis-run.json', + }, + ], + }) + ); + await mockGithub.setup(); }); @@ -29,24 +48,31 @@ test('validate inputs and secrets', async () => { const mockInputs = { e2e_pass_on_error: true, - repos_to_test: '[{"repo":{"name":"web-home", "spec":"test/spec" }}]' + repos_to_test: '[{"repo":{"name":"web-home", "spec":"test/spec" }}]', }; setInputs({ act, mockInputs }); - - setSecrets({ act, mockSecrets: [ - 'E2E_AUTO' - ]}); + + setSecrets({ act, mockSecrets: ['E2E_AUTO'] }); const results = await runWorkflow({ act, repoName, mockGithub }); // e2e_run - const e2e_trigger_remote_tests_inputs = getTestResult({ results, name: 'e2e_trigger_remote_tests_inputs' }); + const e2e_trigger_remote_tests_inputs = getTestResult({ + results, + name: 'e2e_trigger_remote_tests_inputs', + }); - expect(e2e_trigger_remote_tests_inputs.output).toContain(`e2e_pass_on_error=${mockInputs.e2e_pass_on_error}`); + expect(e2e_trigger_remote_tests_inputs.output).toContain( + `e2e_pass_on_error=${mockInputs.e2e_pass_on_error}` + ); expect(e2e_trigger_remote_tests_inputs.output).toContain(`e2e_auto=***`); - expect(e2e_trigger_remote_tests_inputs.output).toContain(JSON.parse(mockInputs.repos_to_test)[0].repo.name); - expect(e2e_trigger_remote_tests_inputs.output).toContain(JSON.parse(mockInputs.repos_to_test)[0].repo.spec); + expect(e2e_trigger_remote_tests_inputs.output).toContain( + JSON.parse(mockInputs.repos_to_test)[0].repo.name + ); + expect(e2e_trigger_remote_tests_inputs.output).toContain( + JSON.parse(mockInputs.repos_to_test)[0].repo.spec + ); }); test.skip('flow with e2e_pass_on_error set to true to make tests non blocking', async () => { @@ -54,22 +80,32 @@ test.skip('flow with e2e_pass_on_error set to true to make tests non blocking', act.setInput('e2e_pass_on_error', 'true'); - const results = await runWorkflow({ act, repoName, mockGithub, mockSteps: { - e2e_pending_status: [ { name: 'e2e_pending_status', mockWith: 'echo ""' } ], - migration_number: [ { name: 'migration_number', mockWith: 'echo ""' } ], - magic_url: [ { name: 'magic_url', mockWith: 'echo ""' } ], - e2e_prepare: [ { name: 'e2e_prepare', mockWith: 'echo ""' } ], - // Purposefully fail to test e2e_pass_on_error - e2e_trigger_remote_tests: [ { name: 'e2e_prepare', mockWith: 'echo "exit 1"' } ], - }}); - - const jobs_found = getTestResults({ results, names: [ - 'e2e_pending_status', - 'migration_number', - 'magic_url', - 'e2e_trigger_remote_tests', - 'e2e_status' - ] }); + const results = await runWorkflow({ + act, + repoName, + mockGithub, + mockSteps: { + e2e_pending_status: [{ name: 'e2e_pending_status', mockWith: 'echo ""' }], + migration_number: [{ name: 'migration_number', mockWith: 'echo ""' }], + magic_url: [{ name: 'magic_url', mockWith: 'echo ""' }], + e2e_prepare: [{ name: 'e2e_prepare', mockWith: 'echo ""' }], + // Purposefully fail to test e2e_pass_on_error + e2e_trigger_remote_tests: [ + { name: 'e2e_prepare', mockWith: 'echo "exit 1"' }, + ], + }, + }); + + const jobs_found = getTestResults({ + results, + names: [ + 'e2e_pending_status', + 'migration_number', + 'magic_url', + 'e2e_trigger_remote_tests', + 'e2e_status', + ], + }); expect(jobs_found.length).toEqual(5); }); diff --git a/.github/workflows/test/frontend_runtime_utility_pr.test.ts b/.github/workflows/test/frontend_runtime_utility_pr.test.ts index 70dd2ef9..bef70062 100644 --- a/.github/workflows/test/frontend_runtime_utility_pr.test.ts +++ b/.github/workflows/test/frontend_runtime_utility_pr.test.ts @@ -1,7 +1,12 @@ import { MockGithub } from '@kie/mock-github'; import { Act } from '@kie/act-js'; import { getWorkflowConfig, runWorkflow } from 'tests/utils/setup'; -import { getTestResult, getTestResults, setInputs, setSecrets } from 'tests/utils/helpers'; +import { + getTestResult, + getTestResults, + setInputs, + setSecrets, +} from 'tests/utils/helpers'; import mockPackageJson from 'tests/package.json'; const repoName = 'frontend_runtime_utility_pr'; @@ -10,7 +15,7 @@ let mockGithub: MockGithub; beforeEach(async () => { mockGithub = new MockGithub(getWorkflowConfig({ repoName })); - + await mockGithub.setup(); }); @@ -22,43 +27,46 @@ test('validate inputs and secrets', async () => { const act = new Act(mockGithub.repo.getPath(repoName)); const mockInputs = { - use_chromatic: true + use_chromatic: true, }; setInputs({ act, mockInputs }); - - setSecrets({ act, mockSecrets: [ - 'CHROMATIC_PROJECT_TOKEN' - ]}); + + setSecrets({ act, mockSecrets: ['CHROMATIC_PROJECT_TOKEN'] }); const results = await runWorkflow({ act, repoName, mockGithub }); // chromatic_upload const chromatic_inputs = getTestResult({ results, name: 'chromatic_inputs' }); - + expect(chromatic_inputs.output).toContain(`chromatic_project_token=***`); // magic_url const magic_url_inputs = getTestResult({ results, name: 'magic_url_inputs' }); - expect(magic_url_inputs.output).toContain(`migration=${mockPackageJson.config.migration}`); + expect(magic_url_inputs.output).toContain( + `migration=${mockPackageJson.config.migration}` + ); // pr_comment - const pr_comment_inputs = getTestResult({ results, name: 'pr_comment_inputs' }); - - expect(pr_comment_inputs.output).toContain(`message=To run E2E tests leave a comment`); + const pr_comment_inputs = getTestResult({ + results, + name: 'pr_comment_inputs', + }); + + expect(pr_comment_inputs.output).toContain( + `message=To run E2E tests leave a comment` + ); }); test('default flow', async () => { const act = new Act(mockGithub.repo.getPath(repoName)); const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'pr_comment', - 'migration_number', - 'validate', - 'magic_url' - ] }); + const jobs_found = getTestResults({ + results, + names: ['pr_comment', 'migration_number', 'validate', 'magic_url'], + }); expect(jobs_found.length).toEqual(4); }); @@ -70,9 +78,7 @@ test('when use_validate is false', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate' - ] }); + const jobs_found = getTestResults({ results, names: ['validate'] }); expect(jobs_found.length).toEqual(0); }); @@ -84,9 +90,7 @@ test('when use_chromatic is true', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'chromatic_upload' - ] }); + const jobs_found = getTestResults({ results, names: ['chromatic_upload'] }); expect(jobs_found.length).toEqual(1); }); diff --git a/.github/workflows/test/provision_only_pr.test.ts b/.github/workflows/test/provision_only_pr.test.ts index 9aaac400..4fa3973e 100644 --- a/.github/workflows/test/provision_only_pr.test.ts +++ b/.github/workflows/test/provision_only_pr.test.ts @@ -9,7 +9,7 @@ const repoName = 'provision_only_pr'; beforeEach(async () => { mockGithub = new MockGithub(getWorkflowConfig({ repoName })); - + await mockGithub.setup(); }); @@ -22,9 +22,7 @@ test('default flow', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate', - ] }); + const jobs_found = getTestResults({ results, names: ['validate'] }); expect(jobs_found.length).toEqual(1); }); diff --git a/.github/workflows/test/provision_only_release.test.ts b/.github/workflows/test/provision_only_release.test.ts index 43c0a931..d41f0b5d 100644 --- a/.github/workflows/test/provision_only_release.test.ts +++ b/.github/workflows/test/provision_only_release.test.ts @@ -9,7 +9,7 @@ const repoName = 'provision_only_release'; beforeEach(async () => { mockGithub = new MockGithub(getWorkflowConfig({ repoName })); - + await mockGithub.setup(); }); @@ -19,17 +19,18 @@ afterEach(async () => { test('validate inputs and secrets', async () => { const act = new Act(mockGithub.repo.getPath(repoName)); - const mockSecrets = [ - 'AUTO_GITHUB_PAT_TOKEN' - ]; + const mockSecrets = ['AUTO_GITHUB_PAT_TOKEN']; setSecrets({ act, mockSecrets }); const results = await runWorkflow({ act, repoName, mockGithub }); // version_artifact - const version_artifact_inputs = getTestResult({ results, name: 'version_artifact_inputs' }); - + const version_artifact_inputs = getTestResult({ + results, + name: 'version_artifact_inputs', + }); + expect(version_artifact_inputs.output).toContain(`github_token=***`); }); @@ -38,10 +39,10 @@ test('default flow', async () => { const results = await runWorkflow({ act, repoName, mockGithub }); - const jobs_found = getTestResults({ results, names: [ - 'validate', - 'version_artifact' - ] }); + const jobs_found = getTestResults({ + results, + names: ['validate', 'version_artifact'], + }); expect(jobs_found.length).toEqual(2); }); diff --git a/README.md b/README.md index 81823825..f0df5556 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,16 @@ The following workflows are for the entire JupiterOne organization. - [frontend_npm_release](.github/workflows/docs/frontend/frontend_npm_release.md) ### Backend Workflows + - [publish_docker_ghcr](.github/workflows/docs/backend/publish_docker_ghcr.md) - [publish_integration_docker_image](.github/workflows/docs/backend/publish_integration_docker_image.md) ## Composite Actions -The workflows above take advantage of the composite actions listed below, leveraging composition to execute those jobs that pertain to the workflow. The actions below enable us to consolidate repeatable jobs into a single location. This makes our workflows DRY, easier to reason about and more stable. +The workflows above take advantage of the composite actions listed below, +leveraging composition to execute those jobs that pertain to the workflow. The +actions below enable us to consolidate repeatable jobs into a single location. +This makes our workflows DRY, easier to reason about and more stable. ### Common @@ -66,7 +70,11 @@ The workflows above take advantage of the composite actions listed below, levera ## Local Testing -We are using [act-js](https://github.com/kiegroup/act-js) and [mock-github](https://www.npmjs.com/package/@kie/mock-github#mockgithub) to test our workflows and composite actions. These tests are intended to simplify development, speed up the feedback loop, and bring more stability to our flows and actions. To run the tests, please execute the following command: +We are using [act-js](https://github.com/kiegroup/act-js) and +[mock-github](https://www.npmjs.com/package/@kie/mock-github#mockgithub) to test +our workflows and composite actions. These tests are intended to simplify +development, speed up the feedback loop, and bring more stability to our flows +and actions. To run the tests, please execute the following command: ``` npm test @@ -84,7 +92,11 @@ ACT_LOG=true npm test #### Skipping Steps -Many of our steps cannot and should not be run during testing (installing npm packages, running cypress, etc.) and would break if we were to run them locally. To address this issue, you can define a `mocks.ts` file in your composite actions. This file should define the list of steps in your action that `should be skipped` during testing: +Many of our steps cannot and should not be run during testing (installing npm +packages, running cypress, etc.) and would break if we were to run them locally. +To address this issue, you can define a `mocks.ts` file in your composite +actions. This file should define the list of steps in your action that +`should be skipped` during testing: ``` // .github/actions/frontend/chromatic/mocks.ts @@ -94,7 +106,8 @@ export const CHROMATIC_MOCK_STEPS = [ ]; ``` -When necessary you can also pass in `mockSteps` via the `runWorkflow` or `runCompositeAction` commands. +When necessary you can also pass in `mockSteps` via the `runWorkflow` or +`runCompositeAction` commands. **Mock composite action via runCompositeAction** @@ -138,11 +151,18 @@ const results = await runWorkflow({ act, repoName, mockGithub, mockSteps: { ### Mapping Workflow Inputs To Composite Actions -As workflows grow over time, they may end up with a considerable number of inputs. We want to make sure those inputs get mapped to the correct composite actions. This is accomplished using the following approach. +As workflows grow over time, they may end up with a considerable number of +inputs. We want to make sure those inputs get mapped to the correct composite +actions. This is accomplished using the following approach. -If a composite action leverages inputs, you will see one its first steps has a name of `[name]_inputs` ([example](.github/actions/frontend/runtime/e2e_prepare/action.yml#L25)). This step is responsible for logging out the various inputs that are being passed to the action. +If a composite action leverages inputs, you will see one its first steps has a +name of `[name]_inputs` +([example](.github/actions/frontend/runtime/e2e_prepare/action.yml#L25)). This +step is responsible for logging out the various inputs that are being passed to +the action. -Then in our tests we are able to target these inputs and verify that the appropriate inputs are being mapped to the correct composite actions. +Then in our tests we are able to target these inputs and verify that the +appropriate inputs are being mapped to the correct composite actions. ``` const test_inputs = getTestResult({ results, name: 'test_inputs' }); @@ -152,18 +172,32 @@ expect(test_inputs.output).toContain(`example_input=hello world`); #### Composite Actions -When it comes to testing a composite action, you will notice the action has a test directory containing at least two files: -- `test/action_test.yml` - A composite action can not be triggered by itself like a workflow. This is a workflow file that utilizes the composition action ([example](.github/actions/frontend/runtime/e2e_prepare/test/action_test.yml)). +When it comes to testing a composite action, you will notice the action has a +test directory containing at least two files: + +- `test/action_test.yml` - A composite action can not be triggered by itself + like a workflow. This is a workflow file that utilizes the composition action + ([example](.github/actions/frontend/runtime/e2e_prepare/test/action_test.yml)). - `test/action.test.ts` - This is the test itself that calls `action_test.yml`. -Note: You must ensure that `name` of the job and the `path` within in the `action_test.yml` match the `repoName` defined in the `action.test.ts`, otherwise the test will fail. +Note: You must ensure that `name` of the job and the `path` within in the +`action_test.yml` match the `repoName` defined in the `action.test.ts`, +otherwise the test will fail. -Note: All booleans in a composite action must leverage fromJSON to ensure the value are treated as booleans and not strings. See issue here: https://github.com/actions/runner/issues/1483 +Note: All booleans in a composite action must leverage fromJSON to ensure the +value are treated as booleans and not strings. See issue here: +https://github.com/actions/runner/issues/1483 ## Testing In Another Repo -If you wish to copy/paste the workflows and/or composite actions into another repo to test these out live, you can leverage the following command. This will create a `temp` directory with the workflows/actions in it. These will have been updated to: -- The `uses` property in the workflows will reference local composite actions - `jupiterone/.github/.github/actions/.../@v#` updated to `./.github/actions/...` +If you wish to copy/paste the workflows and/or composite actions into another +repo to test these out live, you can leverage the following command. This will +create a `temp` directory with the workflows/actions in it. These will have been +updated to: + +- The `uses` property in the workflows will reference local composite actions - + `jupiterone/.github/.github/actions/.../@v#` updated to + `./.github/actions/...` - Test/readme files will also be dropped as these can cause issues. ``` diff --git a/bin/generate-local-files.js b/bin/generate-local-files.js index a5625495..db2e63eb 100644 --- a/bin/generate-local-files.js +++ b/bin/generate-local-files.js @@ -15,8 +15,8 @@ if (!fs.existsSync(dest)) { fs.cpSync(src, dest, { recursive: true, filter: (name) => { - const include = - !name.includes('/test') && + const include = + !name.includes('/test') && !name.includes('.md') && !name.includes('.DS_Store') && !name.includes('mocks.ts'); @@ -26,7 +26,7 @@ fs.cpSync(src, dest, { } return include; - } + }, }); filesToUpdate.forEach((file) => { @@ -37,4 +37,4 @@ filesToUpdate.forEach((file) => { .replace(/(uses: .\/.github\/actions.*)(@.*)/g, `$1 `); fs.writeFileSync(file, result, 'utf-8'); -}); \ No newline at end of file +}); diff --git a/bin/update-composite-tags.js b/bin/update-composite-tags.js index dc3250aa..59de6914 100644 --- a/bin/update-composite-tags.js +++ b/bin/update-composite-tags.js @@ -10,19 +10,24 @@ const updateFlow = async (fileName) => { const pathToPrFlow = `${pathToWorkflows}/${fileName}`; const workflow = await readFile(pathToPrFlow, 'utf8'); const tagVersion = TAG_VERSION.replace('v', ''); - const newWorkflow = workflow.replace(/(jupiterone\/.github\/.github\/actions.*@).*/g, `$1v${tagVersion}`); + const newWorkflow = workflow.replace( + /(jupiterone\/.github\/.github\/actions.*@).*/g, + `$1v${tagVersion}` + ); await writeFile(pathToPrFlow, newWorkflow); }; const update = async () => { const files = await readdir(pathToWorkflows); - const filteredFiles = files.filter(file => file.includes('.yaml') || file.includes('.yml')); - + const filteredFiles = files.filter( + (file) => file.includes('.yaml') || file.includes('.yml') + ); + for await (const file of filteredFiles) { await updateFlow(file); } -} +}; (async () => { if (!TAG_VERSION) { @@ -32,4 +37,4 @@ const update = async () => { } await update(); -})(); \ No newline at end of file +})(); diff --git a/tests/utils/helpers.ts b/tests/utils/helpers.ts index 4c9f7e45..ca4597e9 100644 --- a/tests/utils/helpers.ts +++ b/tests/utils/helpers.ts @@ -4,7 +4,10 @@ import { Act } from '@kie/act-js'; Helpers methods for finding and extracting a test result from the act-js output. */ -interface Result { name: string; output: string; } +interface Result { + name: string; + output: string; +} export const getTestResult = ({ results, @@ -23,7 +26,7 @@ export const getTestResults = ({ names, }: { results: Result[]; - names: string[] + names: string[]; }) => { const resultsFound = results.filter((result) => names.includes(result?.name?.replace('Main ', '')) @@ -37,8 +40,9 @@ export const setInputs = ({ mockInputs, }: { act: Act; - mockInputs: object -}) => Object.keys(mockInputs).forEach((key) => act.setInput(key, mockInputs[key])); + mockInputs: object; +}) => + Object.keys(mockInputs).forEach((key) => act.setInput(key, mockInputs[key])); export const setSecrets = ({ act, @@ -46,4 +50,5 @@ export const setSecrets = ({ }: { act: Act; mockSecrets: string[]; -}) => mockSecrets.forEach((mockSecret) => act.setSecret(mockSecret, mockSecret)); +}) => + mockSecrets.forEach((mockSecret) => act.setSecret(mockSecret, mockSecret)); diff --git a/tests/utils/mocking.ts b/tests/utils/mocking.ts index fd3bf47e..2fc254fd 100644 --- a/tests/utils/mocking.ts +++ b/tests/utils/mocking.ts @@ -1,6 +1,6 @@ import fs from 'fs'; import { resolve } from 'node:path'; -import { writeFileSync, readFileSync } from "node:fs"; +import { writeFileSync, readFileSync } from 'node:fs'; import yaml from 'js-yaml'; import { cwd } from 'node:process'; @@ -11,12 +11,12 @@ type Step = { with: { ref: string; }; -} +}; type MockCompositeStep = { mockWith?: string; name: string; -} +}; export type MockCompositeSteps = MockCompositeStep[]; @@ -24,33 +24,37 @@ type MockStep = { mockWith?: string; name: string; mockCompositeSteps?: MockCompositeSteps; -} +}; export type MockSteps = { [key: string]: MockStep[]; }; -const localizePath = (path: string) => path - .replace(/jupiterone\/.github\//g, '') - .replace(/@.*/g, ''); +const localizePath = (path: string) => + path.replace(/jupiterone\/.github\//g, '').replace(/@.*/g, ''); const getCompositeMockSteps = async ({ mockSteps, - pathToCompositeFolder + pathToCompositeFolder, }: { - mockSteps?:MockCompositeSteps; + mockSteps?: MockCompositeSteps; pathToCompositeFolder: string; }) => { // Look for mocks being passed in - let mockCompositeSteps:MockCompositeSteps = mockSteps; + let mockCompositeSteps: MockCompositeSteps = mockSteps; // Otherwise dynamically load in mocks from composite action if (!mockCompositeSteps) { - const pathToCompositeMocks = resolve(cwd(), `${pathToCompositeFolder}/mocks.ts`); + const pathToCompositeMocks = resolve( + cwd(), + `${pathToCompositeFolder}/mocks.ts` + ); if (fs.existsSync(pathToCompositeMocks)) { const compositeMocks = await import(pathToCompositeMocks); - mockCompositeSteps = Object.values(compositeMocks).flat() as unknown as MockCompositeSteps; + mockCompositeSteps = Object.values( + compositeMocks + ).flat() as unknown as MockCompositeSteps; } } @@ -63,15 +67,17 @@ composite action within the temp repo (i.e. ./repo/name_of_repo/...). */ const updateCompositeSteps = ({ mockCompositeSteps, - actionPath + actionPath, }: { - mockCompositeSteps: MockCompositeSteps, + mockCompositeSteps: MockCompositeSteps; actionPath?: string; }) => { const actionYaml = yaml.load(readFileSync(actionPath, 'utf8')); mockCompositeSteps?.forEach((mockStep) => { - const step = actionYaml?.runs?.steps.filter((step) => step?.name === mockStep?.name).shift(); + const step = actionYaml?.runs?.steps + .filter((step) => step?.name === mockStep?.name) + .shift(); if (step) updateStepAsMock({ step, mockStep }); }); @@ -82,15 +88,18 @@ const updateCompositeSteps = ({ export const updateCompositeWithMocks = async ({ repoName, originDirectory, - mockSteps + mockSteps, }: { - repoName: string, + repoName: string; originDirectory: string; mockSteps?: MockCompositeSteps; }) => { const actionPath = resolve(`repo`, repoName, 'action.yml'); const pathToCompositeFolder = originDirectory.replace('/test', ''); - const mockCompositeSteps = await getCompositeMockSteps({ pathToCompositeFolder, mockSteps }); + const mockCompositeSteps = await getCompositeMockSteps({ + pathToCompositeFolder, + mockSteps, + }); updateCompositeSteps({ actionPath, @@ -107,21 +116,26 @@ export const updateWorkflowWithMocks = async ({ repoName, mockSteps = {}, }: { - repoPath:string, - repoName: string, + repoPath: string; + repoName: string; mockSteps?: MockSteps; }) => { - const workflowPath = resolve(repoPath, '.github', 'workflows', `${repoName}.yml`); + const workflowPath = resolve( + repoPath, + '.github', + 'workflows', + `${repoName}.yml` + ); const workflowYaml = yaml.load(readFileSync(workflowPath, 'utf8')); - const jobs:{ + const jobs: { [key: string]: { - steps: [Step] - } + steps: [Step]; + }; } = workflowYaml?.jobs; // Loop through each job and the corresponding steps in the workflow for await (const entry of Object.entries(jobs)) { - const [ key, value ] = entry; + const [key, value] = entry; for await (const step of value.steps) { // Only update steps that leverage a jupiterone composite action if (step?.uses?.includes('jupiterone')) { @@ -129,7 +143,7 @@ export const updateWorkflowWithMocks = async ({ repoName, mockSteps, key, - step + step, }); } @@ -149,16 +163,16 @@ the uses/with property as they become obsolete. */ const updateStepAsMock = ({ step, - mockStep + mockStep, }: { step: Step; mockStep?: MockStep | MockCompositeStep; }) => { step.run = mockStep?.mockWith || `echo ''`; - + if (step && step?.uses) delete step.uses; if (step && step?.with) delete step.with; -} +}; /* For each individual step, we want to: @@ -169,17 +183,19 @@ const updateStepInJob = async ({ repoName, mockSteps = {}, key, - step + step, }: { - repoName: string, + repoName: string; mockSteps?: MockSteps; key: string; step: Step; }) => { - const mockJobStep:MockStep = mockSteps[key]?.filter(({ name }) => name === step.name)?.shift(); + const mockJobStep: MockStep = mockSteps[key] + ?.filter(({ name }) => name === step.name) + ?.shift(); const mockCompositeSteps = await getCompositeMockSteps({ mockSteps: mockJobStep?.mockCompositeSteps, - pathToCompositeFolder: localizePath(step.uses) + pathToCompositeFolder: localizePath(step.uses), }); // Update job step in workflow to point at local composite action @@ -196,7 +212,7 @@ const updateStepInJob = async ({ // Will mock the entire workflow job step if mocked externally if (mockJobStep && !mockJobStep?.mockCompositeSteps) { - updateStepAsMock({ step, mockStep:mockJobStep }); + updateStepAsMock({ step, mockStep: mockJobStep }); } return step; diff --git a/tests/utils/setup.ts b/tests/utils/setup.ts index b247e431..72856122 100644 --- a/tests/utils/setup.ts +++ b/tests/utils/setup.ts @@ -2,7 +2,12 @@ import { join, resolve } from 'node:path'; import { cwd } from 'node:process'; import { Act } from '@kie/act-js'; import { MockGithub } from '@kie/mock-github'; -import { updateCompositeWithMocks, updateWorkflowWithMocks, MockSteps, MockCompositeSteps } from './mocking'; +import { + updateCompositeWithMocks, + updateWorkflowWithMocks, + MockSteps, + MockCompositeSteps, +} from './mocking'; export const getCompositeActionConfig = ({ directory, @@ -13,7 +18,7 @@ export const getCompositeActionConfig = ({ directory: string; repoName: string; actionTriggeringComposite?: string; - additionalFiles?: { src: string; dest: string; }[]; + additionalFiles?: { src: string; dest: string }[]; }) => { return { repo: { @@ -32,7 +37,7 @@ export const getCompositeActionConfig = ({ src: resolve(cwd(), 'tests', 'package.json'), dest: 'package.json', }, - ...(additionalFiles ? additionalFiles : []) + ...(additionalFiles ? additionalFiles : []), ], }, }, @@ -44,7 +49,7 @@ export const getWorkflowConfig = ({ additionalFiles, }: { repoName: string; - additionalFiles?: { src: string; dest: string; }[]; + additionalFiles?: { src: string; dest: string }[]; }) => { return { repo: { @@ -63,9 +68,9 @@ export const getWorkflowConfig = ({ { src: resolve(cwd(), '.github/actions'), dest: `.github/actions`, - filter: ['**/test'] // Don't copy over the tests in composite actions + filter: ['**/test'], // Don't copy over the tests in composite actions }, - ...(additionalFiles ? additionalFiles : []) + ...(additionalFiles ? additionalFiles : []), ], }, }, @@ -81,16 +86,18 @@ export const runCompositeAction = async ({ act: Act; repoName: string; originDirectory: string; - mockSteps?: MockCompositeSteps, + mockSteps?: MockCompositeSteps; }) => { await updateCompositeWithMocks({ repoName, originDirectory, - mockSteps + mockSteps, + }); + + const result = await act.runEventAndJob('push', repoName, { + logFile: process.env.ACT_LOG ? `log-${repoName}.log` : undefined, }); - const result = await act.runEventAndJob('push', repoName, { logFile: process.env.ACT_LOG ? `log-${repoName}.log` : undefined }); - /* The first two and last item in the returned results are the same for every composite action test. Therefore we want to remove those to make our test results cleaner. @@ -110,7 +117,7 @@ export const runWorkflow = async ({ act: Act; repoName: string; mockGithub: MockGithub; - mockSteps?: MockSteps, + mockSteps?: MockSteps; config?: object; }) => { await updateWorkflowWithMocks({ @@ -121,10 +128,10 @@ export const runWorkflow = async ({ // Need to leverage ubuntu-latest for tests to operate act.setInput('fallback_runner', 'true'); - + const result = await act.runEvent('workflow_call', { ...config, - logFile: process.env.ACT_LOG ? `log-${repoName}.log` : undefined + logFile: process.env.ACT_LOG ? `log-${repoName}.log` : undefined, }); return result; diff --git a/tsconfig.json b/tsconfig.json index d29c8c71..8249eef7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,8 +6,8 @@ "types": ["vitest/globals"], "paths": { "~*": ["./.github*"], - "tests*": ["./tests*"], - }, + "tests*": ["./tests*"] + } }, "include": [".github/**/*.ts", "tests/**/*.ts"] } diff --git a/vitest.config.ts b/vitest.config.ts index c5a466f7..0cc17902 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -15,6 +15,6 @@ export default defineConfig({ test: { globals: true, // environment: 'happy-dom', - testTimeout: 600000 + testTimeout: 600000, }, }); From 5815597889210f7cb97364b379ff4ddf669f2a9a Mon Sep 17 00:00:00 2001 From: Sivli Embir Date: Fri, 5 Jan 2024 10:10:51 -0800 Subject: [PATCH 2/2] npm-dev-deps_2 - allow for dev deps in npm bundles --- .github/workflows/frontend_npm_release.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/frontend_npm_release.yml b/.github/workflows/frontend_npm_release.yml index 44e95bde..25c5e4d2 100644 --- a/.github/workflows/frontend_npm_release.yml +++ b/.github/workflows/frontend_npm_release.yml @@ -19,6 +19,10 @@ on: need to make sure we don't break the pipeline." default: true type: boolean + use_dev_deps_for_publish: + description: 'If true will leverage the npm dev deps for publishing' + default: false + type: boolean secrets: NPM_TOKEN: description: 'A J1 npm.com Publish token' @@ -94,6 +98,8 @@ jobs: fetch-depth: 0 - name: setup_env uses: jupiterone/.github/.github/actions/setup_env@v3.0.42 + with: + use_dev: ${{ inputs.use_dev_deps_for_publish }} - name: build uses: jupiterone/.github/.github/actions/build@v3.0.42 - name: publish