diff --git a/.github/workflows/_prek.yaml b/.github/workflows/_prek.yaml new file mode 100644 index 000000000..63cd5a70f --- /dev/null +++ b/.github/workflows/_prek.yaml @@ -0,0 +1,26 @@ +name: Prek Formatting Checks + +on: + workflow_call: + +jobs: + prek: + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v6 + + - name: Setup Node + uses: actions/setup-node@v6.4.0 + with: + node-version: "22.x" + + - name: Install stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.16.1 + with: + components: rustfmt + + - name: Run prek hooks + uses: j178/prek-action@v2.0.6 + with: + prek-version: "0.4.12" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7a686bf2d..2d6e658e0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -203,3 +203,8 @@ jobs: steps: - name: Lint Workflows uses: diamondlightsource/workflows@main + + prek: + # Deduplicate jobs from pull requests and branch pushes within the same repo. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + uses: ./.github/workflows/_prek.yaml