-
Notifications
You must be signed in to change notification settings - Fork 66
Add e2e test workflow #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cb9726d
Add e2e workflow
JillRegan c5bb7eb
Remove comment
JillRegan 3f5c447
Merge branch 'jill/add-sections-and-fields-tests' into jill/add-e2e-t…
JillRegan a0c7a28
Install OP CLI
JillRegan c2ae4bc
add handeling for push to main
JillRegan 2748372
Add ok to test workflow
JillRegan c5a0942
Add push condition back
JillRegan a04d379
Fix syntax error
JillRegan 98bf371
Update to ensure branch is main
JillRegan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,33 @@ | ||
| name: E2E Tests | ||
|
|
||
| on: | ||
| workflow_call: | ||
| secrets: | ||
| OP_SERVICE_ACCOUNT_TOKEN: | ||
| description: "1Password service account token" | ||
| required: true | ||
|
|
||
| jobs: | ||
| e2e-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Install 1Password CLI | ||
| uses: 1password/install-cli-action@v2 | ||
| with: | ||
| version: 2.32.0 | ||
|
|
||
| - name: Install dependencies | ||
| run: go mod tidy | ||
|
|
||
| - name: Run E2E tests | ||
| run: make test-e2e | ||
| env: | ||
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} |
This file contains hidden or 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,25 @@ | ||
| # Write comments "/ok-to-test sha=<hash>" on a pull request. This will emit a repository_dispatch event. | ||
| name: Ok To Test | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| jobs: | ||
| ok-to-test: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write # For adding reactions to the pull request comments | ||
| contents: write # For executing the repository_dispatch event | ||
| # Only run for PRs, not issue comments | ||
| if: ${{ github.event.issue.pull_request }} | ||
| steps: | ||
| - name: Slash Command Dispatch | ||
| uses: volodymyrZotov/slash-command-dispatch@7c1b623a2b0eba93f684c34f689a441f0be84cf1 # TODO: use peter-evans/slash-command-dispatch when fix for team permissions is released https://github.com/peter-evans/slash-command-dispatch/pull/424 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| reaction-token: ${{ secrets.GITHUB_TOKEN }} | ||
| issue-type: pull-request | ||
| commands: ok-to-test | ||
| # The repository permission level required by the user to dispatch commands. Only allows 1Password collaborators to run this. | ||
| permission: write |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,110 @@ | ||
| name: Test E2E | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths-ignore: &ignore_paths | ||
| - "docs/**" | ||
| - "examples/**" | ||
| - "*.md" | ||
| - ".gitignore" | ||
| - "LICENSE" | ||
JillRegan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - "scripts/**" | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| branches: ["**"] # run for PRs targeting any branch | ||
| paths-ignore: *ignore_paths | ||
| repository_dispatch: | ||
| types: [ok-to-test-command] | ||
|
|
||
| concurrency: | ||
| group: >- | ||
| ${{ github.event_name == 'pull_request' && | ||
| format('e2e-{0}', github.event.pull_request.head.ref) || | ||
| format('e2e-{0}', github.ref) }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| check-external-pr: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| condition: ${{ steps.check.outputs.condition }} | ||
| steps: | ||
| - name: Check if PR is from external contributor | ||
| id: check | ||
| run: | | ||
| echo "Event name: ${{ github.event_name }}" | ||
| echo "Repository: ${{ github.repository }}" | ||
|
|
||
| if [ "${{ github.event_name }}" == "pull_request" ]; then | ||
| # For pull_request events, check if PR is from external fork | ||
| echo "PR head repo: ${{ github.event.pull_request.head.repo.full_name }}" | ||
| if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then | ||
| echo "condition=skip" >> $GITHUB_OUTPUT | ||
| echo "Setting condition=skip (external fork PR creation)" | ||
| else | ||
| echo "condition=pr-creation-maintainer" >> $GITHUB_OUTPUT | ||
| echo "Setting condition=pr-creation-maintainer (internal PR creation)" | ||
| fi | ||
| elif [ "${{ github.event_name }}" == "repository_dispatch" ]; then | ||
| # For repository_dispatch events (ok-to-test), check if sha matches | ||
| SHA_PARAM="${{ github.event.client_payload.slash_command.args.named.sha }}" | ||
| PR_HEAD_SHA="${{ github.event.client_payload.pull_request.head.sha }}" | ||
|
|
||
| echo "Checking dispatch event conditions..." | ||
| echo "SHA from command: $SHA_PARAM" | ||
| echo "PR head SHA: $PR_HEAD_SHA" | ||
|
|
||
| if [ -n "$SHA_PARAM" ] && [[ "$PR_HEAD_SHA" == *"$SHA_PARAM"* ]]; then | ||
| echo "condition=dispatch-event" >> $GITHUB_OUTPUT | ||
| echo "Setting condition=dispatch-event (sha matches)" | ||
| else | ||
| echo "condition=skip" >> $GITHUB_OUTPUT | ||
| echo "Setting condition=skip (sha does not match or empty)" | ||
| fi | ||
| elif [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref_name }}" == "main" ]; then | ||
| echo "condition=push-to-main" >> $GITHUB_OUTPUT | ||
| echo "Setting condition=push-to-main (push to main)" | ||
| else | ||
| # Unknown event type | ||
| echo "condition=skip" >> $GITHUB_OUTPUT | ||
| echo "Setting condition=skip (unknown event type: ${{ github.event_name }})" | ||
| fi | ||
|
|
||
| e2e: | ||
| needs: check-external-pr | ||
| if: | | ||
| (needs.check-external-pr.outputs.condition == 'pr-creation-maintainer') | ||
| || | ||
| (needs.check-external-pr.outputs.condition == 'dispatch-event') | ||
| || | ||
| needs.check-external-pr.outputs.condition == 'push-to-main' | ||
| uses: ./.github/workflows/e2e-tests.yml | ||
| secrets: | ||
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | ||
|
|
||
| comment-pr: | ||
| needs: [check-external-pr, e2e] | ||
| runs-on: ubuntu-latest | ||
| if: always() && needs.check-external-pr.outputs.condition == 'dispatch-event' | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - name: Create URL to the run output | ||
| id: vars | ||
| run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Create comment on PR | ||
| uses: peter-evans/create-or-update-comment@v5 | ||
| with: | ||
| issue-number: ${{ github.event.client_payload.pull_request.number }} | ||
| body: | | ||
| ${{ | ||
| needs.e2e.result == 'success' && '✅ E2E tests passed.' || | ||
| needs.e2e.result == 'failure' && '❌ E2E tests failed.' || | ||
| '⚠️ E2E tests completed.' | ||
| }} | ||
|
|
||
| [View test run output][1] | ||
|
|
||
| [1]: ${{ steps.vars.outputs.run-url }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.