-
Notifications
You must be signed in to change notification settings - Fork 180
139 lines (139 loc) · 4.49 KB
/
pre-commit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Pre-Commit Hook CI
on:
push:
paths:
- pre_commit_hooks/**
- pre_commit_hooks_tests/**
- .github/workflows/pre-commit.yml
- .pre-commit-config.yaml
- .pre-commit-hooks.yaml
pull_request:
paths:
- pre_commit_hooks/**
- pre_commit_hooks_tests/**
- .github/workflows/pre-commit.yml
- .pre-commit-config.yaml
- .pre-commit-hooks.yaml
jobs:
run-unit-tests-and-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run unit tests & linters
uses: actions/setup-python@v5
with:
python-version: '3.x'
architecture: 'x64'
- run: pip install -r requirements-dev.txt
- run: pytest ./pre_commit_hooks_tests/
- run: ruff check ./pre_commit_hooks_tests/ ./pre_commit_hooks
- run: mypy ./pre_commit_hooks/ ./pre_commit_hooks_tests/
- run: black --check .
validate-integ-test-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install pre-commit
- run: pre-commit install
- run: echo >> ./guard/resources/validate/data-dir/advanced_regex_negative_lookbehind_non_compliant.yaml
- run: git add .
- name: Run pre-commit hook
run: |
output=$(pre-commit run 2>&1 || true)
echo $output
if ! echo $output | grep -q "exit code: 19"; then
echo "Expected output not found"
exit 1
fi
test-integ-test-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install pre-commit
- run: pre-commit install
- run: echo >> ./pre_commit_hooks_tests/resources/s3_bucket_logging_enabled.guard
- run: git add .
- name: Run pre-commit hook
run: |
output=$(pre-commit run 2>&1 || true)
echo $output
if ! echo $output | grep -q "exit code: 7"; then
echo "Expected output not found"
exit 1
fi
validate-integ-test-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- run: brew install pre-commit
- run: pre-commit install
- run: echo >> ./guard/resources/validate/data-dir/advanced_regex_negative_lookbehind_non_compliant.yaml
- run: git add .
- name: Run pre-commit hook
run: |
output=$(pre-commit run 2>&1 || true)
echo $output
if ! echo $output | grep -q "exit code: 19"; then
echo "Expected output not found"
exit 1
fi
test-integ-test-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- run: brew install pre-commit
- run: pre-commit install
- run: echo >> ./pre_commit_hooks_tests/resources/s3_bucket_logging_enabled.guard
- run: git add .
- name: Run pre-commit hook
run: |
output=$(pre-commit run 2>&1 || true)
echo $output
if ! echo $output | grep -q "exit code: 7"; then
echo "Expected output not found"
exit 1
fi
validate-integ-test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10.0'
- run: pip install pre-commit
- run: pre-commit install
- run: '"`n" | Out-File -Append ./guard/resources/validate/data-dir/advanced_regex_negative_lookbehind_non_compliant.yaml'
- run: git add .
- name: Run pre-commit hook
shell: powershell
run: |
$output = pre-commit run | Out-String
if ($output | Select-String -Pattern "exit code: 19") {
exit 0
} else {
Write-Host "Expected output not found"
Write-Host $output
exit 1
}
test-integ-test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10.0'
- run: pip install pre-commit
- run: pre-commit install
- run: '"`n" | Out-File -Append ./pre_commit_hooks_tests/resources/s3_bucket_logging_enabled.guard'
- run: git add .
- name: Run pre-commit hook
shell: powershell
run: |
$output = pre-commit run | Out-String
if ($output | Select-String -Pattern "exit code: 7") {
exit 0
} else {
Write-Host "Expected output not found"
Write-Host $output
exit 1
}