Skip to content

Commit b792562

Browse files
committed
Check in CI that the encoding list is up-to-date with KSC
1 parent 3bef091 commit b792562

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/check.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Check
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request: {}
8+
9+
jobs:
10+
check-encodings:
11+
name: Check that the encoding list is up-to-date with KSC
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Check out ksy_schema
16+
uses: actions/checkout@v4
17+
with:
18+
path: ksy_schema
19+
- name: Get list of encodings from ksy_schema
20+
working-directory: ksy_schema
21+
run: |
22+
jq '.definitions.CharacterEncoding.enum' ksy_schema.json > encodings.json
23+
24+
- name: Check out compiler
25+
uses: actions/checkout@v4
26+
with:
27+
repository: kaitai-io/kaitai_struct_compiler
28+
path: compiler
29+
- name: Set up JDK
30+
uses: actions/setup-java@v4
31+
with:
32+
distribution: temurin
33+
java-version: '21'
34+
- uses: sbt/setup-sbt@v1
35+
- name: Get list of canonical encodings from KSC
36+
working-directory: compiler
37+
# Written to work with https://github.com/kaitai-io/kaitai_struct_compiler/blob/56582ef65ca869ca43a1691a496bf4989f938675/shared/src/main/scala/io/kaitai/struct/EncodingList.scala
38+
run: |
39+
echo 'java.nio.file.Files.write(java.nio.file.Paths.get("encodings.min.json"), io.kaitai.struct.JSON.stringify(io.kaitai.struct.EncodingList.canonicalToAliasEntries.map(_._1)).getBytes(java.nio.charset.StandardCharsets.UTF_8))' \
40+
| sbt compilerJVM/console
41+
jq . encodings.min.json > encodings.json
42+
rm -f encodings.min.json
43+
44+
- name: Compare encoding lists in ksy_schema and KSC
45+
run: |
46+
git diff --no-index --exit-code -- ksy_schema/encodings.json compiler/encodings.json

0 commit comments

Comments
 (0)