Skip to content

Merge pull request #8376 from govuk-one-login/revert-8369-ATO-2438-qu… #14531

Merge pull request #8376 from govuk-one-login/revert-8369-ATO-2438-qu…

Merge pull request #8376 from govuk-one-login/revert-8369-ATO-2438-qu… #14531

Workflow file for this run

name: pre-commit
on:
pull_request:
types:
- opened
- reopened
- ready_for_review
- synchronize
push:
branches:
- main
merge_group:
jobs:
noop-on-merge-group:
if: github.event_name == 'merge_group'
runs-on: ubuntu-latest
name: Run pre-commit # important this is the same name as the pre-commit job
steps:
- name: 🛑 Skip Pre-commit Checks for Merge Group
run: echo "This is a merge group event. Skipping pre-commit checks."; true
shell: bash
pre-commit:
# This job will run on all pull requests and pushes to main, but not on merge groups
# We run it on merge to main to ensure that pre-commit's cache is up to date
if: github.event_name != 'merge_group'
runs-on: ubuntu-latest
name: Run pre-commit # important this is the same name as the noop-on-merge-group job
steps:
- name: 📦 Check Out Repository Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: 🏗️ Set Up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 #v5.2.0
with:
java-version: "17"
distribution: "corretto"
- name: 🏗️ Set Up Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v4
with:
cache-read-only: false
add-job-summary: never
- name: 🏗️ Set Up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
cache: "pip"
- name: 📦 Cache Go modules
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-cache-rain-v1.20.1-${{ runner.os }}
# Go modules expect semantic version tags like v1.20.1 not commit hashes.
- name: 🏗️ Install rain
run: |
go install github.com/aws-cloudformation/rain/cmd/rain@v1.20.1
echo "$HOME/go/bin" >> "$GITHUB_PATH"
"$HOME/go/bin/rain" --version
shell: bash
- name: 🏗️ Set Up Terraform
uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4.0.0
- name: 🏗️ Install Pre-commit
run: python -m pip install pre-commit
shell: bash
- name: 🛠️ Freeze Python Dependencies
run: python -m pip freeze --local
shell: bash
- name: 📦 Cache Pre-commit tools
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-3|${{ env.pythonLocation }}|
pre-commit-3|
- name: ✅ Run Pre-commit Hooks
run: |
pre-commit run --show-diff-on-failure --color=always \
--from-ref "${{ github.event.pull_request.base.sha }}" \
--to-ref "${{ github.event.pull_request.head.sha }}"
shell: bash
- name: 🧹 Cache Cleanup
run: pre-commit gc
shell: bash