Skip to content

Commit

Permalink
chore(ci): add pre-commit and renovate validation (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
p5 committed Jan 21, 2024
1 parent 3f82ff2 commit 571f724
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/actions/run-pre-commit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run pre-commit

inputs:
pre-commit-args:
description: 'Additional arguments to pass to pre-commit'
required: false
default: '--all-files'

runs:
using: 'composite'
steps:
- name: Setup Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5

- name: Run pre-commit
uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # v3.0.0
with:
extra_args: ${{ inputs.pre-commit-args }}

- name: Check for changed files
shell: bash
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "pre-commit changed files, please run pre-commit locally and commit the changes"
exit 1
fi
25 changes: 25 additions & 0 deletions .github/actions/validate-renovate-config/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Validate Renovate config

inputs:
renovate-version:
description: 'The version of Renovate to use'
required: false
default: 'latest'

runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4
with:
node-version: latest

- name: Install dependencies
shell: bash
env:
RENOVATE_VERSION: ${{ inputs.renovate-version }}
run: npm install -g renovate@${RENOVATE_VERSION}

- name: Validate Renovate config
shell: bash
run: renovate-config-validator --strict
23 changes: 23 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pre-Commit CI

on:
pull_request:
paths:
- .pre-commit-config.yml
- .github/workflows/pre-commit.yml
push:
branches:
- main
paths:
- .pre-commit-config.yml
- .github/workflows/pre-commit.yml

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Run pre-commit
uses: ./.github/actions/run-pre-commit
23 changes: 23 additions & 0 deletions .github/workflows/renovate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Renovate CI

on:
pull_request:
paths:
- ".github/renovate.json5"
- ".github/workflows/renovate.yml"
push:
branches:
- main
paths:
- ".github/renovate.json5"
- ".github/workflows/renovate.yml"

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Validate Renovate Configuration
uses: ./.github/actions/validate-renovate-config
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

0 comments on commit 571f724

Please sign in to comment.