Skip to content

Commit b33e746

Browse files
committed
Add GHA job enusre error codes are up to date and snippets fail with expected error
1 parent a3616db commit b33e746

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/scaladoc.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,43 @@ jobs:
8585

8686
- name: Test sourcelinks to stdlib
8787
run: true # ./project/scripts/sbt scaladoc/sourceLinksIntegrationTest:test
88+
89+
check-error-code-snippets:
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v6
93+
- uses: coursier/cache-action@v7
94+
- uses: VirtusLab/scala-cli-setup@v1
95+
- with:
96+
jvm: temurin:17
97+
- name: Publish compiler locally
98+
run: |
99+
version=$(./project/scripts/sbt "print scala3-compiler-bootstrapped-new/version" | tail -n1)
100+
echo "SCALA_VERSION=$version" >> $GITHUB_ENV
101+
echo "Would test snippets using Scala $version"
102+
103+
# Publish locally minimal set of artifacts that would be required to test snippets
104+
sbt "set every doc := new File(\"unused\");\
105+
all \
106+
scala-library-bootstrapped/publishLocal \
107+
scala3-compiler-bootstrapped-new/publishLocal \
108+
scala3-interfaces/publishLocal \
109+
scala3-library-bootstrapped-new/publishLocal \
110+
"
111+
- name: Test error code snippets
112+
shell: bash
113+
run: scala-cli test -S ${{ env.SCALA_VERSION }} --with-compiler project/scripts/checkErrorCodeSnippets.test.scala -- +l +a +c
114+
- if: failure()
115+
run: |
116+
cat << EOF >> $GITHUB_STEP_SUMMARY
117+
Snippets validation for error codes failed
118+
119+
If you've modified messages of positions of error codes, you might need to update the expected outputs, to do it run: following command:
120+
scala -S ${{ env.SCALA_VERSION }} project/scripts/checkErrorCodeSnippets.scala --with-compiler --main-class=updateAllErrorCodeOutputs
121+
122+
Single error code validation can be performed using:
123+
scala -S ${{ env.SCALA_VERSION }} project/scripts/checkErrorCodeSnippets.scala --with-compiler -- docs/_docs/reference/error-codes/E001.md [--verbose --update-output]
124+
125+
To check the validation use dedicated test suite:
126+
scala test -S ${{ env.SCALA_VERSION }} --with-compiler project/scripts/checkErrorCodeSnippets.test.scala -- +l +a +c
127+
EOF

0 commit comments

Comments
 (0)