-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
252 additions
and
187 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
.github/workflows/docs/frontend/frontend_runtime_utility_manual_e2e_trigger.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# 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. | ||
|
||
## 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 | ||
|
||
## 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 | ||
|
||
## Example Usage | ||
|
||
### Default Flow | ||
|
||
#### Usage | ||
|
||
```yaml | ||
# Triggered by adding a comment to a PR | ||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
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') | ||
uses: jupiterone/.github/.github/workflows/frontend_runtime_application_pr.yml@v# | ||
secrets: | ||
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | ||
E2E_AUTO: ${{ secrets.E2E_AUTO }} | ||
``` | ||
#### Diagram | ||
```mermaid | ||
graph LR; | ||
A[start flow]; | ||
B[e2e_pending_status]; | ||
C[migration_number]; | ||
D[magic_url]; | ||
E[e2e_trigger_remote_tests]; | ||
F[external_repo]; | ||
G[e2e_status]; | ||
|
||
A --> B --> C --> D --> E -->|trigger E2E tests and wait| F -->|report back status| E --> G; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
.github/workflows/frontend_runtime_utility_manual_e2e_trigger.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Default workflow for a runtime utility when a PR is opened | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
fallback_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" | ||
type: boolean | ||
default: false | ||
repos_to_test: | ||
description: "Kick off a n+ spec files within n+ repos" | ||
type: string | ||
secrets: | ||
NPM_TOKEN: | ||
description: "A J1 npm.com Publish token" | ||
required: true | ||
E2E_AUTO: | ||
description: "A J1 token for kicking off cypress tests" | ||
required: false | ||
|
||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
e2e_pending_status: | ||
runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: e2e_pending_status | ||
uses: jupiterone/.github/.github/actions/frontend/runtime/e2e_pending_status | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
migration_number: | ||
runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} | ||
outputs: | ||
migration: ${{ steps.migration_number.outputs.migration }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: migration_number | ||
name: migration_number | ||
uses: jupiterone/.github/.github/actions/frontend/runtime/migration_number@v2 | ||
|
||
magic_url: | ||
runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} | ||
needs: [migration_number] | ||
permissions: | ||
id-token: write | ||
statuses: write | ||
contents: read | ||
issues: read | ||
pull-requests: read | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: setup_env | ||
uses: jupiterone/.github/.github/actions/setup_env@v2 | ||
with: | ||
use_dev: true | ||
- name: build | ||
uses: jupiterone/.github/.github/actions/build@v2 | ||
- name: magic_url | ||
uses: jupiterone/.github/.github/actions/frontend/runtime/magic_url@v2 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
migration_number: ${{ needs.migration_number.outputs.migration }} | ||
# runtime utilities do not have a route of there own, so we default to home | ||
magic_url_route: '/home' | ||
|
||
e2e_trigger_remote_tests: | ||
runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} | ||
needs: [magic_url] | ||
strategy: | ||
matrix: | ||
repos: ${{ fromJson(inputs.repos_to_test) }} | ||
continue-on-error: ${{ inputs.e2e_pass_on_error }} | ||
outputs: | ||
test_passed: ${{ steps.e2e_trigger_remote_tests.outputs.test_passed }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: setup_env | ||
uses: jupiterone/.github/.github/actions/setup_env@v2 | ||
with: | ||
use_dev: true | ||
- id: e2e_trigger_remote_tests | ||
name: e2e_trigger_remote_tests | ||
uses: jupiterone/.github/.github/actions/frontend/runtime/e2e_trigger_remote_tests@v2 | ||
with: | ||
e2e_pass_on_error: ${{ inputs.e2e_pass_on_error }} | ||
e2e_auto: ${{ secrets.E2E_AUTO }} | ||
repo_name: ${{ matrix.repos.repo.name }} | ||
repo_spec: ${{ matrix.repos.repo.spec }} | ||
|
||
e2e_status: | ||
name: E2E Status | ||
runs-on: ${{ (inputs.fallback_runner && 'ubuntu-latest') || 'scaleset-jupiterone-infra-arm64' }} | ||
needs: [e2e_pending_status, e2e_trigger_remote_tests] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: e2e_status | ||
uses: jupiterone/.github/.github/actions/frontend/runtime/e2e_status | ||
if: always() | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
e2e_pass_on_error: ${{ inputs.e2e_pass_on_error }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.