Skip to content

Commit

Permalink
Merge branch 'main' into lint-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
myyk authored Nov 7, 2024
2 parents d748022 + 1a5605a commit 7401239
Show file tree
Hide file tree
Showing 20 changed files with 924 additions and 76 deletions.
51 changes: 47 additions & 4 deletions .github/workflows/publish-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,34 @@ concurrency:
cancel-in-progress: true

jobs:
build-artifacts:
# when in master repo, publish all tags and manual runs on main
if: github.repository == 'com-lihaoyi/mill'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0}

- uses: coursier/cache-action@v6

- uses: actions/setup-java@v4
with:
java-version: '11'
distribution: temurin

- run: ./mill -i __.publishArtifacts

- uses: actions/upload-artifact@v4.4.3
with:
path: .
include-hidden-files: true
name: publish-artifacts

publish-sonatype:
# when in master repo, publish all tags and manual runs on main
if: github.repository == 'com-lihaoyi/mill'
needs: build-artifacts
runs-on: ubuntu-latest

# only run one publish job for the same sha at the same time
Expand All @@ -40,8 +65,17 @@ jobs:
LC_ALL: "en_US.UTF-8"

steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0}
- uses: actions/download-artifact@v4
with:
path: .
name: publish-artifacts

- run: ls -la .

# Need to fix cached artifact file permissions because github actions screws it up
# https://github.com/actions/upload-artifact/issues/38
# Best is, we restore any file to avoid any changes
- run: git reset --hard

- uses: coursier/cache-action@v6

Expand All @@ -62,8 +96,17 @@ jobs:
REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}

steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0}
- uses: actions/download-artifact@v4
with:
path: .
name: publish-artifacts

- run: ls -la .

# Need to fix cached artifact file permissions because github actions screws it up
# https://github.com/actions/upload-artifact/issues/38
# Best is, we restore any file to avoid any changes
- run: git reset --hard

- uses: coursier/cache-action@v6

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-mill-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:

- name: Run Mill '${{ inputs.millargs }}'
# Mill tests are pretty heavy so run them only 3x parallel on 4 core Github Actions runners
run: ./mill -i -j3 -k ${{ inputs.millargs }}
run: ./mill -i -j3 -k ${{ inputs.millargs }}
if: inputs.millargs != '' && !startsWith(inputs.os, 'windows')

- name: Run Mill (on Windows) '${{ inputs.millargs }}'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ jobs:
millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.testCached'"
- java-version: 17
millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.testCached'"
- java-version: '17'
millargs: "'example.thirdparty[arrow].local.testCached'"
- java-version: '11'
millargs: "'example.{depth,extending}.__.local.testCached'"

Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/scala-steward.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on:
schedule:
- cron: '0 0 * * *' # daily
workflow_dispatch:

name: Scala Steward

permissions:
contents: write
pull-requests: write

jobs:
scala-steward:
runs-on: ubuntu-latest

steps:
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- uses: scala-steward-org/scala-steward-action@v2.71.0
3 changes: 2 additions & 1 deletion example/package.mill
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ object `package` extends RootModule with Module {
"commons-io" -> ("apache/commons-io", "b91a48074231ef813bc9b91a815d77f6343ff8f0"),
"netty" -> ("netty/netty", "20a790ed362a3c11e0e990b58598e4ac6aa88bef"),
"mockito" -> ("mockito/mockito", "97f3574cc07fdf36f1f76ba7332ac57675e140b1"),
"gatling" -> ("gatling/gatling", "3870fda86e6bca005fbd53108c60a65db36279b6")
"gatling" -> ("gatling/gatling", "3870fda86e6bca005fbd53108c60a65db36279b6"),
"arrow" -> ("arrow-kt/arrow", "bc9bf92cc98e01c21bdd2bf8640cf7db0f97204a")
)
object thirdparty extends Cross[ThirdPartyModule](build.listIn(millSourcePath / "thirdparty"))
trait ThirdPartyModule extends ExampleCrossModule {
Expand Down
5 changes: 2 additions & 3 deletions example/scalalib/native/1-simple/src/Foo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import mainargs.{main, ParserForMethods}

object Foo {

def generateHtml(text: String): CString = {
def generateHtml(text: String) (using Zone) = {
val html = "<h1>" + text + "</h1>\n"

implicit val z: Zone = Zone.open()
val cResult = toCString(html)
cResult

}

@main
def main(text: String) = {
def main(text: String) = Zone {
stdio.printf(generateHtml(text))
}

Expand Down
3 changes: 1 addition & 2 deletions example/scalalib/native/3-multi-module/bar/src/Bar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import scala.scalanative.libc._
import scala.scalanative.unsafe._

object Bar {
def main(args: Array[String]): Unit = {
def main(args: Array[String]): Unit = Zone {
println("Running HelloWorld function")
implicit val z: Zone = Zone.open()
val result = toCString(args(0))
val barValue = HelloWorldBar.stringLength(result)
stdio.printf(c"Bar value: Argument length is %i\n", barValue)
Expand Down
7 changes: 2 additions & 5 deletions example/scalalib/native/3-multi-module/foo/src/Foo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ import mainargs.{main, ParserForMethods, arg}

object Foo {
@main
def main(
@arg(name = "foo-text") fooText: String,
@arg(name = "bar-text") barText: String
): Unit = {
def main(@arg(name = "foo-text") fooText: String,
@arg(name = "bar-text") barText: String): Unit = Zone {

implicit val z: Zone = Zone.open()
val cFooText = toCString(fooText)
val cBarText = toCString(barText)

Expand Down
2 changes: 1 addition & 1 deletion example/scalalib/native/4-common-config/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object `package` extends RootModule with ScalaNativeModule {

> ./mill run
...
Foo.value: <h1>hello</h1>
Value: <h1>hello</h1>

> ./mill show releaseMode
"mill.scalanativelib.api.ReleaseMode.ReleaseFast"
Expand Down
12 changes: 5 additions & 7 deletions example/scalalib/native/4-common-config/src/Foo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ import fansi._

object Foo {

def generateHtml(text: String): CString = {
def generateHtml(text: String) (using Zone) = {
val colored = Console.RED + "<h1>" + text + "</h1>" + Console.RESET

implicit val z: Zone = Zone.open()
val cResult = toCString(colored)
cResult
}

val value = generateHtml("hello")

def main(args: Array[String]): Unit = {
stdio.printf(c"Foo.value: %s\n", Foo.value)

def main(args: Array[String]): Unit = Zone {
val value = generateHtml("hello")
stdio.printf(c"Value: %s\n", value)
}
}
Loading

0 comments on commit 7401239

Please sign in to comment.