Repository navigation
fix(*): settle the lint and contract drift the replay left behind #2162
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Commit lint | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, edited] | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: commit-lint-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| pr-title: | |
| name: pull request title | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Validate PR title | |
| env: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| run: PYTHONPATH=. python3 scripts/check_pr_title.py | |
| - name: Validate PR body | |
| env: | |
| PR_BODY: ${{ github.event.pull_request.body }} | |
| run: PYTHONPATH=. python3 scripts/check_pr_body.py | |
| commit-messages: | |
| name: commit messages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Set up Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Install commitlint | |
| run: npm ci | |
| - name: Validate commit messages | |
| env: | |
| DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | |
| run: | | |
| EXCLUDE="" | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| BASE="${{ github.event.pull_request.base.sha }}" | |
| # A commit already on the default branch passed this gate when it | |
| # landed, and nobody can rewrite it now. A PR that merges that | |
| # branch into a long-lived one carries its whole history in | |
| # BASE..HEAD, so exclude it instead of re-linting it. | |
| git fetch --no-tags --quiet origin "$DEFAULT_BRANCH" | |
| EXCLUDE="^FETCH_HEAD" | |
| else | |
| BASE="${{ github.event.before }}" | |
| fi | |
| if [ -z "$BASE" ] || [ "$BASE" = "0000000000000000000000000000000000000000" ]; then | |
| BASE="$(git rev-list --max-parents=0 HEAD)" | |
| fi | |
| FAILED=0 | |
| for sha in $(git rev-list --no-merges "$BASE..HEAD" $EXCLUDE); do | |
| git log -1 --format=%B "$sha" | npx commitlint --config commitlint.config.cjs || FAILED=1 | |
| done | |
| PYTHONPATH=. python3 scripts/check_commit_messages.py "$BASE..HEAD" $EXCLUDE || FAILED=1 | |
| exit "$FAILED" | |
| - name: Validate prospective squash header | |
| if: github.event_name == 'pull_request' | |
| env: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: printf '%s (#%s)\n' "$PR_TITLE" "$PR_NUMBER" | npx commitlint --config commitlint.config.cjs | |
| repository-files: | |
| name: repository files | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Validate changed files | |
| env: | |
| CHECK_LARGE_FILES_MAX_BYTES: 1048576 | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| BASE="${{ github.event.pull_request.base.sha }}" | |
| else | |
| BASE="${{ github.event.before }}" | |
| fi | |
| if [ -z "$BASE" ] || [ "$BASE" = "0000000000000000000000000000000000000000" ]; then | |
| BASE="$(git rev-list --max-parents=0 HEAD)" | |
| fi | |
| PYTHONPATH=. python3 scripts/check_large_files.py "$BASE..HEAD" | |
| PYTHONPATH=. python3 scripts/check_source_language.py "$BASE..HEAD" |