From 3a53f423a7ecc985abf4cab22a871a0e81dc23bf Mon Sep 17 00:00:00 2001 From: Stan Date: Sun, 2 Jun 2024 01:23:49 +0200 Subject: [PATCH] up munit version and change leak test params (#112) --- .github/workflows/ci.yml | 152 +++++++----------- .sbtopts | 3 + build.sbt | 2 +- .../kovstas/fs2throttler/MemoryLeakSpec.scala | 10 +- 4 files changed, 70 insertions(+), 97 deletions(-) create mode 100644 .sbtopts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0194c97..3dd8e49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: Build on: push: branches: [ main ] - tags: ["*"] + tags: [ "*" ] paths-ignore: - '**/*.md' pull_request: @@ -16,44 +16,30 @@ jobs: name: Build and Test strategy: matrix: - os: [ubuntu-22.04] - scala: [3.4.2, 2.12.19, 2.13.14] - java: [temurin@17] - project: [rootJS, root, rootNative] + os: [ ubuntu-latest ] + scala: [ 2.12, 2.13, 3 ] + java: [ temurin@17 ] + project: [ rootJS, root, rootNative ] runs-on: ${{ matrix.os }} + timeout-minutes: 60 steps: - name: Checkout current branch (full) - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Download Java (temurin@17) - id: download-java-temurin-17 - if: matrix.java == 'temurin@17' - uses: typelevel/download-java@v1 - with: - distribution: temurin - java-version: 17 - - name: Setup Java (temurin@17) + id: setup-java-temurin-17 if: matrix.java == 'temurin@17' - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: - distribution: jdkfile + distribution: temurin java-version: 17 - jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }} + cache: sbt - - name: Cache sbt - uses: actions/cache@v2 - with: - path: | - ~/.sbt - ~/.ivy2/cache - ~/.coursier/cache/v1 - ~/.cache/coursier/v1 - ~/AppData/Local/Coursier/Cache/v1 - ~/Library/Caches/Coursier/v1 - key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + - name: sbt update + if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false' + run: sbt +update - name: Install brew formulae (ubuntu) if: (matrix.project == 'rootNative') && startsWith(matrix.os, 'ubuntu') @@ -84,7 +70,7 @@ jobs: - name: Upload target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} path: targets.tar @@ -95,122 +81,106 @@ jobs: if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') strategy: matrix: - os: [ ubuntu-22.04 ] - scala: [ 2.13.14 ] + os: [ ubuntu-latest ] java: [ temurin@17 ] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Download Java (temurin@17) - id: download-java-temurin-17 - if: matrix.java == 'temurin@17' - uses: typelevel/download-java@v1 - with: - distribution: temurin - java-version: 17 - - name: Setup Java (temurin@17) + id: setup-java-temurin-17 if: matrix.java == 'temurin@17' - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: - distribution: jdkfile + distribution: temurin java-version: 17 - jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }} + cache: sbt + + - name: sbt update + if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false' + run: sbt +update - - name: Cache sbt - uses: actions/cache@v2 - with: - path: | - ~/.sbt - ~/.ivy2/cache - ~/.coursier/cache/v1 - ~/.cache/coursier/v1 - ~/AppData/Local/Coursier/Cache/v1 - ~/Library/Caches/Coursier/v1 - key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - - name: Download target directories (3.4.2, rootJS) - uses: actions/download-artifact@v2 + - name: Download target directories (3, rootJS) + uses: actions/download-artifact@v4 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-3.4.2-rootJS + name: target-${{ matrix.os }}-${{ matrix.java }}-3-rootJS - - name: Inflate target directories (3.4.2, rootJS) + - name: Inflate target directories (3, rootJS) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (3.4.2, root) - uses: actions/download-artifact@v2 + - name: Download target directories (3, root) + uses: actions/download-artifact@v4 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-3.4.2-root + name: target-${{ matrix.os }}-${{ matrix.java }}-3-root - - name: Inflate target directories (3.4.2, root) + - name: Inflate target directories (3, root) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (3.4.2, rootNative) - uses: actions/download-artifact@v2 + - name: Download target directories (3, rootNative) + uses: actions/download-artifact@v4 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-3.4.2-rootNative + name: target-${{ matrix.os }}-${{ matrix.java }}-3-rootNative - - name: Inflate target directories (3.4.2, rootNative) + - name: Inflate target directories (3, rootNative) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.12.19, rootJS) - uses: actions/download-artifact@v2 + - name: Download target directories (2.12, rootJS) + uses: actions/download-artifact@v4 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.19-rootJS + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12-rootJS - - name: Inflate target directories (2.12.19, rootJS) + - name: Inflate target directories (2.12, rootJS) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.12.19, root) - uses: actions/download-artifact@v2 + - name: Download target directories (2.12, root) + uses: actions/download-artifact@v4 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.19-root + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12-root - - name: Inflate target directories (2.12.19, root) + - name: Inflate target directories (2.12, root) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.12.19, rootNative) - uses: actions/download-artifact@v2 + - name: Download target directories (2.12, rootNative) + uses: actions/download-artifact@v4 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.19-rootNative + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12-rootNative - - name: Inflate target directories (2.12.19, rootNative) + - name: Inflate target directories (2.12, rootNative) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.13.14, rootJS) - uses: actions/download-artifact@v2 + - name: Download target directories (2.13, rootJS) + uses: actions/download-artifact@v4 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.14-rootJS + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13-rootJS - - name: Inflate target directories (2.13.14, rootJS) + - name: Inflate target directories (2.13, rootJS) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.13.14, root) - uses: actions/download-artifact@v2 + - name: Download target directories (2.13, root) + uses: actions/download-artifact@v4 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.14-root + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13-root - - name: Inflate target directories (2.13.14, root) + - name: Inflate target directories (2.13, root) run: | tar xf targets.tar rm targets.tar - - name: Download target directories (2.13.14, rootNative) - uses: actions/download-artifact@v2 + - name: Download target directories (2.13, rootNative) + uses: actions/download-artifact@v4 with: - name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.14-rootNative + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13-rootNative - - name: Inflate target directories (2.13.14, rootNative) + - name: Inflate target directories (2.13, rootNative) run: | tar xf targets.tar rm targets.tar diff --git a/.sbtopts b/.sbtopts new file mode 100644 index 0000000..224cb18 --- /dev/null +++ b/.sbtopts @@ -0,0 +1,3 @@ +-J-Xms2g +-J-Xmx4g +-J-XX:MaxMetaspaceSize=512m diff --git a/build.sbt b/build.sbt index 5161dce..78eaf14 100644 --- a/build.sbt +++ b/build.sbt @@ -6,7 +6,7 @@ ThisBuild / scalacOptions ++= scalaOptions(scalaVersion.value) ThisBuild / libraryDependencies ++= Seq( "co.fs2" %% "fs2-core" % "3.10.2", - "org.scalameta" %% "munit" % "0.7.29" % Test, + "org.scalameta" %% "munit" % "1.0.0" % Test, "org.typelevel" %% "cats-effect-testkit" % "3.5.4" % Test ) diff --git a/src/test/scala/dev/kovstas/fs2throttler/MemoryLeakSpec.scala b/src/test/scala/dev/kovstas/fs2throttler/MemoryLeakSpec.scala index 4fa7ce0..9050790 100644 --- a/src/test/scala/dev/kovstas/fs2throttler/MemoryLeakSpec.scala +++ b/src/test/scala/dev/kovstas/fs2throttler/MemoryLeakSpec.scala @@ -36,9 +36,9 @@ class MemoryLeakSpec extends FunSuite { override def munitFlakyOK = true case class LeakTestParams( - warmupIterations: Int = 5, - samplePeriod: FiniteDuration = 3.seconds, - monitorPeriod: FiniteDuration = 60.seconds, + warmupIterations: Int = 3, + samplePeriod: FiniteDuration = 1.seconds, + monitorPeriod: FiniteDuration = 20.seconds, limitTotalBytesIncreasePerSecond: Long = 700000, limitConsecutiveIncreases: Int = 10 ) @@ -139,14 +139,14 @@ class MemoryLeakSpec extends FunSuite { Stream .range(0, 1000000) .covary[IO] - .through(Throttler.throttle(100, 100.millis, Enforcing)) + .through(Throttler.throttle(100, 10.millis, Enforcing)) } leakTest("Throttler.throttle shaping") { Stream .range(0, 1000000) .covary[IO] - .through(Throttler.throttle(100, 100.millis, Shaping)) + .through(Throttler.throttle(100, 10.millis, Shaping)) } }