Skip to content

Commit 6ab049a

Browse files
committed
Add workflow to check CAIPs
1 parent 6d6c109 commit 6ab049a

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.ci/check_caips.main.kts

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env kotlin
2+
3+
@file:Repository("https://jitpack.io")
4+
@file:DependsOn("com.github.komputing:XIP-checker:0.0.1")
5+
6+
import org.komputing.dipchecker.CheckConfig
7+
import org.komputing.dipchecker.checkDate
8+
import org.komputing.dipchecker.checkFolder
9+
import java.io.File
10+
import kotlin.system.exitProcess
11+
12+
val config = CheckConfig("caip",
13+
mapOf(
14+
"title" to { },
15+
"status" to { value ->
16+
if (!listOf("Draft", "Active", "Review", "Final", "Superseded").contains(value)) throw IllegalArgumentException("Invalid status $value")
17+
},
18+
"type" to { value ->
19+
if (!listOf("Meta", "Standard").contains(value)) throw IllegalArgumentException("Invalid type $value")
20+
},
21+
"author" to { },
22+
"created" to { checkDate(it) }),
23+
mapOf(
24+
"requires" to {
25+
if (!Regex("[0-9]+(, [0-9]+)*").matches(it)) throw IllegalArgumentException("Invalid requires $it")
26+
},
27+
"discussions-to" to { },
28+
"superseded-by" to { },
29+
"updated" to { checkDate(it) }
30+
)
31+
)
32+
33+
try {
34+
println(checkFolder(File("CAIPs"), config))
35+
} catch (e: Exception) {
36+
println("Validation of CAIPs failed")
37+
println("Reason: " + e.message)
38+
exitProcess(1)
39+
}
40+

.github/workflows/ci.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: CI
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: fwilhe2/setup-kotlin@main
12+
- run: kotlin .ci/check_caips.main.kts

0 commit comments

Comments
 (0)