-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (61 loc) · 1.98 KB
/
Copy pathci.yml
File metadata and controls
70 lines (61 loc) · 1.98 KB
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
name: Test Action
on:
push:
pull_request:
jobs:
test-changed:
name: Test mode=changed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- uses: ./
with:
version: '2.98.0.4'
mode: changed
# The action and the hook on every platform they support, with a file that is formatted and one that
# is not. The repository itself has no Java files, so the tests write their own.
test-platforms:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-15-intel, windows-latest]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Write a formatted file
run: printf 'class Formatted {\n int x;\n}\n' > Formatted.java
- name: Check it
uses: ./
with:
version: '2.98.0.4'
mode: all
- name: Write a file that is not formatted
run: printf 'class Unformatted{int x;}\n' > Unformatted.java
- name: Check it, expecting a failure
id: unformatted
continue-on-error: true
uses: ./
with:
version: '2.98.0.4'
mode: all
- name: Make sure the check failed
run: test "${{ steps.unformatted.outcome }}" = failure
- name: Run the pre-commit hook on a file that is not formatted, then on a formatted one
run: |
git init -q hook-test
cd hook-test
printf 'class Hook{int x;}\n' > Hook.java
git add Hook.java
if bash ../pre-commit; then
echo "::error::The hook accepted a file that is not formatted"
exit 1
fi
printf 'class Hook {\n int x;\n}\n' > Hook.java
git add Hook.java
bash ../pre-commit