Skip to content

Commit

Permalink
Propose more basic pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
hofbi committed Dec 17, 2024
1 parent ec5d715 commit 624136d
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e2e/
e2e/
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUN apt update && apt install -y --no-install-recommends \
python3-venv

# Install pre-commit
RUN pip install --break-system-packages pre-commit
RUN pip install --break-system-packages pre-commit
2 changes: 0 additions & 2 deletions .github/workflows/buildifier.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Buildifier

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
Expand All @@ -9,7 +8,6 @@ on:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
Expand All @@ -9,13 +8,11 @@ on:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

concurrency:
# Cancel previous actions from the same PR or branch except 'main' branch.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info.
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}}
cancel-in-progress: ${{ github.ref_name != 'main' }}

jobs:
test:
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v6
Expand All @@ -42,14 +39,12 @@ jobs:
if: always()
steps:
- uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 # v3.0.3

# Note: possible conclusion values:
# https://github.com/technote-space/workflow-conclusion-action/blob/main/src/constant.ts
- name: report success
if: ${{ env.WORKFLOW_CONCLUSION == 'success' }}
working-directory: /tmp
run: echo ${{ env.WORKFLOW_CONCLUSION }} && exit 0

- name: report failure
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' }}
working-directory: /tmp
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Cut a release whenever a new tag is pushed to the repo.
name: Release

on:
# Can be triggered from the tag.yaml workflow
workflow_call:
Expand All @@ -12,10 +11,8 @@ on:
push:
tags:
- "v*.*.*"

permissions:
contents: write

jobs:
release:
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@c9d6d1893b10a8d68584a6ba52c3dd35506486d0 # 2024-12-03
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ http_archive(
EOF

awk 'f;/--SNIP--/{f=1}' e2e/smoke/WORKSPACE.bazel
echo "\`\`\`"
echo "\`\`\`"
2 changes: 0 additions & 2 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ on:
# Allow devs to tag manually through the GitHub UI.
# For example after landing a fix that customers are waiting for.
workflow_dispatch:

# Run twice a month, on the 1rst and 15th at 3PM UTC (8AM PST)
# This is a trade-off between making too many releases,
# which overwhelms BCR maintainers and over-notifies users,
# and releasing too infrequently which delays delivery of bugfixes and features.
schedule:
- cron: "0 15 1,15 * *"

jobs:
tag:
permissions:
Expand Down
33 changes: 31 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,30 @@
# Commitizen runs in commit-msg stage
# but we don't want to run the other hooks on commit messages
default_stages: [commit]

# Use a slightly older version of node by default
# as the default uses a very new version of GLIBC
default_language_version:
node: 16.18.0

repos:
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
exclude: |
(?x)^(
docs/
)
- id: trailing-whitespace
# Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier
rev: 7.3.1.1
Expand All @@ -29,3 +46,15 @@ repos:
rev: v3.1.0
hooks:
- id: prettier
- repo: https://github.com/google/yamlfmt
rev: v0.14.0
hooks:
- id: yamlfmt
exclude: |
(?x)^(
.bcr/config.yml
)
- repo: https://github.com/crate-ci/typos
rev: v1.28.4
hooks:
- id: typos
1 change: 1 addition & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# See https://github.com/crate-ci/typos?tab=readme-ov-file#false-positives how to ignore
2 changes: 1 addition & 1 deletion e2e/smoke/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# smoke test

This e2e exercises the repo from an end-users perpective.
This e2e exercises the repo from an end-users perspective.
It catches mistakes in our install instructions, or usages that fail when called from an "external" repository to rules_mylang.
It is also used by the presubmit check for the Bazel Central Registry.

0 comments on commit 624136d

Please sign in to comment.