Skip to content

Commit 01af650

Browse files
committed
add ci for validators tests
1 parent 4775de6 commit 01af650

2 files changed

Lines changed: 111 additions & 0 deletions

File tree

.forgejo/workflows/.gitkeep

Whitespace-only changes.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Validate Validators
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'validators/**'
8+
- 'gitinfo.schema.json'
9+
- 'examples/**'
10+
- '.github/workflows/test-validators.yml'
11+
pull_request:
12+
branches: [main]
13+
paths:
14+
- 'validators/**'
15+
- 'gitinfo.schema.json'
16+
- 'examples/**'
17+
- '.github/workflows/test-validators.yml'
18+
workflow_dispatch:
19+
20+
jobs:
21+
test-nodejs:
22+
name: Test Node.js Validator
23+
runs-on: ubuntu-latest
24+
container:
25+
image: node:20-alpine
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Validate minimal example
30+
run: node validators/nodejs/validate.js examples/minimal.gitinfo
31+
32+
- name: Validate open-source-project example
33+
run: node validators/nodejs/validate.js examples/open-source-project.gitinfo
34+
35+
- name: Validate mirror-only example (JSONC with comments)
36+
run: node validators/nodejs/validate.js examples/mirror-only.gitinfo
37+
38+
- name: Test invalid file detection
39+
run: |
40+
echo '{"invalid_field": "should fail"}' > /tmp/invalid.gitinfo
41+
if node validators/nodejs/validate.js /tmp/invalid.gitinfo; then
42+
echo "Expected validation to fail but it passed"
43+
exit 1
44+
else
45+
echo "Correctly detected invalid file"
46+
fi
47+
48+
test-powershell:
49+
name: Test PowerShell Validator
50+
runs-on: ubuntu-latest
51+
container:
52+
image: mcr.microsoft.com/powershell:latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Validate minimal example
57+
shell: pwsh
58+
run: ./validators/powershell/Validate-GitInfo.ps1 -Path examples/minimal.gitinfo
59+
60+
- name: Validate open-source-project example
61+
shell: pwsh
62+
run: ./validators/powershell/Validate-GitInfo.ps1 -Path examples/open-source-project.gitinfo
63+
64+
- name: Validate mirror-only example (JSONC with comments)
65+
shell: pwsh
66+
run: ./validators/powershell/Validate-GitInfo.ps1 -Path examples/mirror-only.gitinfo
67+
68+
- name: Test invalid file detection
69+
shell: pwsh
70+
run: |
71+
'{"invalid_field": "should fail"}' | Set-Content /tmp/invalid.gitinfo
72+
try {
73+
./validators/powershell/Validate-GitInfo.ps1 -Path /tmp/invalid.gitinfo
74+
Write-Error "Expected validation to fail but it passed"
75+
exit 1
76+
} catch {
77+
Write-Host "Correctly detected invalid file"
78+
}
79+
80+
test-bash:
81+
name: Test Bash Validator
82+
runs-on: ubuntu-latest
83+
container:
84+
image: alpine:latest
85+
steps:
86+
- uses: actions/checkout@v4
87+
88+
- name: Install dependencies
89+
run: apk add --no-cache bash jq coreutils
90+
91+
- name: Make script executable
92+
run: chmod +x validators/bash/validate.sh
93+
94+
- name: Validate minimal example
95+
run: ./validators/bash/validate.sh examples/minimal.gitinfo
96+
97+
- name: Validate open-source-project example
98+
run: ./validators/bash/validate.sh examples/open-source-project.gitinfo
99+
100+
- name: Validate mirror-only example (JSONC with comments)
101+
run: ./validators/bash/validate.sh examples/mirror-only.gitinfo
102+
103+
- name: Test invalid file detection
104+
run: |
105+
echo '{"invalid_field": "should fail"}' > /tmp/invalid.gitinfo
106+
if ./validators/bash/validate.sh /tmp/invalid.gitinfo; then
107+
echo "Expected validation to fail but it passed"
108+
exit 1
109+
else
110+
echo "Correctly detected invalid file"
111+
fi

0 commit comments

Comments
 (0)