From b65299729ce217359cbd7ad476143ceff6d6912b Mon Sep 17 00:00:00 2001 From: Danila Baklazhenko Date: Sat, 8 Mar 2025 11:21:15 +0200 Subject: [PATCH] Add workflow dispatch --- .github/workflows/extended.yml | 37 ++------------ .github/workflows/pr_comment_commands.yml | 60 +++++++++++++++++++++++ 2 files changed, 63 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/pr_comment_commands.yml diff --git a/.github/workflows/extended.yml b/.github/workflows/extended.yml index 3c9dd6f1bc43..b8e05e0b4d9c 100644 --- a/.github/workflows/extended.yml +++ b/.github/workflows/extended.yml @@ -32,36 +32,14 @@ on: push: branches: - main + workflow_dispatch: + - issue_comment: - types: [created] - jobs: - check_trigger: - runs-on: ubuntu-latest - outputs: - should_run: ${{ github.event_name == 'push' || (github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, 'Run extended tests')) }} - # Custom ref is required since issue_comment event points to the default branch rather than pull request branch - ref: ${{ github.event_name == 'push' && github.ref ||format('refs/pull/{0}/head', github.event.issue.number) }} - steps: - - name: Add reaction to comment - if: github.event_name == 'issue_comment' - uses: actions/github-script@v7 - with: - script: | - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket' - }); - # Check crate compiles and base cargo check passes linux-build-lib: name: linux build test - needs: [check_trigger] - if: needs.check_trigger.outputs.should_run == 'true' runs-on: ubuntu-latest # note: do not use amd/rust container to preserve disk space steps: @@ -69,7 +47,6 @@ jobs: with: submodules: true fetch-depth: 1 - ref: ${{ needs.check_trigger.outputs.ref }} - name: Install Rust run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y @@ -85,8 +62,7 @@ jobs: # Run extended tests (with feature 'extended_tests') linux-test-extended: name: cargo test 'extended_tests' (amd64) - needs: [linux-build-lib, check_trigger] - if: needs.check_trigger.outputs.should_run == 'true' + needs: [linux-build-lib] runs-on: ubuntu-latest # note: do not use amd/rust container to preserve disk space steps: @@ -94,7 +70,6 @@ jobs: with: submodules: true fetch-depth: 1 - ref: ${{ needs.check_trigger.outputs.ref }} - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be - name: Install Rust @@ -120,8 +95,6 @@ jobs: # Check answers are correct when hash values collide hash-collisions: name: cargo test hash collisions (amd64) - needs: [check_trigger] - if: needs.check_trigger.outputs.should_run == 'true' runs-on: ubuntu-latest container: image: amd64/rust @@ -130,7 +103,6 @@ jobs: with: submodules: true fetch-depth: 1 - ref: ${{ needs.check_trigger.outputs.ref }} - name: Setup Rust toolchain uses: ./.github/actions/setup-builder with: @@ -143,8 +115,6 @@ jobs: sqllogictest-sqlite: name: "Run sqllogictests with the sqlite test suite" - needs: [check_trigger] - if: needs.check_trigger.outputs.should_run == 'true' runs-on: ubuntu-latest container: image: amd64/rust @@ -153,7 +123,6 @@ jobs: with: submodules: true fetch-depth: 1 - ref: ${{ needs.check_trigger.outputs.ref }} - name: Setup Rust toolchain uses: ./.github/actions/setup-builder with: diff --git a/.github/workflows/pr_comment_commands.yml b/.github/workflows/pr_comment_commands.yml new file mode 100644 index 000000000000..9a558956767b --- /dev/null +++ b/.github/workflows/pr_comment_commands.yml @@ -0,0 +1,60 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: PR commands + +on: + issue_comment: + types: [created] + +permissions: + contents: read + pull-requests: write + actions: write + +jobs: + + run_extended_tests: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, 'Run extended tests') }} + outputs: + # Custom ref is required since issue_comment event points to the default branch rather than pull request branch + ref: ${{ format('refs/pull/{0}/head', github.event.issue.number) }} + steps: + + - name: Dispatch extended tests for a PR branch with comment + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'extended.yml', + ref: 'refs/pull/${context.payload.issue.number}/head', + }); + + - name: Add reaction to comment + uses: actions/github-script@v7 + with: + script: | + await github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.id, + content: 'rocket' + }); \ No newline at end of file