EncodingList-updated #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: {} | |
| # Allow this workflow to be triggered via a `POST` request to | |
| # `https://api.github.com/repos/kaitai-io/ksy_schema/dispatches`. This is | |
| # performed by the CI workflow | |
| # https://github.com/kaitai-io/kaitai_struct_compiler/blob/6a1a7e25914cf9abe1f3807bff63f155dcfc7806/.github/workflows/encoding-list-updated.yml | |
| # when the source file `EncodingList.scala` in KSC is updated. | |
| repository_dispatch: | |
| types: | |
| - EncodingList-updated | |
| # Cancel in-progress runs of the same workflow - | |
| # from https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: {} | |
| jobs: | |
| check-encodings: | |
| name: Check that the encoding list is up-to-date with KSC | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Check out ksy_schema | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| path: ksy_schema | |
| - name: Get list of encodings from ksy_schema | |
| working-directory: ksy_schema | |
| run: | | |
| jq '.definitions.CharacterEncoding.enum' ksy_schema.json | tee encodings.json | |
| - name: Check out compiler | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| repository: kaitai-io/kaitai_struct_compiler | |
| path: compiler | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - uses: sbt/setup-sbt@v1 | |
| - name: Get list of canonical encodings from KSC | |
| working-directory: compiler | |
| # Written to work with https://github.com/kaitai-io/kaitai_struct_compiler/blob/56582ef65ca869ca43a1691a496bf4989f938675/shared/src/main/scala/io/kaitai/struct/EncodingList.scala | |
| run: | | |
| 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))' \ | |
| | sbt --error compilerJVM/console | |
| jq . encodings.min.json > encodings.json | |
| rm -f encodings.min.json | |
| echo | |
| cat encodings.json | |
| - name: Compare encoding lists in ksy_schema and KSC | |
| run: | | |
| git diff --color=always --no-index --exit-code -- ksy_schema/encodings.json compiler/encodings.json |