From 5c589f93872faab5d0e74465e5ad0c0de5c5a8b9 Mon Sep 17 00:00:00 2001 From: Lanqing Huang Date: Mon, 30 Dec 2024 03:48:17 +0000 Subject: [PATCH 01/10] chore: Upgrade build deps to ensure compatible with Scala Native --- .github/workflows/actions.yml | 4 +-- build.mill | 57 ++++++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 92e2682..4b6118f 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: ['11', '17'] + java: ['11', '17', '21'] steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 @@ -34,7 +34,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 11 + java-version: 17 - name: Check Binary Compatibility run: ./mill -i __.mimaReportBinaryIssues diff --git a/build.mill b/build.mill index b9c0612..0b6c477 100644 --- a/build.mill +++ b/build.mill @@ -1,29 +1,56 @@ package build + import mill._ +import mill.scalalib._ import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl} -import scalalib._ -import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0` -import $ivy.`com.github.lolgab::mill-mima::0.0.23` + +import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.1` +import $ivy.`com.github.lolgab::mill-mima::0.0.24` import de.tobiasroeser.mill.vcs.version.VcsVersion import com.github.lolgab.mill.mima._ val dottyVersion = sys.props.get("dottyVersion") +val scalaVersions = List("2.12.20", "2.13.15", "3.6.2") ++ dottyVersion -val scalaVersions = List("2.12.17", "2.13.10", "2.11.12", "3.1.1") ++ dottyVersion - -object requests extends Cross[RequestsModule](scalaVersions) -trait RequestsModule extends CrossScalaModule with PublishModule with Mima { - def publishVersion = VcsVersion.vcsState().format() - def mimaPreviousVersions = - ( - Seq("0.7.0", "0.7.1", "0.8.2") ++ - Option.when(VcsVersion.vcsState().commitsSinceLastTag != 0)(VcsVersion.vcsState().lastTag).flatten - ).distinct +trait RequestsJvmModule extends RequestsModule with Mima { + def mimaPreviousArtifacts = Agg( + ( + Seq("0.7.0", "0.7.1", "0.8.2") + ++ Option + .when(VcsVersion.vcsState().commitsSinceLastTag != 0)(VcsVersion.vcsState().lastTag) + .flatten + ).map(v => ivy"com.lihaoyi::requests:${v}") : _* + ) override def mimaBinaryIssueFilters = Seq( ProblemFilter.exclude[ReversedMissingMethodProblem]("requests.BaseSession.send"), ProblemFilter.exclude[DirectMissingMethodProblem]("requests.Response.string") ) +} +object requests extends Cross[RequestsJvmModule](scalaVersions) {} + +/** + * Placeholder for Scala Native module + */ +// object native extends Cross[RequestsNativeModule](scalaVersions) +// trait RequestsNativeModule extends RequestsModule with ScalaNativeModule { +// override def scalaNativeVersion = scalaNative +// override def nativeEmbedResources = true + +// def ivyDeps = +// super.ivyDeps() ++ Agg(ivy"com.github.lolgab::scala-native-crypto::0.1.0") +// def nativeLinkingOptions = Seq("-lmicrohttpd") + +// object test extends ScalaNativeTests with RequestsTestModule { +// def nativeLinkingOptions = +// super.nativeLinkingOptions() ++ Seq("-L/usr/local/opt/openssl@3/lib") +// } +// } + +trait RequestsModule extends CrossScalaModule + with PlatformScalaModule + with PublishModule { + def publishVersion = VcsVersion.vcsState().format() def pomSettings = PomSettings( description = "Scala port of the popular Python Requests HTTP client", @@ -32,11 +59,11 @@ trait RequestsModule extends CrossScalaModule with PublishModule with Mima { licenses = Seq(License.MIT), versionControl = VersionControl.github("com-lihaoyi", "requests-scala"), developers = Seq( - Developer("lihaoyi", "Li Haoyi","https://github.com/lihaoyi") + Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi") ) ) - def ivyDeps = Agg(ivy"com.lihaoyi::geny::1.0.0") + def ivyDeps = Agg(ivy"com.lihaoyi::geny::1.1.1") object test extends ScalaTests with TestModule.Utest { def ivyDeps = Agg( From 68d258028e58439f05ceeefa6137c08d3df5f264 Mon Sep 17 00:00:00 2001 From: Lanqing Huang Date: Mon, 30 Dec 2024 05:44:53 +0000 Subject: [PATCH 02/10] chore: Update versions of GitHub Actions --- .github/workflows/actions.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 4b6118f..5486251 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -17,8 +17,8 @@ jobs: matrix: java: ['11', '17', '21'] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: ${{ matrix.java }} @@ -28,10 +28,10 @@ jobs: check-binary-compatibility: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: 17 @@ -47,12 +47,12 @@ jobs: SONATYPE_PGP_PRIVATE_KEY_PASSWORD: ${{ secrets.SONATYPE_PGP_PRIVATE_KEY_PASSWORD }} SONATYPE_USER: ${{ secrets.SONATYPE_USER }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - LANG: "en_US.UTF-8" - LC_MESSAGES: "en_US.UTF-8" - LC_ALL: "en_US.UTF-8" + LANG: 'en_US.UTF-8' + LC_MESSAGES: 'en_US.UTF-8' + LC_ALL: 'en_US.UTF-8' steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: 11 @@ -73,6 +73,7 @@ jobs: fi - name: Create GitHub Release id: create_gh_release + # WARN: `actions/create-release` is currently unmaintained. It just works now, keep it until it breaks. uses: actions/create-release@v1.1.4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token From b5ef43acaa787f88844b1a23256efad937514418 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 31 Dec 2024 07:24:29 +0900 Subject: [PATCH 03/10] Update build.mill Co-authored-by: Ondra Pelech --- build.mill | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.mill b/build.mill index 0b6c477..ddd1daa 100644 --- a/build.mill +++ b/build.mill @@ -11,7 +11,7 @@ import de.tobiasroeser.mill.vcs.version.VcsVersion import com.github.lolgab.mill.mima._ val dottyVersion = sys.props.get("dottyVersion") -val scalaVersions = List("2.12.20", "2.13.15", "3.6.2") ++ dottyVersion +val scalaVersions = List("2.12.20", "2.13.15", "3.3.4") ++ dottyVersion trait RequestsJvmModule extends RequestsModule with Mima { def mimaPreviousArtifacts = Agg( From cd919cfec2c9bdbc64339a55d65ebd84c66f6dde Mon Sep 17 00:00:00 2001 From: Lanqing Huang Date: Sat, 4 Jan 2025 10:39:18 +0000 Subject: [PATCH 04/10] chore: Update mill version to 0.12.5 (Close #181) --- .mill-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mill-version b/.mill-version index ac454c6..43c2417 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.12.0 +0.12.5 From a0946143914d059759bc9141767681218d7791d7 Mon Sep 17 00:00:00 2001 From: Lanqing Huang Date: Tue, 7 Jan 2025 03:41:57 +0000 Subject: [PATCH 05/10] chore: Depreate versions that donot have scala 3 release in binary check --- build.mill | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build.mill b/build.mill index ddd1daa..104a8dd 100644 --- a/build.mill +++ b/build.mill @@ -16,10 +16,7 @@ val scalaVersions = List("2.12.20", "2.13.15", "3.3.4") ++ dottyVersion trait RequestsJvmModule extends RequestsModule with Mima { def mimaPreviousArtifacts = Agg( ( - Seq("0.7.0", "0.7.1", "0.8.2") - ++ Option - .when(VcsVersion.vcsState().commitsSinceLastTag != 0)(VcsVersion.vcsState().lastTag) - .flatten + Seq("0.6.9", "0.7.0", "0.7.1", "0.8.0","0.8.2", "0.9.0") ).map(v => ivy"com.lihaoyi::requests:${v}") : _* ) override def mimaBinaryIssueFilters = Seq( From bd4f1946cb4349a6f919aa7ded38d3c61442ebc9 Mon Sep 17 00:00:00 2001 From: Lanqing Huang Date: Tue, 7 Jan 2025 04:42:50 +0000 Subject: [PATCH 06/10] chore: Add `scalaNextVersion` and add it into GitHub CI Actions --- .github/workflows/actions.yml | 10 ++++++++-- build.mill | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 5486251..fe7f005 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -9,6 +9,12 @@ on: pull_request: branches: - master + workflow_dispatch: # be able to manually trigger a workflow run + +env: + SCALA_NEXT_VERSION: '3.6.2' + # TODO: perherps, it would be nice to allow failure on `SCALA_NEXT_VERSION` as a warning + # to avoid too strict dev experiences in the future improvements. jobs: test: @@ -23,7 +29,7 @@ jobs: distribution: 'temurin' java-version: ${{ matrix.java }} - name: Run tests - run: ./mill -i __.publishArtifacts + __.test + run: ./mill -DscalaNextVersion=${{ env.SCALA_NEXT_VERSION }} -i __.publishArtifacts + __.test check-binary-compatibility: runs-on: ubuntu-latest @@ -36,7 +42,7 @@ jobs: distribution: 'temurin' java-version: 17 - name: Check Binary Compatibility - run: ./mill -i __.mimaReportBinaryIssues + run: ./mill -DscalaNextVersion=${{ env.SCALA_NEXT_VERSION }} -i __.mimaReportBinaryIssues publish-sonatype: if: github.repository == 'com-lihaoyi/requests-scala' && contains(github.ref, 'refs/tags/') diff --git a/build.mill b/build.mill index 104a8dd..6b36c36 100644 --- a/build.mill +++ b/build.mill @@ -10,8 +10,8 @@ import $ivy.`com.github.lolgab::mill-mima::0.0.24` import de.tobiasroeser.mill.vcs.version.VcsVersion import com.github.lolgab.mill.mima._ -val dottyVersion = sys.props.get("dottyVersion") -val scalaVersions = List("2.12.20", "2.13.15", "3.3.4") ++ dottyVersion +val scalaNextVersion = sys.props.get("scalaNextVersion") +val scalaVersions = List("2.12.20", "2.13.15", "3.3.4") ++ scalaNextVersion trait RequestsJvmModule extends RequestsModule with Mima { def mimaPreviousArtifacts = Agg( From e085b0ddf2f85f508093ab8964f8a2c97ba1b92e Mon Sep 17 00:00:00 2001 From: Lanqing Huang Date: Tue, 7 Jan 2025 04:45:51 +0000 Subject: [PATCH 07/10] bugfix: Fix `-i/--interactive/--no-server/--bsp must be passed in as the first argument` --- .github/workflows/actions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index fe7f005..3e19697 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -29,7 +29,7 @@ jobs: distribution: 'temurin' java-version: ${{ matrix.java }} - name: Run tests - run: ./mill -DscalaNextVersion=${{ env.SCALA_NEXT_VERSION }} -i __.publishArtifacts + __.test + run: ./mill -i -DscalaNextVersion=${{ env.SCALA_NEXT_VERSION }} __.publishArtifacts + __.test check-binary-compatibility: runs-on: ubuntu-latest @@ -42,7 +42,7 @@ jobs: distribution: 'temurin' java-version: 17 - name: Check Binary Compatibility - run: ./mill -DscalaNextVersion=${{ env.SCALA_NEXT_VERSION }} -i __.mimaReportBinaryIssues + run: ./mill -i -DscalaNextVersion=${{ env.SCALA_NEXT_VERSION }} __.mimaReportBinaryIssues publish-sonatype: if: github.repository == 'com-lihaoyi/requests-scala' && contains(github.ref, 'refs/tags/') From 419aac2044b9d798701025b07f6ecfcacecccaec Mon Sep 17 00:00:00 2001 From: Lanqing Huang Date: Tue, 7 Jan 2025 09:45:30 +0000 Subject: [PATCH 08/10] bugfix: Make mima check passed --- build.mill | 75 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/build.mill b/build.mill index 6b36c36..f3bdc4d 100644 --- a/build.mill +++ b/build.mill @@ -12,41 +12,22 @@ import com.github.lolgab.mill.mima._ val scalaNextVersion = sys.props.get("scalaNextVersion") val scalaVersions = List("2.12.20", "2.13.15", "3.3.4") ++ scalaNextVersion +val scalaNativeVer = "0.5.6" + +trait MimaCheck extends Mima { + def mimaPreviousVersions = ( + Seq("0.6.9", "0.7.0", "0.7.1", "0.8.0","0.8.2", "0.9.0") + ).distinct -trait RequestsJvmModule extends RequestsModule with Mima { - def mimaPreviousArtifacts = Agg( - ( - Seq("0.6.9", "0.7.0", "0.7.1", "0.8.0","0.8.2", "0.9.0") - ).map(v => ivy"com.lihaoyi::requests:${v}") : _* - ) override def mimaBinaryIssueFilters = Seq( ProblemFilter.exclude[ReversedMissingMethodProblem]("requests.BaseSession.send"), - ProblemFilter.exclude[DirectMissingMethodProblem]("requests.Response.string") + ProblemFilter.exclude[DirectMissingMethodProblem]("requests.Response.string"), ) } -object requests extends Cross[RequestsJvmModule](scalaVersions) {} - -/** - * Placeholder for Scala Native module - */ -// object native extends Cross[RequestsNativeModule](scalaVersions) -// trait RequestsNativeModule extends RequestsModule with ScalaNativeModule { -// override def scalaNativeVersion = scalaNative -// override def nativeEmbedResources = true - -// def ivyDeps = -// super.ivyDeps() ++ Agg(ivy"com.github.lolgab::scala-native-crypto::0.1.0") -// def nativeLinkingOptions = Seq("-lmicrohttpd") - -// object test extends ScalaNativeTests with RequestsTestModule { -// def nativeLinkingOptions = -// super.nativeLinkingOptions() ++ Seq("-L/usr/local/opt/openssl@3/lib") -// } -// } - -trait RequestsModule extends CrossScalaModule - with PlatformScalaModule - with PublishModule { + +trait RequestsPublishModule extends PublishModule with MimaCheck { + def artifactName = "requests" + def publishVersion = VcsVersion.vcsState().format() def pomSettings = PomSettings( @@ -61,12 +42,34 @@ trait RequestsModule extends CrossScalaModule ) def ivyDeps = Agg(ivy"com.lihaoyi::geny::1.1.1") +} - object test extends ScalaTests with TestModule.Utest { - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.7.10", - ivy"com.lihaoyi::ujson::1.3.13", - ivy"com.dimafeng::testcontainers-scala-core:0.41.3" - ) +trait RequestsCrossScalaModule extends CrossScalaModule with ScalaModule { + def millSourcePath = build.millSourcePath / "requests" + def sources = T.sources(millSourcePath / "src") +} + +trait RequestsTestModule extends TestModule.Utest { + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.7.10", + ivy"com.lihaoyi::ujson::1.3.13", + ivy"com.dimafeng::testcontainers-scala-core:0.41.3" + ) +} + +object requests extends Module { + trait RequestsJvmModule extends RequestsCrossScalaModule with RequestsPublishModule { + object test extends ScalaTests with RequestsTestModule } + object jvm extends Cross[RequestsJvmModule](scalaVersions) + + // trait RequestsNativeModule extends ScalaNativeModule with RequestsPublishModule { + // override def scalaNativeVersion = scalaNativeVer + + // def ivyDeps = + // super.ivyDeps() ++ Agg(ivy"com.github.lolgab::scala-native-crypto::0.1.0") + + // object test extends ScalaNativeTests with RequestsTestModule + // } + // object native extends Cross[RequestsNativeModule](scalaVersions) } From b7455ab32f4fbd930310d8171f71542b314b01eb Mon Sep 17 00:00:00 2001 From: Lanqing Huang Date: Tue, 7 Jan 2025 11:10:32 +0000 Subject: [PATCH 09/10] bugfix: Fix statusCode assertation in test case "selfSignedCertificate" --- build.mill | 8 +++----- requests/test/src/requests/RequestTests.scala | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/build.mill b/build.mill index f3bdc4d..0e3820c 100644 --- a/build.mill +++ b/build.mill @@ -15,9 +15,7 @@ val scalaVersions = List("2.12.20", "2.13.15", "3.3.4") ++ scalaNextVersion val scalaNativeVer = "0.5.6" trait MimaCheck extends Mima { - def mimaPreviousVersions = ( - Seq("0.6.9", "0.7.0", "0.7.1", "0.8.0","0.8.2", "0.9.0") - ).distinct + def mimaPreviousVersions = Seq("0.6.9", "0.7.0", "0.7.1", "0.8.0","0.8.2", "0.9.0").distinct override def mimaBinaryIssueFilters = Seq( ProblemFilter.exclude[ReversedMissingMethodProblem]("requests.BaseSession.send"), @@ -65,10 +63,10 @@ object requests extends Module { // trait RequestsNativeModule extends ScalaNativeModule with RequestsPublishModule { // override def scalaNativeVersion = scalaNativeVer - + // // def ivyDeps = // super.ivyDeps() ++ Agg(ivy"com.github.lolgab::scala-native-crypto::0.1.0") - + // // object test extends ScalaNativeTests with RequestsTestModule // } // object native extends Cross[RequestsNativeModule](scalaVersions) diff --git a/requests/test/src/requests/RequestTests.scala b/requests/test/src/requests/RequestTests.scala index 32dd5ec..447c496 100644 --- a/requests/test/src/requests/RequestTests.scala +++ b/requests/test/src/requests/RequestTests.scala @@ -271,9 +271,10 @@ object RequestTests extends HttpbinTestSuite { test("selfSignedCertificate"){ val res = requests.get( "https://self-signed.badssl.com", - verifySslCerts = false + verifySslCerts = false, + check = false, ) - assert(res.statusCode == 200) + assert(res.statusCode == 404) } test("gzipError"){ From a6f47406b7bfb3c82cd7449c101f729d852a487e Mon Sep 17 00:00:00 2001 From: Lanqing Huang Date: Wed, 8 Jan 2025 02:07:29 +0000 Subject: [PATCH 10/10] Reverit return status code to 200 --- requests/test/src/requests/RequestTests.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requests/test/src/requests/RequestTests.scala b/requests/test/src/requests/RequestTests.scala index 447c496..cae8151 100644 --- a/requests/test/src/requests/RequestTests.scala +++ b/requests/test/src/requests/RequestTests.scala @@ -272,9 +272,8 @@ object RequestTests extends HttpbinTestSuite { val res = requests.get( "https://self-signed.badssl.com", verifySslCerts = false, - check = false, ) - assert(res.statusCode == 404) + assert(res.statusCode == 200) } test("gzipError"){