85 lines
2.6 KiB
YAML
85 lines
2.6 KiB
YAML
name: Check Formatting, Committers and Generated Code
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
concurrency:
|
|
group: ci-check-repo-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
verify:
|
|
name: Verify format
|
|
runs-on: ubuntu-22.04
|
|
outputs:
|
|
format: ${{ steps.should_format.outputs.format }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
submodules: true
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
- name: Check all
|
|
id: should_format
|
|
run: |
|
|
./scripts/check_bats_fmt.sh
|
|
|
|
if ./scripts/check_fmt.sh ; then
|
|
echo "code is formatted"
|
|
else
|
|
echo "code is not formatted"
|
|
if [ "${{ github.repository }}" != "dolthub/doltgresql" ]; then
|
|
echo "Pull requests from forks must be manually formatted."
|
|
echo "Please run scripts/format_repo.sh to format this pull request."
|
|
exit 1;
|
|
fi
|
|
echo "format=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
./postgres/parser/build.sh
|
|
GOFLAGS="-mod=readonly" go build ./...
|
|
go vet -unsafeptr=false -mod=readonly ./...
|
|
env:
|
|
BRANCH_NAME: ${{ github.head_ref }}
|
|
CHANGE_TARGET: ${{ github.base_ref }}
|
|
format:
|
|
needs: verify
|
|
if: ${{ needs.verify.outputs.format == 'true' }}
|
|
name: Format PR
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref || github.ref }}
|
|
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
|
|
submodules: true
|
|
token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
- name: Install goimports
|
|
run: go install golang.org/x/tools/cmd/goimports@latest
|
|
- name: Format repo
|
|
run: ./scripts/format_repo.sh
|
|
env:
|
|
BRANCH_NAME: ${{ github.head_ref }}
|
|
CHANGE_TARGET: ${{ github.base_ref }}
|
|
- name: Changes detected
|
|
id: detect-changes
|
|
run: |
|
|
changes=$(git status --porcelain)
|
|
if [ ! -z "$changes" ]; then
|
|
echo "has-changes=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
- uses: EndBug/add-and-commit@v9.1.4
|
|
if: ${{ steps.detect-changes.outputs.has-changes == 'true' }}
|
|
with:
|
|
message: "[ga-format-pr] Run scripts/format_repo.sh"
|
|
add: "."
|
|
cwd: "."
|
|
pull: "--ff"
|