Skip to content

Commit e3a5732

Browse files
CopilotQuafadas
andauthored
Implement laws-based testing framework for vector operations (#57)
* Initial plan * Add laws module with core infrastructure and initial tests Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com> * Fix test Eq instance and verify JVM laws tests pass Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com> * Add comprehensive documentation for laws module Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com> * Address code review feedback: extract constants and givens Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com> * Use vecxt extension methods in laws and add laws tests to CI Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com> * Fix CI: only run laws tests on JVM platform Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com> * Add multiplicative laws * . * . * . * . * . * . * . * Re-enable cross-platform laws tests with fixed multiplication implementation Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com> * fmt * . * . * . * . * . * . --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com> Co-authored-by: Simon Parten <Quafadas@users.noreply.github.com> Co-authored-by: Simon Parten <quafadas@gmail.com>
1 parent ccb6605 commit e3a5732

36 files changed

Lines changed: 952 additions & 171 deletions

.devcontainer/devcontainer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
"ghcr.io/devcontainers/features/java:1": {
2323
"version": 24
2424
},
25-
"ghcr.io/devcontainers/features/node:1": {},
25+
"ghcr.io/devcontainers/features/node:1": {},
2626
"ghcr.io/guiyomh/features/just:0" :{}
2727
},
28-
// Attemps to install blas so that native works.
29-
"postCreateCommand": "chmod +x millw & npm install && sudo apt update & wait; sudo apt-get install -y libatlas-base-dev clang & wait; ./millw __.compiledClassesAndSemanticDbFiles"
28+
// Attemps to install blas so that native works.
29+
"postCreateCommand": "chmod +x mill & npm install && sudo apt update & wait; sudo apt-get install -y libatlas-base-dev clang & wait; ./mill __.compiledClassesAndSemanticDbFiles"
3030
// Configure tool-specific properties.
3131
// "customizations": {},
3232
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.

.gitattributes

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Set default line ending behavior to auto-normalize
2+
* text=auto
3+
4+
# Explicitly declare text files you want to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.scala text
7+
*.sc text
8+
*.sbt text
9+
*.conf text
10+
*.md text
11+
*.yml text
12+
*.yaml text
13+
*.json text
14+
*.xml text
15+
*.properties text
16+
17+
# Declare files that will always have LF line endings on checkout.
18+
*.sh text eol=lf
19+
20+
# Denote all files that are truly binary and should not be modified.
21+
*.jar binary
22+
*.png binary
23+
*.jpg binary
24+
*.gif binary
25+
*.xlsx binary

.github/copilot-instructions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ Answer all questions in the style of a friendly colleague that is an expert in l
1010

1111
## Working Effectively
1212

13-
Mill may be found via it's wrapper script `./millw` in the root of the repository. For example `./millw vecxt.__.compile` will compile the JVM, JS and native targets.
13+
Mill may be found via it's wrapper script `./mill` in the root of the repository. For example `./mill vecxt.__.compile` will compile the JVM, JS and native targets.
1414

1515
Each module contains it's own build definition in the package.mill file in it's module directory.
1616

1717
- BUILDS: Mill cold compilation takes 2 minutes or so. Stay patient!
18-
- Compile specific platforms (e.g. jvm) with `./millw vecxt.jvm.compile` or `./millw vecxt.js.compile` etc.
19-
- Run all tests by following with the same pattern `./millw vecxt.__.test`
20-
- Format code with `./millw mill.scalalib.scalafmt.ScalafmtModule/`. CI will enforce formatting, and will fail if code is not formatted.
21-
- If you see an error like this is JS `[error] @scala.scalajs.js.annotation.internal.JSType is for compiler internal use only. Do not use it yourself.`, run `./millw clean vecxt.js._` to clear the build cache.
22-
- To run a specific main class, use the runMain command and specify the package. `./millw experiments.runMain testCheatsheet` for example.
18+
- Compile specific platforms (e.g. jvm) with `./mill vecxt.jvm.compile` or `./mill vecxt.js.compile` etc.
19+
- Run all tests by following with the same pattern `./mill vecxt.__.test`
20+
- Format code with `./mill mill.scalalib.scalafmt.ScalafmtModule/`. CI will enforce formatting, and will fail if code is not formatted.
21+
- If you see an error like this is JS `[error] @scala.scalajs.js.annotation.internal.JSType is for compiler internal use only. Do not use it yourself.`, run `./mill clean vecxt.js._` to clear the build cache.
22+
- To run a specific main class, use the runMain command and specify the package. `./mill experiments.runMain testCheatsheet` for example.
2323

2424
## Folder structure
2525

@@ -29,7 +29,7 @@ vecxt/
2929
├── .devcontainer/ # VS Code dev container configuration
3030
├── .vscode/ # VS Code workspace settings
3131
├── build.mill # Mill build configuration (main build file)
32-
├── millw # Mill wrapper script for cross-platform builds
32+
├── mill # Mill wrapper script for cross-platform builds
3333
├── styleguide.md # Coding style guidelines
3434
├── benchmarks/ # Benchmarking code - not published, may be run in CI on request
3535
├── experiments/ # Not published, inlined experiments - use this as a sandbox

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
jvm: temurin@17
1818
# Run benchmark with `go test -bench` and stores the output to a file
1919
- name: Run benchmark
20-
run: ./millw benchmark.runJmh -jvmArgs --add-modules=jdk.incubator.vector -rf json
20+
run: ./mill benchmark.runJmh -jvmArgs --add-modules=jdk.incubator.vector -rf json
2121

2222
- name: Set variables
2323
run: |

.github/workflows/ci.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
# This file was automatically generated by sbt-github-actions using the
2-
# githubWorkflowGenerate task. You should add and commit this file to
3-
# your git repository. It goes without saying that you shouldn't edit
4-
# this file by hand! Instead, if you wish to make changes, you should
5-
# change your sbt build configuration to revise the workflow description
6-
# to meet your needs, then regenerate this file.
7-
81
name: Continuous Integration
9-
102
on:
113
pull_request:
124
branches: ['**', '!update/**', '!pr/**']
@@ -16,6 +8,7 @@ on:
168

179
env:
1810
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11+
FORCE_COLOR: '1'
1912

2013

2114
concurrency:
@@ -52,7 +45,7 @@ jobs:
5245
cache: npm
5346

5447
- name: formatCheck
55-
run: ./millw mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
48+
run: ./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
5649

5750
- if: matrix.project == 'js'
5851
run: npm install
@@ -62,16 +55,33 @@ jobs:
6255

6356
- name: scalaJSLink
6457
if: matrix.project == 'js'
65-
run: ./millw vecxt.${{ matrix.project }}.fastLinkJS
58+
run: ./mill vecxt.${{ matrix.project }}.fastLinkJS
6659

6760
- name: nativeLink
6861
if: matrix.project == 'native'
69-
run: ./millw vecxt.${{ matrix.project }}.test.nativeLink
62+
run: ./mill vecxt.${{ matrix.project }}.test.nativeLink
7063

7164
- name: Test
72-
run: ./millw vecxt.${{ matrix.project }}.test
65+
run: ./mill vecxt.${{ matrix.project }}.test
66+
67+
- name: Laws Test
68+
if: matrix.project == 'jvm'
69+
run: ./mill laws.${{ matrix.project }}.test
70+
7371
- name: Doc Gen
74-
run: ./millw site.siteGen
72+
if: matrix.project == 'jvm'
73+
run: ./mill site.siteGen
74+
75+
- name: Publish Test Report
76+
uses: mikepenz/action-junit-report@v5
77+
if: always()
78+
with:
79+
fail_on_failure: false
80+
include_passed: false
81+
detailed_summary: true
82+
annotate_only: true
83+
require_tests: false
84+
report_paths: 'out/**/test-report.xml'
7585

7686
publish:
7787
if: github.repository == 'Quafadas/vecxt' && contains(github.ref, 'refs/tags/')
@@ -89,7 +99,7 @@ jobs:
8999
apps: scala-cli
90100

91101
- name: Publish to Maven Central
92-
run: ./millw mill.javalib.SonatypeCentralPublishModule/
102+
run: ./mill mill.javalib.SonatypeCentralPublishModule/
93103
env:
94104
MILL_PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
95105
MILL_PGP_SECRET_BASE64: ${{ secrets.PGP_SECRET }}
@@ -133,7 +143,7 @@ jobs:
133143
run: mkdir -p site/docs/_assets/benchmarks && cp benchmark_history.json site/docs/_assets/benchmarks/benchmark_history.json
134144

135145
- name: Generate static site
136-
run: ./millw site.siteGen
146+
run: ./mill site.siteGen
137147

138148
- name: Setup Pages
139149
uses: actions/configure-pages@main

.github/workflows/copilot-setup-steps.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ name: "Copilot Setup Steps"
55
on:
66
workflow_dispatch:
77
push:
8+
branches:
9+
- main
810
paths:
911
- .github/workflows/copilot-setup-steps.yml
1012
pull_request:
@@ -28,7 +30,7 @@ jobs:
2830
- name: Checkout code
2931
uses: actions/checkout@v5
3032

31-
- name: Setup NodeJS v18 LTS
33+
- name: Setup NodeJS v18 LTS
3234
uses: actions/setup-node@v3
3335
with:
3436
node-version: 20
@@ -44,8 +46,8 @@ jobs:
4446
java-version: '21'
4547

4648
- name: Verify Java version
47-
run: java --version
49+
run: java --version
4850

4951
# This should resolve a JVM, download dependancies and leave mill ready for use.
5052
- name: setup mill
51-
run: ./millw vecxt.__.compiledClassesAndSemanticDbFiles
53+
run: ./mill vecxt.__.compiledClassesAndSemanticDbFiles

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "3.9.9"
1+
version = "3.10.3"
22
project.git = true
33
runner.dialect = scala3
44
rewrite.scala3.convertToNewSyntax = true

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"label": "compiledClassesAndSemanticDbFiles",
66
"type": "shell",
7-
"command": "./millw __.compiledClassesAndSemanticDbFiles",
7+
"command": "./mill __.compiledClassesAndSemanticDbFiles",
88
"runOptions": {
99
"runOn": "folderOpen"
1010
},

benchmark/package.mill

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
package build.benchmark
22

3-
import mill._, scalalib._, publish._
3+
import mill.*, scalalib.*, publish.*
44
import contrib.jmh.JmhModule
55

66
// mill benchmark.runJmh vecxt.benchmark.AndBooleanBenchmark -jvmArgs --add-modules=jdk.incubator.vector -rf json
77

8-
object `package` extends JmhModule with ScalaModule {
9-
def scalaVersion = build.vecxt.jvm.scalaVersion
10-
def jmhCoreVersion = "1.37"
11-
override def forkArgs: T[Seq[String]] = super.forkArgs() ++ build.vecIncubatorFlag
12-
override def moduleDeps: Seq[JavaModule] = Seq(build.vecxt.jvm)
13-
def enableBsp = false
14-
15-
// override def generateBenchmarkSources = T{
16-
// val dest = T.ctx().dest
17-
18-
// val forkedArgs = forkArgs().toSeq
19-
20-
// val sourcesDir = dest / "jmh_sources"
21-
// val resourcesDir = dest / "jmh_resources"
22-
23-
// os.remove.all(sourcesDir)
24-
// os.makeDir.all(sourcesDir)
25-
// os.remove.all(resourcesDir)
26-
// os.makeDir.all(resourcesDir)
27-
28-
// Jvm.runSubprocess(
29-
// "org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator",
30-
// (runClasspath() ++ generatorDeps()).map(_.path),
31-
// mainArgs = Seq(
32-
// compile().classes.path.toString,
33-
// sourcesDir.toString,
34-
// resourcesDir.toString,
35-
// "default"
36-
// ),
37-
// jvmArgs = forkedArgs
38-
// )
39-
40-
41-
// (sourcesDir, resourcesDir)
42-
// }
43-
}
8+
object `package` extends JmhModule with ScalaModule:
9+
def scalaVersion = build.vecxt.jvm.scalaVersion
10+
def jmhCoreVersion = "1.37"
11+
override def forkArgs: T[Seq[String]] = super.forkArgs() ++ build.vecIncubatorFlag
12+
override def moduleDeps: Seq[JavaModule] = Seq(build.vecxt.jvm)
13+
def enableBsp = false
14+
15+
// override def generateBenchmarkSources = T{
16+
// val dest = T.ctx().dest
17+
18+
// val forkedArgs = forkArgs().toSeq
19+
20+
// val sourcesDir = dest / "jmh_sources"
21+
// val resourcesDir = dest / "jmh_resources"
22+
23+
// os.remove.all(sourcesDir)
24+
// os.makeDir.all(sourcesDir)
25+
// os.remove.all(resourcesDir)
26+
// os.makeDir.all(resourcesDir)
27+
28+
// Jvm.runSubprocess(
29+
// "org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator",
30+
// (runClasspath() ++ generatorDeps()).map(_.path),
31+
// mainArgs = Seq(
32+
// compile().classes.path.toString,
33+
// sourcesDir.toString,
34+
// resourcesDir.toString,
35+
// "default"
36+
// ),
37+
// jvmArgs = forkedArgs
38+
// )
39+
40+
// (sourcesDir, resourcesDir)
41+
// }
42+
end `package`

benchmark_vs_breeze/package.mill

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package build.benchmark_vs_breeze
22

3-
import mill._, scalalib._, publish._
3+
import mill.*, scalalib.*, publish.*
44
import contrib.jmh.JmhModule
55

66
// mill benchmark.runJmh vecxt.benchmark.AndBooleanBenchmark -jvmArgs --add-modules=jdk.incubator.vector -rf json
77

8-
object `package` extends JmhModule with ScalaModule {
9-
def scalaVersion = build.vecxt.jvm.scalaVersion
10-
def jmhCoreVersion = "1.37"
11-
def enableBsp = false
12-
override def forkArgs: T[Seq[String]] = super.forkArgs() ++ build.vecIncubatorFlag
13-
override def moduleDeps: Seq[JavaModule] = Seq(build.vecxt.jvm)
14-
override def mvnDeps = super.mvnDeps() ++ Seq(
15-
mvn"org.scalanlp::breeze:2.1.0"
16-
)
17-
18-
}
8+
object `package` extends JmhModule with ScalaModule:
9+
def scalaVersion = build.vecxt.jvm.scalaVersion
10+
def jmhCoreVersion = "1.37"
11+
def enableBsp = false
12+
override def forkArgs: T[Seq[String]] = super.forkArgs() ++ build.vecIncubatorFlag
13+
override def moduleDeps: Seq[JavaModule] = Seq(build.vecxt.jvm)
14+
override def mvnDeps = super.mvnDeps() ++ Seq(
15+
mvn"org.scalanlp::breeze:2.1.0"
16+
)
17+
end `package`

0 commit comments

Comments
 (0)