Skip to content

Commit

Permalink
Add workflow to check CAIPs
Browse files Browse the repository at this point in the history
  • Loading branch information
ligi committed Nov 20, 2022
1 parent 6d6c109 commit 6ab049a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .ci/check_caips.main.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env kotlin

@file:Repository("https://jitpack.io")
@file:DependsOn("com.github.komputing:XIP-checker:0.0.1")

import org.komputing.dipchecker.CheckConfig
import org.komputing.dipchecker.checkDate
import org.komputing.dipchecker.checkFolder
import java.io.File
import kotlin.system.exitProcess

val config = CheckConfig("caip",
mapOf(
"title" to { },
"status" to { value ->
if (!listOf("Draft", "Active", "Review", "Final", "Superseded").contains(value)) throw IllegalArgumentException("Invalid status $value")
},
"type" to { value ->
if (!listOf("Meta", "Standard").contains(value)) throw IllegalArgumentException("Invalid type $value")
},
"author" to { },
"created" to { checkDate(it) }),
mapOf(
"requires" to {
if (!Regex("[0-9]+(, [0-9]+)*").matches(it)) throw IllegalArgumentException("Invalid requires $it")
},
"discussions-to" to { },
"superseded-by" to { },
"updated" to { checkDate(it) }
)
)

try {
println(checkFolder(File("CAIPs"), config))
} catch (e: Exception) {
println("Validation of CAIPs failed")
println("Reason: " + e.message)
exitProcess(1)
}

12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: fwilhe2/setup-kotlin@main
- run: kotlin .ci/check_caips.main.kts

0 comments on commit 6ab049a

Please sign in to comment.