Skip to content

Commit

Permalink
Merge pull request #221 from i10416/tidy/minor-cleanup
Browse files Browse the repository at this point in the history
tidy: minor cleanup
  • Loading branch information
markehammons authored Feb 29, 2024
2 parents af26b6d + e0b4b77 commit 022e79a
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 81 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: SLinC CI
on:
pull_request:
push:
push:
branches:
- "master"


jobs:
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
- uses: coursier/cache-action@v6
- uses: coursier/[email protected]
with:
Expand All @@ -25,61 +25,61 @@ jobs:
- run: mkdir reports
- name: Core tests
run: sbt coverage test

- run: |
sbt coverageReport
mkdir -p reports
cp target/scala-3.3.1/scoverage-report/scoverage.xml reports/scoverage.xml
# - run: |
# ./mill core.scoverage.xmlReport
# cp out/core/scoverage/xmlReport.dest/scoverage.xml reports/core-coverage.xml
# env:
# env:
# JAVA_HOME: ${{ env.JAVA_HOME_17_X64}}



# - name: Java 17 Implementation test
# run: |
# ./mill j17.compile
# ./mill j17.test
# env:
# env:
# JAVA_HOME: ${{ env.JAVA_HOME_17_X64}}

# - run: |
# ./mill j17.scoverage.xmlReport
# cp out/j17/scoverage/xmlReport.dest/scoverage.xml reports/java17-coverage.xml

# env:
# env:
# JAVA_HOME: ${{ env.JAVA_HOME_17_X64}}

# - name: Java 19 Implementation test
# run: |
# ./mill j19.compile
# ./mill j19.test
# ./mill j19.test

# - run: |
# ./mill j19.scoverage.xmlReport
# ./mill j19.scoverage.xmlReport
# cp out/j19/scoverage/xmlReport.dest/scoverage.xml reports/java19-coverage.xml

# - name: Runtime 17 implementation tests
# run: ./mill runtime.test
# env:
# - name: Runtime 17 implementation tests
# run: ./mill runtime.test
# env:
# JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }}

# - run: |
# ./mill runtime.scoverage.xmlReport
# ./mill runtime.scoverage.xmlReport
# cp out/runtime/scoverage/xmlReport.dest/scoverage.xml reports/java-17-runtime-coverage.xml

# env:
# env:
# JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }}
# - name: Runtime 19 implementation tests

# - name: Runtime 19 implementation tests
# run: ./mill runtime.test
# - run: |
# ./mill runtime.scoverage.xmlReport
# cp out/runtime/scoverage/xmlReport.dest/scoverage.xml reports/java-19-runtime-coverage.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v3
with:
directory: reports
directory: reports
28 changes: 14 additions & 14 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Publish Docs
on:
on:
workflow_dispatch

jobs:
build:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
with:
lfs: true
- uses: coursier/cache-action@v6
- uses: coursier/cache-action@v6
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
Expand All @@ -18,20 +18,20 @@ jobs:
run: sbt doc
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
with:
path: target/scala-3.3.1/api
deploy:
needs: build
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
steps:
steps:
- uses: actions/checkout@v3
- uses: coursier/cache-action@v6
- name: Get Secrets
Expand All @@ -18,10 +18,10 @@ jobs:
e5a2f416-de5c-4f2d-bc09-b060011d760b > SONATYPE_PASSWORD
44adbbc1-df7f-432f-8034-b060011d5d94 > SONATYPE_USERNAME
88fba8d9-e11a-4d8c-bfbd-b06001410130 > PGP_PASSPHRASE
- name: Get JVMs
- name: Get JVMs
uses: actions/setup-java@v4
with:
with:
distribution: 'temurin'
java-version: 17
cache: sbt
- run: sbt ci-release
- run: sbt ci-release
42 changes: 21 additions & 21 deletions docs/_docs/contributing/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ The code in this repository is primarily divided into four top-level directories
* `j17/`: Java 17 specific parts of the Slinc implementation
* `j19/`: Java 19 specific parts of the Slinc implementation
* `runtime/`: The complete Slinc project, with Java 17 and 19 implementations combined and the correct implementation chosen at runtime by your system.

## Developing Slinc
Slinc is a somewhat involved project to program for. With implementations targeting Java 17 and Java 19, one needs access to both JDKs to develop and run the j17 and j19 projects.
Slinc is a somewhat involved project to program for. With implementations targeting Java 17 and Java 19, one needs access to both JDKs to develop and run the j17 and j19 projects.

### Sdkman

Expand All @@ -19,7 +19,7 @@ Once you have sdkman installed, you can use the following commands to install an
* Install: `sdk i java 19-tem`
* Use: `sdk u java 19-tem`
* Default: `sdk d java 19-tem`

#### Java 17
* Install: `sdk i java 17.0.4.1-tem`
* Use: `sdk u java 17.0.4.1-tem`
Expand All @@ -29,25 +29,25 @@ Once you have sdkman installed, you can use the following commands to install an

`Use` will set the JDK visible for a certain terminal instance. This is useful if you want to build the entire project. Use will only effect the JDK choice for the terminal it's invoked in, and will not affect the user default JVM.

`Default` will set the JDK that's visible for all programs launched after the command has been invoked. This is useful for reloading your code editor to work on a different java implementation for Slinc.
`Default` will set the JDK that's visible for all programs launched after the command has been invoked. This is useful for reloading your code editor to work on a different java implementation for Slinc.

### Editor
When developing Slinc, it's suggested to use [VSCode](https://code.visualstudio.com/) along with the [Metals](https://marketplace.visualstudio.com/items?itemName=scalameta.metals) extension. Slinc is heavily dependent on compile-time programming, and VSCode+Metals works very well with this development model. One can use other editors, but it's probably mandatory to use Metals.
When developing Slinc, it's suggested to use [VSCode](https://code.visualstudio.com/) along with the [Metals](https://marketplace.visualstudio.com/items?itemName=scalameta.metals) extension. Slinc is heavily dependent on compile-time programming, and VSCode+Metals works very well with this development model. One can use other editors, but it's probably mandatory to use Metals.

Using metals, one can import the build definition from mill. If one encounters an issue with the import failing for no discernable reason, try deleting the `out` directory and trying again. There is a problem with this project and mill failing to generate bloop configurations. If one encounters errors when viewing a code base that do not resolve themselves, it's suggested to try closing VSCode, killing all Java processes, and deleting .metals, .bloop, and out. Generally, this will fix all issues.
Using metals, one can import the build definition from mill. If one encounters an issue with the import failing for no discernable reason, try deleting the `out` directory and trying again. There is a problem with this project and mill failing to generate bloop configurations. If one encounters errors when viewing a code base that do not resolve themselves, it's suggested to try closing VSCode, killing all Java processes, and deleting .metals, .bloop, and out. Generally, this will fix all issues.

When developing for Slinc, choose an implementation to focus on, and choose the appropriate JDK for it. Switch with the appropriate `default` command on sdkman, kill all java processes, and afterwards open the project with VSCode. The corresponding `j` project should be having no missing definition errors after this process. Switching between JDK versions follows the same process.
When developing for Slinc, choose an implementation to focus on, and choose the appropriate JDK for it. Switch with the appropriate `default` command on sdkman, kill all java processes, and afterwards open the project with VSCode. The corresponding `j` project should be having no missing definition errors after this process. Switching between JDK versions follows the same process.

## Compiling
## Compiling

The following commands compile the Slinc projecs:
The following commands compile the Slinc projects:

* core: `./mill core.compile`
* j17: `./mill j17.compile`
* j19: `./mill j19.compile`
* runtime: `./mill runtime.compile`

Compiling the entire project would normally be done by running `./mill _.compile`, but considering the different project have different JDK requirements, the full compilation takes the form of
Compiling the entire project would normally be done by running `./mill _.compile`, but considering the different project have different JDK requirements, the full compilation takes the form of

```bash
sdk u java 17.0.4.1-tem && \
Expand Down Expand Up @@ -78,7 +78,7 @@ Testing code is generally stored in the `core` project under `core/test/src`. Ja
Tests in Slinc use munit and scalacheck. One can read how to use munit with scalacheck [here](https://scalameta.org/munit/docs/integrations/scalacheck.html) and how to use scalacheck [here](https://github.com/typelevel/scalacheck/blob/main/doc/UserGuide.md).


In order to develop a new test suite for Slinc, add the implementation to `core/test/src`. If the test suite is testing an implementation in `core` then one can define it in the normal way specified by the munit documentation. However, if it's meant to be a test of Slinc implementations, it should be defined in a generic fashion like so:
In order to develop a new test suite for Slinc, add the implementation to `core/test/src`. If the test suite is testing an implementation in `core` then one can define it in the normal way specified by the munit documentation. However, if it's meant to be a test of Slinc implementations, it should be defined in a generic fashion like so:

```scala
package fr.hammons.slinc
Expand All @@ -87,7 +87,7 @@ import munit.ScalaCheckSuite

trait MyTestSuite(slinc: Slinc) extends ScalaCheckSuite:
import slinc.{*,given}
test("myTest") {
test("myTest") {
assertEquals(4,4)
}
```
Expand All @@ -104,9 +104,9 @@ If one's test suite concerns JIT compilation, one can use `noJit` and `immediate

### Troubleshooting tests

Sometimes when running a freshly written test, or testing freshly written code, one might encounter a situation where the test suite will stop testing early, or never stop running.
Sometimes when running a freshly written test, or testing freshly written code, one might encounter a situation where the test suite will stop testing early, or never stop running.

Generally, the test suite will stop running early when some part of the Slinc runtime fails to initialize properly. One can easily detect if this is the case by moving some test code out of the test section into the root of the suite.
Generally, the test suite will stop running early when some part of the Slinc runtime fails to initialize properly. One can easily detect if this is the case by moving some test code out of the test section into the root of the suite.

Observe the following example:

Expand All @@ -125,7 +125,7 @@ trait MySuite(s: Slinc) extends ScalacheckSuite:
import s.{*,given}
sizeOf[Int]
4.as[SizeT]

test("myTest") {
assertEquals(sizeOf[Int], 4.as[SizeT])
}
Expand All @@ -141,18 +141,18 @@ trait MySuite(s: Slinc) extends ScalacheckSuite:

property("myProperty") {
forAll{
(i: Int) =>
(i: Int) =>
Scope.confined{
val ptr = Ptr.blank[CInt]

!ptr = i
!ptr = i
assertEquals(!ptr, i)
}
}
}
```

should be changed to
should be changed to

```scala
trait MySuite(s: Slinc) extends ScalacheckSuite:
Expand All @@ -164,13 +164,13 @@ trait MySuite(s: Slinc) extends ScalacheckSuite:

property("myProperty") {
forAll{
(i: Int) =>
(i: Int) =>
Scope.confined{
val ptr = Ptr.blank[CInt]

!ptr = i
!ptr = i
assertEquals(!ptr, i)
}
}
}
```
```
Loading

0 comments on commit 022e79a

Please sign in to comment.