|
| 1 | +# Copyright (c) 2025 ADBC Drivers Contributors |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# This is a common workflow for performing basic PR checks: |
| 16 | +# |
| 17 | +# - Run pre-commit |
| 18 | +# |
| 19 | +# It is also planned to cover things like checking the PR title/description |
| 20 | +# format and ensuring issues and milestones are properly linked. |
| 21 | + |
| 22 | +name: Dev |
| 23 | + |
| 24 | +on: |
| 25 | + pull_request: |
| 26 | + types: |
| 27 | + - opened |
| 28 | + - edited |
| 29 | + - reopened |
| 30 | + - synchronize |
| 31 | + push: |
| 32 | + branches: |
| 33 | + - main |
| 34 | + workflow_call: {} |
| 35 | + |
| 36 | +concurrency: |
| 37 | + group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }} |
| 38 | + cancel-in-progress: true |
| 39 | + |
| 40 | +defaults: |
| 41 | + run: |
| 42 | + shell: bash |
| 43 | + |
| 44 | +permissions: |
| 45 | + contents: read |
| 46 | + |
| 47 | +jobs: |
| 48 | + # Check the PR itself. |
| 49 | + pr_standard: |
| 50 | + name: "Check PR" |
| 51 | + runs-on: ubuntu-latest |
| 52 | + if: github.event_name == 'pull_request' |
| 53 | + |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v5 |
| 56 | + with: |
| 57 | + fetch-depth: 1 |
| 58 | + persist-credentials: false |
| 59 | + |
| 60 | + - name: Check PR title format |
| 61 | + if: github.repository == 'adbc-drivers/dev' |
| 62 | + env: |
| 63 | + PR_TITLE: ${{ github.event.pull_request.title }} |
| 64 | + run: | |
| 65 | + python adbc_drivers_dev/title_check.py $(pwd) "$PR_TITLE" |
| 66 | +
|
| 67 | + - name: Check PR title format |
| 68 | + if: github.repository != 'adbc-drivers/dev' |
| 69 | + env: |
| 70 | + PR_TITLE: ${{ github.event.pull_request.title }} |
| 71 | + run: | |
| 72 | + git clone --depth 1 git@github.com:adbc-drivers/dev |
| 73 | + python dev/adbc_drivers_dev/title_check.py $(pwd) "$PR_TITLE" |
| 74 | +
|
| 75 | + lint: |
| 76 | + name: "lint & pre-commit" |
| 77 | + runs-on: ubuntu-latest |
| 78 | + if: "github.event.action != 'edited'" |
| 79 | + |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v5 |
| 82 | + with: |
| 83 | + fetch-depth: 0 |
| 84 | + persist-credentials: false |
| 85 | + |
| 86 | + - uses: actions/setup-go@v6 |
| 87 | + with: |
| 88 | + check-latest: true |
| 89 | + go-version: "stable" |
| 90 | + |
| 91 | + - uses: actions/setup-python@v6 |
| 92 | + with: |
| 93 | + python-version: "3.x" |
| 94 | + |
| 95 | + - name: Install |
| 96 | + run: pip install pre-commit |
| 97 | + |
| 98 | + - name: pre-commit (cache) |
| 99 | + uses: actions/cache@v4 |
| 100 | + with: |
| 101 | + path: ~/.cache/pre-commit |
| 102 | + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} |
| 103 | + |
| 104 | + - name: pre-commit |
| 105 | + run: | |
| 106 | + pre-commit run --all-files --color=always --show-diff-on-failure --verbose |
0 commit comments