Skip to content

Commit 804c11b

Browse files
committed
Validate API reports are up-to-date in CI
1 parent 978e4a5 commit 804c11b

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,28 @@ jobs:
2121
env:
2222
SCALAJS_VERSION: "${{ matrix.scalajsversion == '0.6.x' && '0.6.28' || '' }}"
2323
steps:
24+
2425
- uses: actions/checkout@v2
2526
- uses: olafurpg/setup-scala@v13
2627
with:
2728
java-version: "[email protected]"
2829
- uses: coursier/cache-action@v6
30+
2931
- name: Build
3032
run: sbt "++${{ matrix.scalaversion }}" package
33+
3134
- name: Test generate documentation
3235
run: sbt "++${{ matrix.scalaversion }}" doc
36+
3337
- name: Build examples
3438
run: sbt "++${{ matrix.scalaversion }}" example/compile
35-
- name: scalafmt
39+
40+
- name: Validate formatting
3641
run: sbt "++${{ matrix.scalaversion }}" scalafmtCheck
3742

43+
- name: Validate api report
44+
run: ./api-reports/validate "${{ matrix.scalaversion }}"
45+
3846
readme:
3947
runs-on: ubuntu-latest
4048
steps:
File renamed without changes.
File renamed without changes.

api-reports/validate

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
cd "$(dirname "$0")"
4+
5+
[ $# -ne 1 ] && echo "Usage: $0 <scala version>" && exit 1
6+
7+
series="${1%.*}"
8+
file="${series/./_}.txt"
9+
echo -n "Validating $file ... "
10+
11+
help='Run `sbt +compile` and check in the differences to the '"$(basename "$0") directory"
12+
13+
if [ ! -e "$file" ]; then
14+
echo "file not found. $help"
15+
exit 2
16+
elif [ -n "$(git status --porcelain -- "$file")" ]; then
17+
echo "out-of-date. $help"
18+
exit 3
19+
else
20+
echo "ok"
21+
fi

scalafix/src/main/scala/org/scalajs/dom/scalafix/GenerateApiReport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class GenerateApiReport extends SemanticRule("GenerateApiReport") {
100100
private def saveReport(): Unit = {
101101
val scalaVer = Util.scalaSeriesVer.replace('.', '_')
102102
val projectRoot = System.getProperty("user.dir")
103-
val reportFile = Paths.get(s"$projectRoot/api-$scalaVer.txt")
103+
val reportFile = Paths.get(s"$projectRoot/api-reports/$scalaVer.txt")
104104
val api = state.result().iterator.map(_.stripPrefix("org/scalajs/dom/")).mkString("\n")
105105

106106
val content =

0 commit comments

Comments
 (0)