-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added new GitHub action for manual integration test run based on PR #4135
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
4 commits
Select commit
Hold shift + click to select a range
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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # | ||
| # This workflow allows manually running integration tests against an open PR or a branch. | ||
| # Go to Actions → "Integration Tests (Manual)" → Run workflow → enter a PR number or branch name. | ||
| # | ||
| # It reuses the existing dotnet-build-and-test and python-merge-tests workflows, | ||
| # passing a ref so they check out and test the correct code. | ||
| # | ||
|
|
||
| name: Integration Tests (Manual) | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr-number: | ||
| description: "PR number to run integration tests against (leave empty if using branch)" | ||
| required: false | ||
| type: string | ||
| default: "" | ||
| branch: | ||
| description: "Branch name to run integration tests against (leave empty if using PR number)" | ||
| required: false | ||
| type: string | ||
| default: "" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: integration-tests-manual-${{ github.event.inputs.pr-number || github.event.inputs.branch }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| resolve-ref: | ||
| name: Resolve ref | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| checkout-ref: ${{ steps.resolve.outputs.checkout-ref }} | ||
| steps: | ||
| - name: Resolve checkout ref | ||
| id: resolve | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.inputs.pr-number }} | ||
| BRANCH: ${{ github.event.inputs.branch }} | ||
| REPO: ${{ github.repository }} | ||
| REPO_OWNER: ${{ github.repository_owner }} | ||
| run: | | ||
| if [ -n "$PR_NUMBER" ] && [ -n "$BRANCH" ]; then | ||
| echo "::error::Please provide either a PR number or a branch name, not both." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$PR_NUMBER" ] && [ -z "$BRANCH" ]; then | ||
| echo "::error::Please provide either a PR number or a branch name." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -n "$PR_NUMBER" ]; then | ||
| if ! echo "$PR_NUMBER" | grep -Eq '^[0-9]+$'; then | ||
| echo "::error::Invalid PR number. Only numeric values are allowed." | ||
| exit 1 | ||
| fi | ||
|
|
||
| PR_DATA=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json state,headRepository,headRepositoryOwner) | ||
| PR_STATE=$(echo "$PR_DATA" | jq -r '.state') | ||
| HEAD_OWNER=$(echo "$PR_DATA" | jq -r '.headRepositoryOwner.login') | ||
|
|
||
| if [ "$PR_STATE" != "OPEN" ]; then | ||
| echo "::error::PR #$PR_NUMBER is not open (state: $PR_STATE)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$HEAD_OWNER" != "$REPO_OWNER" ]; then | ||
| echo "::error::PR #$PR_NUMBER is from a fork ($HEAD_OWNER). Running integration tests against fork PRs is not allowed for security reasons." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "checkout-ref=refs/pull/$PR_NUMBER/head" >> "$GITHUB_OUTPUT" | ||
| echo "Running integration tests for PR #$PR_NUMBER" | ||
| else | ||
| if ! echo "$BRANCH" | grep -Eq '^[a-zA-Z0-9_./-]+$'; then | ||
| echo "::error::Invalid branch name. Only alphanumeric characters, hyphens, underscores, dots, and slashes are allowed." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "checkout-ref=$BRANCH" >> "$GITHUB_OUTPUT" | ||
| echo "Running integration tests for branch $BRANCH" | ||
| fi | ||
|
|
||
| dotnet-integration-tests: | ||
| name: .NET Integration Tests | ||
| needs: resolve-ref | ||
| uses: ./.github/workflows/dotnet-build-and-test.yml | ||
| with: | ||
| checkout-ref: ${{ needs.resolve-ref.outputs.checkout-ref }} | ||
| secrets: inherit | ||
|
|
||
| python-integration-tests: | ||
| name: Python Integration Tests | ||
| needs: resolve-ref | ||
| uses: ./.github/workflows/python-merge-tests.yml | ||
| with: | ||
| checkout-ref: ${{ needs.resolve-ref.outputs.checkout-ref }} | ||
| secrets: inherit | ||
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
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.