Skip to content

Commit

Permalink
test: add workflow testing pre-commit hook config
Browse files Browse the repository at this point in the history
  • Loading branch information
boidolr committed Feb 8, 2024
1 parent c3bf02f commit c028d73
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Test pre-commit hook"

on:
push:
branches:
- main
- dev
- develop
pull_request:
branches:
- main
workflow_dispatch:
schedule:
- cron: "15 7 */7 * *"

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- uses: boidolr/actions/run-precommit@main
with:
working-directory: tests

6 changes: 6 additions & 0 deletions tests/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/boidolr/precommit-ast-grep
rev: main
hooks:
- id: ast-grep
args: ["--config=tests/sgconfig.yaml", "--filter=ast-grep-pass", "--update-all"]
11 changes: 11 additions & 0 deletions tests/rules/test-rule-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id: ast-grep-fix
message: Test fix rule
severity: error
language: json
rule:
kind: pair
has:
field: key
regex: version
fix: |
"version": "0.1.0"
9 changes: 9 additions & 0 deletions tests/rules/test-rule-pass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
id: ast-grep-pass
message: Test pass rule
severity: error
language: json
rule:
kind: pair
has:
field: key
regex: "no match"
2 changes: 2 additions & 0 deletions tests/sgconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ruleDirs:
- ./rules

0 comments on commit c028d73

Please sign in to comment.