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

Rebootstrap to pull in os-lib 0.11.0 #3686

Merged
merged 1 commit into from
Oct 8, 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
2 changes: 1 addition & 1 deletion .config/mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.0-RC3
0.12.0-RC3-17-b4d4fe
19 changes: 6 additions & 13 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,9 @@ trait BridgeModule extends MillPublishJavaModule with CrossScalaModule {
}

def generatedSources = Task {

compilerBridgeSourceJars().foreach { jar =>
mill.api.IO.unpackZip(jar.path, os.rel)
os.unzip(jar.path, T.dest)
}

Seq(PathRef(T.dest))
Expand Down Expand Up @@ -984,19 +985,11 @@ def uploadToGithub(authKey: String) = T.command {

if (releaseTag == label) {
// TODO: check if the tag already exists (e.g. because we created it manually) and do not fail
scalaj.http.Http(
s"https://api.github.com/repos/${Settings.githubOrg}/${Settings.githubRepo}/releases"
requests.post(
s"https://api.github.com/repos/${Settings.githubOrg}/${Settings.githubRepo}/releases",
data = ujson.Obj("tag_name" -> releaseTag, "name" -> releaseTag),
headers = Seq("Authorization" -> ("token " + authKey))
)
.postData(
ujson.write(
ujson.Obj(
"tag_name" -> releaseTag,
"name" -> releaseTag
)
)
)
.header("Authorization", "token " + authKey)
.asString
}

val examples = exampleZips().map(z => (z.path, z.path.last))
Expand Down
43 changes: 1 addition & 42 deletions ci/shared.mill
Original file line number Diff line number Diff line change
@@ -1,49 +1,8 @@
package build.ci

/**
* Utility code that is shared between our SBT build and our Mill build. SBT
* calls this by shelling out to Ammonite in a subprocess, while Mill loads it
* via import $file
*/

import $ivy.`org.scalaj::scalaj-http:2.4.2`
import mainargs.main

def unpackZip(zipDest: os.Path, url: String) = {
println(s"Unpacking zip $url into $zipDest")
os.makeDir.all(zipDest)

val bytes =
scalaj.http.Http.apply(url).option(scalaj.http.HttpOptions.followRedirects(true)).asBytes
val byteStream = new java.io.ByteArrayInputStream(bytes.body)
val zipStream = new java.util.zip.ZipInputStream(byteStream)
while ({
zipStream.getNextEntry match {
case null => false
case entry =>
if (!entry.isDirectory) {
val dest = zipDest / os.SubPath(entry.getName)
os.makeDir.all(dest / os.up)
val fileOut = new java.io.FileOutputStream(dest.toString)
val buffer = new Array[Byte](4096)
while ({
zipStream.read(buffer) match {
case -1 => false
case n =>
fileOut.write(buffer, 0, n)
true
}
}) ()
fileOut.close()
}
zipStream.closeEntry()
true
}
}) ()
}

@main
def downloadTestRepo(label: String, commit: String, dest: os.Path) = {
unpackZip(dest, s"https://github.com/$label/archive/$commit.zip")
os.unzip.stream(requests.get.stream(s"https://github.com/$label/archive/$commit.zip"), dest)
dest
}
41 changes: 20 additions & 21 deletions ci/upload.mill
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package build.ci
import scalaj.http._
import mainargs.main

@main
def apply(
uploadedFile: os.Path,
tagName: String,
Expand All @@ -12,34 +9,36 @@ def apply(
githubRepo: String
): String = {

val response = Http(
s"https://api.github.com/repos/${githubOrg}/${githubRepo}/releases/tags/${tagName}"
val response = requests.get(
s"https://api.github.com/repos/${githubOrg}/${githubRepo}/releases/tags/${tagName}",
headers = Seq(
"Authorization" -> s"token $authKey",
"Accept" -> "application/vnd.github.v3+json"
)
)
.header("Authorization", "token " + authKey)
.header("Accept", "application/vnd.github.v3+json")
.asString
val body = response.body

val parsed = ujson.read(body)
val parsed = ujson.read(response)

println("Response code: " + response.code)
println(body)
println("Response code: " + response.statusCode)
println(response.text())

val snapshotReleaseId = parsed("id").num.toInt

val uploadUrl =
s"https://uploads.github.com/repos/${githubOrg}/${githubRepo}/releases/" +
s"$snapshotReleaseId/assets?name=$uploadName"

val res = Http(uploadUrl)
.header("Content-Type", "application/octet-stream")
.header("Authorization", "token " + authKey)
.timeout(connTimeoutMs = 5000, readTimeoutMs = 60000)
.postData(os.read.bytes(uploadedFile))
.asString

println(res.body)
val longUrl = ujson.read(res.body)("browser_download_url").str
val res = requests.post(
uploadUrl,
headers = Seq(
"Content-Type" -> "application/octet-stream",
"Authorization" -> s"token $authKey"
),
data = os.read.stream(uploadedFile)
)

println(res.text())
val longUrl = ujson.read(res)("browser_download_url").str

println("Long Url " + longUrl)
longUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MainActivity : Activity() {
val textView = TextView(this)

// Set the text to "Hello, World!"
textView.text = "Hello, World!"
textView.text = "Hello, World Kotlin!"

// Set text size
textView.textSize = 32f
Expand Down
1 change: 0 additions & 1 deletion integration/invalidation/invalidation/resources/build.mill
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package build
import mill._
import $packages._
import $ivy.`org.scalaj::scalaj-http:2.4.2`

def task = Task {
build.a.input()
Expand Down
1 change: 0 additions & 1 deletion mill-build/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import mill.scalalib._

object `package` extends MillBuildRootModule {
override def ivyDeps = Agg(
ivy"org.scalaj::scalaj-http:2.4.2",
ivy"de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0",
ivy"com.github.lolgab::mill-mima::0.1.1",
ivy"net.sourceforge.htmlcleaner:htmlcleaner:2.29",
Expand Down
Loading