github.com/dolthub/go-mysql-server@v0.18.0/.github/workflows/format.yml (about)

     1  name: Check/Format PR
     2  
     3  on:
     4    pull_request:
     5      branches: [ main ]
     6  
     7  concurrency:
     8    group: format-${{ github.event.pull_request.number || github.ref }}
     9    cancel-in-progress: true
    10  
    11  jobs:
    12    format:
    13      name: Format PR
    14      if: github.event.pull_request.head.repo.full_name == github.repository
    15      runs-on: ubuntu-22.04
    16      steps:
    17        - name: Setup Go 1.x
    18          uses: actions/setup-go@v3
    19          with:
    20            go-version: ^1.19
    21        - uses: actions/checkout@v3
    22          with:
    23            token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
    24            ref: ${{ github.head_ref }}
    25        - name: Install goimports
    26          run: |
    27            go mod download golang.org/x/tools
    28            go install golang.org/x/tools/cmd/goimports
    29        - name: Format repo
    30          run: |
    31            ./format_repo.sh
    32          env:
    33            BRANCH_NAME: ${{ github.head_ref }}
    34            CHANGE_TARGET: ${{ github.base_ref }}
    35        - name: Changes detected
    36          id: detect-changes
    37          run: |
    38            changes=$(git status --porcelain)
    39            if [ ! -z "$changes" ]; then
    40               echo "has-changes=true" >> $GITHUB_OUTPUT
    41            fi
    42        - uses: EndBug/add-and-commit@v9.1.1
    43          if: ${{ steps.detect-changes.outputs.has-changes == 'true' }}
    44          with:
    45            message: "[ga-format-pr] Run ./format_repo.sh to fix formatting"
    46            add: "."
    47            cwd: "."
    48    verify:
    49      needs: format
    50      name: Verify format
    51      runs-on: ubuntu-22.04
    52      steps:
    53        - name: Setup Go 1.x
    54          uses: actions/setup-go@v3
    55          with:
    56            go-version: ^1.19
    57          id: go
    58        - uses: actions/checkout@v3
    59          with:
    60            ref: ${{ github.head_ref }}
    61        - name: Check all
    62          id: check_format
    63          run: |
    64            ./check_repo.sh
    65          env:
    66            BRANCH_NAME: ${{ github.head_ref }}
    67            CHANGE_TARGET: ${{ github.base_ref }}
    68    alt-verify:
    69      if: github.event.pull_request.head.repo.full_name != github.repository
    70      name: Verify format
    71      runs-on: ubuntu-22.04
    72      steps:
    73        - name: Setup Go 1.x
    74          uses: actions/setup-go@v3
    75          with:
    76            go-version: ^1.19
    77          id: go
    78        - uses: actions/checkout@v3
    79        - name: Check all
    80          id: check_format
    81          run: |
    82            ./check_repo.sh
    83            code=$(echo $?)
    84            if [ "$code" != 0 ]; then
    85              echo "Please run ./format_repo.sh to fix this pull request's formatting"
    86            fi
    87          env:
    88            BRANCH_NAME: ${{ github.head_ref }}
    89            CHANGE_TARGET: ${{ github.base_ref }}