Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bazel-flake #57

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 70 additions & 2 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
description = "Bazel rules_scala flake";
description = "Bazel rules_scala3 flake";

inputs = {
nixpkgs.url = "nixpkgs/release-24.05";
flake-utils.url = "github:numtide/flake-utils";
bazel.url = "git+ssh://[email protected]/timothyklim/bazel-flake.git";
};

outputs = { self, nixpkgs, flake-utils }:
outputs = { self, nixpkgs, flake-utils, bazel }:
with flake-utils.lib; with system; eachSystem [ aarch64-darwin aarch64-linux x86_64-linux ] (system:
let
pkgs = import nixpkgs {
Expand All @@ -20,7 +21,7 @@
};
in
rec {
devShell = pkgs.callPackage ./shell.nix { };
devShell = pkgs.callPackage ./shell.nix { bazel = bazel.packages.${system}.default; };
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
});
}
4 changes: 2 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs }:
{ pkgs, bazel }:

with pkgs;

Expand All @@ -8,6 +8,6 @@ in
mkShell {
name = "rules_scala-env";
nativeBuildInputs = [ jdk ];
buildInputs = [ bash bazel_7 bazel-buildtools python3 just fd ripgrep gnused nixpkgs-fmt ];
buildInputs = [ bash bazel bazel-buildtools python3 just fd ripgrep gnused nixpkgs-fmt ];
LOCALE_ARCHIVE = lib.optionals stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
}
20 changes: 14 additions & 6 deletions tests/jmh/ArrayBench.scala
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
package test

import java.util.concurrent.TimeUnit.*

import org.openjdk.jmh.annotations.*

@State(Scope.Benchmark)
class ArrayState:
val array = (1 to 100).toArray

val array: Array[Int] = (1 to 100).toArray
val h = 123

class ArrayBench:
@Benchmark
@BenchmarkMode(Array(Mode.SingleShotTime, Mode.Throughput))
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(MILLISECONDS)
@Warmup(iterations = 2, time = 100, timeUnit = MILLISECONDS)
@Measurement(iterations = 2, time = 100, timeUnit = MILLISECONDS)
@Fork(2)
def testFold(state: ArrayState): Unit =
val builder = Vector.newBuilder[Int]
state.array.foldLeft(builder)(_ += _)
()

@Benchmark
@BenchmarkMode(Array(Mode.SingleShotTime, Mode.Throughput))
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(MILLISECONDS)
@Warmup(iterations = 2, time = 100, timeUnit = MILLISECONDS)
@Measurement(iterations = 2, time = 100, timeUnit = MILLISECONDS)
@Fork(2)
def testArray(state: ArrayState): Unit =
val builder = Vector.newBuilder[Int]
var _i = 0
Expand All @@ -30,8 +35,11 @@ class ArrayBench:
()

@Benchmark
@BenchmarkMode(Array(Mode.SingleShotTime, Mode.Throughput))
@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(MILLISECONDS)
@Warmup(iterations = 2, time = 100, timeUnit = MILLISECONDS)
@Measurement(iterations = 2, time = 100, timeUnit = MILLISECONDS)
@Fork(2)
def testForeach(state: ArrayState): Unit =
val builder = Vector.newBuilder[Int]
state.array.foreach(builder += _)
Expand Down
5 changes: 4 additions & 1 deletion tests/jmh/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env -S bash -e
. "$(dirname "$0")"/../common.sh

bazel run :jmh
bazel run :jmh -- \
-wi 2 -i 2 -f 2 \
-bm thrpt \
-tu ms
2 changes: 1 addition & 1 deletion tests/providers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ configure_bootstrap_scala(

declare_zinc_configuration(
name = "provided_zinc_configuration",
compiler_bridge = ":compiler_bridge",
compiler_bridge = "@scala3_sbt_bridge//jar",
)

join_configurations(
Expand Down
7 changes: 0 additions & 7 deletions tests/scaladoc/A.scala

This file was deleted.

1 change: 0 additions & 1 deletion tests/scaladoc/B.scala

This file was deleted.

16 changes: 0 additions & 16 deletions tests/scaladoc/BUILD

This file was deleted.

5 changes: 0 additions & 5 deletions tests/scaladoc/test

This file was deleted.

1 change: 0 additions & 1 deletion tests/test-frameworks/mixed/junit.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package annex.scalacheck

import org.junit.Test
import org.junit.Assert.*

class JUnitTests:

Expand Down
4 changes: 2 additions & 2 deletions tests/test-frameworks/mixed/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
. "$(dirname "$0")"/../../common.sh

out=$(bazel test :mixed)
echo "$out" | grep 'should pop values in last-in-first-out order'
echo "$out" | grep 'JUnit many success'
echo "$out" | grep 'Dummy.foo: OK, proved property.'
echo "$out" | grep 'Dummy.bar: OK, proved property.'
Loading