Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

add workflow combining quick and simple PR checks (#82126)

Chris Vandoodewaardcc1fa36312fe
diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml
index f0b70fc97af..b48ee156a18 100644
--- a/.github/actionlint.yaml
+++ b/.github/actionlint.yaml
@@ -14,3 +14,6 @@ paths:
.github/workflows/lint.yml:
ignore:
- 'step must run script with "run" section or run action with "uses" section'
+ .github/workflows/pr.checks.yml:
+ ignore:
+ - 'step must run script with "run" section or run action with "uses" section'
diff --git a/.github/workflows/block-master-source-branch-prs.yml b/.github/workflows/block-master-source-branch-prs.yml
deleted file mode 100644
index 1cfe78a5c5d..00000000000
--- a/.github/workflows/block-master-source-branch-prs.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-name: Block Master Branch PRs
-on:
- pull_request:
- types: [opened, synchronize]
-
-jobs:
- check-source-branch:
- if: github.head_ref == 'master'
- runs-on: ${{ vars.SLIM_RUNNER_KEY }}
- timeout-minutes: 5
- steps:
- - name: Block master branch PRs
- run: |
- echo "PRs from \`master\` branches are not allowed, please use a new branch name for your PR."
- exit 1
diff --git a/.github/workflows/check-backport-script.yml b/.github/workflows/check-backport-script.yml
deleted file mode 100644
index 393404f74cf..00000000000
--- a/.github/workflows/check-backport-script.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-name: Prevent backport.sh from being merged
-
-on:
- pull_request:
- types: [opened, synchronize, reopened]
-
-jobs:
- check-backport-script:
- runs-on: ${{ vars.SLIM_RUNNER_KEY }}
- timeout-minutes: 5
- steps:
- - name: Checkout code
- uses: actions/checkout@v6
- - name: Check for backport.sh file
- run: |
- if [ -f "./backport.sh" ]; then
- echo "backport.sh file exists. Please remove it before merging."
- exit 1
- else
- echo "All good."
- fi
diff --git a/.github/workflows/linear-pr-links.yml b/.github/workflows/linear-pr-links.yml
deleted file mode 100644
index 97781d3cd66..00000000000
--- a/.github/workflows/linear-pr-links.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-name: Add Issue References to PR
-
-on:
- pull_request:
- types: [opened, edited, synchronize]
-
-jobs:
- add-issue-references:
- runs-on: ${{ vars.SLIM_RUNNER_KEY }}
- timeout-minutes: 5
- steps:
- - name: Checkout code
- uses: actions/checkout@v6
- - name: Run the link script
- uses: actions/github-script@v9
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
- PR_NUMBER: ${{ github.event.pull_request.number }}
- REPO_OWNER: ${{ github.repository_owner }}
- REPO_NAME: ${{ github.event.repository.name }}
- with:
- script: |
- const { link_issues } = require('${{ github.workspace }}/.github/scripts/update-pr-with-issues.js');
- await link_issues(github)
diff --git a/.github/workflows/pr.checks.yml b/.github/workflows/pr.checks.yml
new file mode 100644
index 00000000000..e1c15f189f6
--- /dev/null
+++ b/.github/workflows/pr.checks.yml
@@ -0,0 +1,52 @@
+# Helpful (and quick) checks that run on PRs.
+
+name: PR Checks
+
+on: pull_request
+
+jobs:
+ checks:
+ runs-on: ${{ vars.SLIM_RUNNER_KEY }}
+ timeout-minutes: 10
+ permissions:
+ pull-requests: write
+ issues: read
+ steps:
+ - uses: actions/checkout@v6
+ with:
+ sparse-checkout: |
+ /.github/scripts/update-pr-with-issues.js
+ /backport.sh
+ sparse-checkout-cone-mode: false
+ # download repo structure without file contents, fetched on demand since we only need a few files
+ # NOTE: this gets slow if we start accessing more files, remove this filter in that case.
+ filter: blob:none
+
+ - parallel:
+ - name: Block master branch PRs (from forks)
+ if: github.head_ref == 'master'
+ run: |
+ echo "PRs from \`master\` branches are not allowed, please use a new branch name for your PR."
+ exit 1
+
+ - name: Link PR and issues
+ uses: actions/github-script@v9
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ REPO_OWNER: ${{ github.repository_owner }}
+ REPO_NAME: ${{ github.event.repository.name }}
+ with:
+ script: |
+ const { link_issues } = require('${{ github.workspace }}/.github/scripts/update-pr-with-issues.js');
+ await link_issues(github)
+
+ - name: Prevent backport.sh from being merged
+ run: |
+ if [ -f "./backport.sh" ]; then
+ echo "backport.sh file exists. Please remove it before merging."
+ exit 1
+ else
+ echo "All good."
+ fi
diff --git a/.github/workflows/pull-request-reminders.yml b/.github/workflows/pull-request-reminders.yml
deleted file mode 100644
index 76c3e104f8a..00000000000
--- a/.github/workflows/pull-request-reminders.yml
+++ /dev/null
@@ -1,45 +0,0 @@
-name: Pull Request Reminders
-
-on:
- pull_request:
- types: [opened]
- branches:
- - "master"
-
-jobs:
- external-reminder:
- name: External PR Helper
- if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
- runs-on: ${{ vars.SLIM_RUNNER_KEY }}
- timeout-minutes: 5
- permissions:
- pull-requests: write
- issues: read
- steps:
- - uses: actions/github-script@v9
- with:
- script: | # js
- const owner = context.repo.owner;
- const repo = context.repo.repo;
-
- const pullNumber = '${{ github.event.pull_request.number }}';
- const author = '${{ github.event.pull_request.user.login }}';
-
- await github.rest.issues.addLabels({
- owner,
- repo,
- issue_number: pullNumber,
- labels: ["External"],
- });
-
- const guideLink = "https://www.notion.so/metabase/Third-Party-PRs-External-contributions-5954061854424c1ea6391d98746646e0";
- const message = `@${author} Thanks for your contribution! ❤️ We'll try to review it as soon as we can.\n\n
- Reviewers, make sure to check out our [External PR Review Guide](${guideLink}) when reviewing.
- `;
-
- await github.rest.issues.createComment({
- owner,
- repo,
- issue_number: pullNumber,
- body: message,
- });