diff --git a/.github/workflows/alioss-integration.yml b/.github/workflows/alioss-integration.yml index 2f9911a..882a290 100644 --- a/.github/workflows/alioss-integration.yml +++ b/.github/workflows/alioss-integration.yml @@ -2,12 +2,12 @@ name: Alioss Integration Tests on: workflow_dispatch: + inputs: + pr_ref: + description: 'SHA of the PR head commit (for fork PRs)' + required: false + default: '' pull_request: - paths: - - ".github/workflows/alioss-integration.yml" - - "alioss/**" - - "go.mod" - - "go.sum" push: branches: - main @@ -28,6 +28,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v7 + with: + ref: ${{ inputs.pr_ref || github.sha }} - name: Set up Go uses: actions/setup-go@v6 with: diff --git a/.github/workflows/azurebs-integration.yml b/.github/workflows/azurebs-integration.yml index 5f51562..b6412e1 100644 --- a/.github/workflows/azurebs-integration.yml +++ b/.github/workflows/azurebs-integration.yml @@ -2,12 +2,12 @@ name: Azurebs Integration Tests on: workflow_dispatch: + inputs: + pr_ref: + description: 'SHA of the PR head commit (for fork PRs)' + required: false + default: '' pull_request: - paths: - - ".github/workflows/azurebs-integration.yml" - - "azurebs/**" - - "go.mod" - - "go.sum" push: branches: - main @@ -28,6 +28,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v7 + with: + ref: ${{ inputs.pr_ref || github.sha }} - name: Set up Go uses: actions/setup-go@v6 with: diff --git a/.github/workflows/dav-integration.yml b/.github/workflows/dav-integration.yml index 298f733..8a60a5f 100644 --- a/.github/workflows/dav-integration.yml +++ b/.github/workflows/dav-integration.yml @@ -2,12 +2,12 @@ name: DAV Integration Tests on: workflow_dispatch: + inputs: + pr_ref: + description: 'SHA of the PR head commit (for fork PRs)' + required: false + default: '' pull_request: - paths: - - ".github/workflows/dav-integration.yml" - - "dav/**" - - "go.mod" - - "go.sum" push: branches: - main @@ -28,6 +28,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v7 + with: + ref: ${{ inputs.pr_ref || github.sha }} - name: Set up Go uses: actions/setup-go@v6 diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..626c734 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,15 @@ +name: Dependabot auto-merge + +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + auto-merge: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - name: Enable auto-merge + run: gh pr merge --auto --rebase "${{ github.event.pull_request.number }}" diff --git a/.github/workflows/fork-integration-trigger.yml b/.github/workflows/fork-integration-trigger.yml new file mode 100644 index 0000000..071590c --- /dev/null +++ b/.github/workflows/fork-integration-trigger.yml @@ -0,0 +1,48 @@ +name: Trigger integration tests for fork PRs + +on: + issue_comment: + types: [created] + +permissions: + pull-requests: write + +jobs: + trigger: + name: Trigger integration tests + runs-on: ubuntu-latest + if: | + github.event.issue.pull_request != null && + contains(github.event.comment.body, '/run-integration') + steps: + - name: Check commenter has write permission + run: | + permission=$(gh api repos/$GITHUB_REPOSITORY/collaborators/${{ github.actor }}/permission --jq '.permission') + if [[ "$permission" != "write" && "$permission" != "admin" ]]; then + echo "${{ github.actor }} does not have write permission (got: $permission)" + exit 1 + fi + + - name: Get PR head SHA and check for fork + id: pr + run: | + pr=$(gh pr view ${{ github.event.issue.number }} --json headRefOid,isCrossRepository) + read -r ref is_fork < <(echo "$pr" | jq -r '[.headRefOid, (.isCrossRepository | tostring)] | @tsv') + if [[ "$is_fork" == "false" ]]; then + echo "This command is only needed for fork PRs. Integration tests run automatically for PRs from this repository." + exit 1 + fi + echo "ref=$ref" >> $GITHUB_OUTPUT + + - name: Add reaction to comment + run: | + gh api --method POST \ + repos/$GITHUB_REPOSITORY/issues/comments/${{ github.event.comment.id }}/reactions \ + -f content=rocket + + - name: Trigger integration tests + run: | + for workflow in s3-integration.yml gcs-integration.yml alioss-integration.yml azurebs-integration.yml dav-integration.yml; do + gh workflow run "$workflow" --ref ${{ github.event.repository.default_branch }} -f pr_ref=${{ steps.pr.outputs.ref }} & + done + wait diff --git a/.github/workflows/gcs-integration.yml b/.github/workflows/gcs-integration.yml index 42250cd..ff2b1f9 100644 --- a/.github/workflows/gcs-integration.yml +++ b/.github/workflows/gcs-integration.yml @@ -2,12 +2,12 @@ name: GCS Integration Tests on: workflow_dispatch: + inputs: + pr_ref: + description: 'SHA of the PR head commit (for fork PRs)' + required: false + default: '' pull_request: - paths: - - ".github/workflows/gcs-integration.yml" - - "gcs/**" - - "go.mod" - - "go.sum" push: branches: - "main" @@ -27,7 +27,9 @@ jobs: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) steps: - name: Checkout code - uses: actions/checkout@v7 + uses: actions/checkout@v7 + with: + ref: ${{ inputs.pr_ref || github.sha }} - name: Set up Go uses: actions/setup-go@v6 with: @@ -62,7 +64,9 @@ jobs: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) steps: - name: Checkout code - uses: actions/checkout@v7 + uses: actions/checkout@v7 + with: + ref: ${{ inputs.pr_ref || github.sha }} - name: Set up Go uses: actions/setup-go@v6 with: diff --git a/.github/workflows/s3-integration.yml b/.github/workflows/s3-integration.yml index 242a9c6..60d4363 100644 --- a/.github/workflows/s3-integration.yml +++ b/.github/workflows/s3-integration.yml @@ -2,12 +2,12 @@ name: S3 Integration Tests on: workflow_dispatch: + inputs: + pr_ref: + description: 'SHA of the PR head commit (for fork PRs)' + required: false + default: '' pull_request: - paths: - - ".github/workflows/s3-integration.yml" - - "s3/**" - - "go.mod" - - "go.sum" push: branches: - main @@ -32,6 +32,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v7 + with: + ref: ${{ inputs.pr_ref || github.sha }} - name: Set up test environment uses: ./.github/actions/go-test-bootstrap @@ -118,6 +120,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v7 + with: + ref: ${{ inputs.pr_ref || github.sha }} - name: Set up test environment uses: ./.github/actions/go-test-bootstrap @@ -161,6 +165,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v7 + with: + ref: ${{ inputs.pr_ref || github.sha }} - name: Set up test environment uses: ./.github/actions/go-test-bootstrap