From 6a08632f2a3aa06d89dbd49c92a491a07de9e34c Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 13:51:06 +0000 Subject: [PATCH 01/13] Test self-hosted runner --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 542fabf..ca4b8a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,40 @@ jobs: path: bin/sn-bindgen-* name: binaries if-no-files-found: error + +macos_arm_build: + name: MacOS (Arm64) + strategy: + fail-fast: true + runs-on: macos-arm64 + env: + SN_RELEASE: fast + LLVM_VERSION: 14 + LLVM_BIN: /opt/homebrew/opt/llvm@14/bin + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + cache: 'sbt' + + - name: Install LLVM + run: brew install llvm@$LLVM_VERSION + + - name: CI and build the binary + run: sbt ci 'buildBinary sn-bindgen-aarch64-apple-darwin' + - name: Upload artifacts + uses: actions/upload-artifact@master + with: + path: bin/sn-bindgen-* + name: binaries + if-no-files-found: error + linux_build: name: Linux runs-on: ubuntu-20.04 From aa5bbb2e33adb5f715b7e26b4df984f0a0a402e3 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 13:53:09 +0000 Subject: [PATCH 02/13] Update ci.yml --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca4b8a4..5baecc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,8 +77,8 @@ macos_arm_build: path: bin/sn-bindgen-* name: binaries if-no-files-found: error - - linux_build: + +linux_build: name: Linux runs-on: ubuntu-20.04 env: @@ -102,7 +102,6 @@ macos_arm_build: name: binaries if-no-files-found: error - linux_arm64_build: name: Linux (Arm64) runs-on: ubuntu-20.04 From 7180b809e391f0697e4f99cebf33e07982042a17 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 13:54:50 +0000 Subject: [PATCH 03/13] WIP --- .github/workflows/ci.yml | 92 ++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5baecc4..175c6fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,63 +45,63 @@ jobs: name: binaries if-no-files-found: error -macos_arm_build: - name: MacOS (Arm64) - strategy: - fail-fast: true - runs-on: macos-arm64 - env: - SN_RELEASE: fast - LLVM_VERSION: 14 - LLVM_BIN: /opt/homebrew/opt/llvm@14/bin - steps: - - uses: actions/checkout@v3 + macos_arm_build: + name: MacOS (Arm64) + strategy: + fail-fast: true + runs-on: macos-arm64 + env: + SN_RELEASE: fast + LLVM_VERSION: 14 + LLVM_BIN: /opt/homebrew/opt/llvm@14/bin + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + cache: 'sbt' + + - name: Install LLVM + run: brew install llvm@$LLVM_VERSION + + - name: CI and build the binary + run: sbt ci 'buildBinary sn-bindgen-aarch64-apple-darwin' + + - name: Upload artifacts + uses: actions/upload-artifact@master + with: + path: bin/sn-bindgen-* + name: binaries + if-no-files-found: error + + linux_build: + name: Linux + runs-on: ubuntu-20.04 + env: + FORCE_COLOR: 1 + steps: + - uses: earthly/actions/setup-earthly@v1 with: - fetch-depth: 0 + version: v0.7.2 - - uses: actions/setup-java@v3 + - uses: actions/checkout@v3 with: - distribution: 'temurin' - java-version: '17' - cache: 'sbt' - - - name: Install LLVM - run: brew install llvm@$LLVM_VERSION + fetch-depth: 0 - - name: CI and build the binary - run: sbt ci 'buildBinary sn-bindgen-aarch64-apple-darwin' + - name: Intel build + run: earthly --ci --platform linux/amd64 --output +bindgen --BINARY_NAME="sn-bindgen-x86_64-pc-linux" - - name: Upload artifacts + - name: Upload Intel artifacts uses: actions/upload-artifact@master with: path: bin/sn-bindgen-* name: binaries if-no-files-found: error -linux_build: - name: Linux - runs-on: ubuntu-20.04 - env: - FORCE_COLOR: 1 - steps: - - uses: earthly/actions/setup-earthly@v1 - with: - version: v0.7.2 - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Intel build - run: earthly --ci --platform linux/amd64 --output +bindgen --BINARY_NAME="sn-bindgen-x86_64-pc-linux" - - - name: Upload Intel artifacts - uses: actions/upload-artifact@master - with: - path: bin/sn-bindgen-* - name: binaries - if-no-files-found: error - linux_arm64_build: name: Linux (Arm64) runs-on: ubuntu-20.04 From 16340a019c554b8e1758a795591e3f06a47f9739 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 13:57:11 +0000 Subject: [PATCH 04/13] WIP --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 175c6fe..007e0cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: name: MacOS (Arm64) strategy: fail-fast: true - runs-on: macos-arm64 + runs-on: macos-aarch64 env: SN_RELEASE: fast LLVM_VERSION: 14 From 61df82c617187fbf84acc060a0c2236512bced73 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 14:01:17 +0000 Subject: [PATCH 05/13] Install SBT --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 007e0cc..2090ac5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,9 @@ jobs: - name: Install LLVM run: brew install llvm@$LLVM_VERSION + - name: Install SBT + run: brew install sbt + - name: CI and build the binary run: sbt ci 'buildBinary sn-bindgen-aarch64-apple-darwin' From 2eeeaf69e52e2256d970ccf8d6116090d112bc7f Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 14:31:29 +0000 Subject: [PATCH 06/13] Shrug --- .github/workflows/ci.yml | 12 ++++++++++-- modules/bindgen/src/main/scala/ClangDetector.scala | 7 ++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2090ac5..8cef2ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,6 @@ jobs: fail-fast: true runs-on: macos-11 env: - SN_RELEASE: fast LLVM_VERSION: 14 LLVM_BIN: /usr/local/opt/llvm@14/bin steps: @@ -35,6 +34,11 @@ jobs: - name: Install LLVM run: brew install llvm@$LLVM_VERSION + - name: Sets env vars for release + run: | + echo "SN_RELEASE=fast" >> $GITHUB_ENV + if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') + - name: CI and build the binary run: sbt ci 'buildBinary sn-bindgen-x86_64-apple-darwin' @@ -51,7 +55,6 @@ jobs: fail-fast: true runs-on: macos-aarch64 env: - SN_RELEASE: fast LLVM_VERSION: 14 LLVM_BIN: /opt/homebrew/opt/llvm@14/bin steps: @@ -71,6 +74,11 @@ jobs: - name: Install SBT run: brew install sbt + - name: Sets env vars for release + run: | + echo "SN_RELEASE=fast" >> $GITHUB_ENV + if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') + - name: CI and build the binary run: sbt ci 'buildBinary sn-bindgen-aarch64-apple-darwin' diff --git a/modules/bindgen/src/main/scala/ClangDetector.scala b/modules/bindgen/src/main/scala/ClangDetector.scala index 4552e55..a54d286 100644 --- a/modules/bindgen/src/main/scala/ClangDetector.scala +++ b/modules/bindgen/src/main/scala/ClangDetector.scala @@ -7,6 +7,7 @@ import com.indoorvivants.detective.Platform import Platform.OS.* import java.lang.ProcessBuilder.Redirect import scala.sys.process.ProcessLogger +import scala.util.Try case class ClangInfo( includePaths: List[String] @@ -49,7 +50,11 @@ object ClangDetector: end process def detect(path: Path, args: String*): Either[ProcessResult, ClangInfo] = - val tempFolder = Files.createTempDirectory("sn-bindgen-clang") + val tempFolder = LazyList + .fill(5)(Try(Files.createTempDirectory("sn-bindgen-clang"))) + .dropWhile(_.isFailure) + .head + .get val destination = tempFolder.resolve("output.o").toString val tempC = Files.createTempFile(tempFolder, "test", ".c").toString() From 4776abaebd4a3f41c182d07d175a9e3e28feded4 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 14:58:01 +0000 Subject: [PATCH 07/13] only do release-fast on main/tags --- .github/workflows/ci.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8cef2ef..3c04f7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -151,7 +151,6 @@ jobs: fail-fast: false runs-on: windows-2019 env: - SN_RELEASE: fast LLVM_BIN: 'C:\Program Files\LLVM\bin' LLVM_VERSION: "14.0.6" steps: @@ -181,11 +180,17 @@ jobs: - run: clang -v shell: cmd - - name: Install clang + - name: Sets env vars for release + run: | + echo "SN_RELEASE=fast" >> $env:GITHUB_ENV + if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') + shell: pwsh + + - name: Install clang and SBT shell: pwsh run: | choco install llvm --version="$Env:LLVM_VERSION" --allow-downgrade - choco install sbt --version=1.8.0 + choco install sbt --version=1.9.7 clang --version - name: SBT remote cache From 4c52e8a26424da776799ff802c1c7eac3b9a7f4d Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 15:13:51 +0000 Subject: [PATCH 08/13] Run MacOS Arm64 only on release --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c04f7d..907a132 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,8 @@ jobs: strategy: fail-fast: true runs-on: macos-aarch64 + if: startsWith(github.ref, 'refs/tags/v') + continue-on-error: true env: LLVM_VERSION: 14 LLVM_BIN: /opt/homebrew/opt/llvm@14/bin @@ -77,7 +79,6 @@ jobs: - name: Sets env vars for release run: | echo "SN_RELEASE=fast" >> $GITHUB_ENV - if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') - name: CI and build the binary run: sbt ci 'buildBinary sn-bindgen-aarch64-apple-darwin' @@ -217,7 +218,7 @@ jobs: if-no-files-found: error release: - needs: [linux_build, linux_arm64_build, windows_build, macos_build] + needs: [linux_build, linux_arm64_build, windows_build, macos_build, macos_arm_build] name: Release runs-on: ubuntu-20.04 env: @@ -252,6 +253,7 @@ jobs: ./cs resolve com.indoorvivants:bindgen-interface_3:$(cat version) ./cs resolve com.indoorvivants:bindgen-interface_2.12:$(cat version) ./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier osx-x86_64 --artifact-type jar + ./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier osx-aarch64 --artifact-type jar ./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier linux-x86_64 --artifact-type jar ./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier linux-aarch64 --artifact-type jar ./cs fetch com.indoorvivants:bindgen_native0.4_3:$(cat version) --classifier windows-x86_64 --artifact-type jar From c297e575b13902f227b9db57ec0b35e80fb21396 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 15:51:05 +0000 Subject: [PATCH 09/13] Remove Earthly --- .github/workflows/ci.yml | 36 +++++++++++++++++++++++++++++------- Earthfile | 34 ---------------------------------- 2 files changed, 29 insertions(+), 41 deletions(-) delete mode 100644 Earthfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 907a132..69827bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ env: JAVA_OPTS: "-Xmx4G" JVM_OPTS: "-Xmx4G" SBT_OPTS: "-Xmx4G" + LLVM_VERSION: 14 jobs: macos_build: @@ -39,6 +40,10 @@ jobs: echo "SN_RELEASE=fast" >> $GITHUB_ENV if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main') + - name: Sets env vars for LLVM + run: | + echo "LLVM_BIN=/usr/local/opt/llvm@$LLVM_VERSION/bin" >> $GITHUB_ENV + - name: CI and build the binary run: sbt ci 'buildBinary sn-bindgen-x86_64-apple-darwin' @@ -56,9 +61,6 @@ jobs: runs-on: macos-aarch64 if: startsWith(github.ref, 'refs/tags/v') continue-on-error: true - env: - LLVM_VERSION: 14 - LLVM_BIN: /opt/homebrew/opt/llvm@14/bin steps: - uses: actions/checkout@v3 with: @@ -80,6 +82,10 @@ jobs: run: | echo "SN_RELEASE=fast" >> $GITHUB_ENV + - name: Sets env vars for LLVM + run: | + echo "LLVM_BIN=/opt/homebrew/opt/llvm@$LLVM_VERSION/bin" >> $GITHUB_ENV + - name: CI and build the binary run: sbt ci 'buildBinary sn-bindgen-aarch64-apple-darwin' @@ -93,8 +99,10 @@ jobs: linux_build: name: Linux runs-on: ubuntu-20.04 - env: - FORCE_COLOR: 1 + env: + BINARIES: binaries/ + LLVM_BIN: /usr/lib/llvm-14/bin + LLVM_VERSION: 14 steps: - uses: earthly/actions/setup-earthly@v1 with: @@ -104,8 +112,22 @@ jobs: with: fetch-depth: 0 - - name: Intel build - run: earthly --ci --platform linux/amd64 --output +bindgen --BINARY_NAME="sn-bindgen-x86_64-pc-linux" + - name: Setup Unix-like + run: ./build/setup_unix.sh + + - name: Sets env vars for release + run: | + echo "SN_RELEASE=fast" >> $GITHUB_ENV + + - name: Sets env vars for LLVM + run: | + echo "LLVM_BIN=/usr/lib/llvm-$LLVM_VERSION/bin" >> $GITHUB_ENV + + - name: CI and build the binary + run: sbt ci 'buildBinary sn-bindgen-x86_64-pc-linux' + + - name: Build site + run: sbt buildWebsite - name: Upload Intel artifacts uses: actions/upload-artifact@master diff --git a/Earthfile b/Earthfile deleted file mode 100644 index 3812574..0000000 --- a/Earthfile +++ /dev/null @@ -1,34 +0,0 @@ -VERSION 0.7 - - -dependencies-base: - FROM eclipse-temurin:17-focal - COPY build /scripts - RUN /scripts/setup-debian.sh 14 - WORKDIR /sources - - - # SBT dependencies - COPY build.sbt /sources - COPY project/*.sbt /sources/project/ - COPY project/*.scala /sources/project/ - COPY project/build.properties /sources/project/ - RUN sbt update - - SAVE IMAGE --push sn-bindgen-deps-base:14 - -bindgen: - FROM +dependencies-base - ARG BUILD_COMMAND="ci; buildBinary" - ARG BINARY_NAME="bindgen" - - ENV LLVM_BIN=/usr/lib/llvm-14/bin - ENV CC=/usr/lib/llvm-14/bin/clang - ENV CXX=/usr/lib/llvm-14/bin/clang++ - ENV SN_RELEASE "fast" - ENV CI "true" - - COPY . /sources - RUN sbt "${BUILD_COMMAND}" - - SAVE ARTIFACT bin/bindgen AS LOCAL bin/$BINARY_NAME From bc3fdbf084f93ce8c20944ff4c8c2b13ab14db42 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 15:57:31 +0000 Subject: [PATCH 10/13] remove env overrides --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69827bd..143d022 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,10 +99,6 @@ jobs: linux_build: name: Linux runs-on: ubuntu-20.04 - env: - BINARIES: binaries/ - LLVM_BIN: /usr/lib/llvm-14/bin - LLVM_VERSION: 14 steps: - uses: earthly/actions/setup-earthly@v1 with: From 727b14ec305fa3c1f656ee454a63ae5c4d9c264d Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 15:57:49 +0000 Subject: [PATCH 11/13] Quick check that it works on arm --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 143d022..e3a7825 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: strategy: fail-fast: true runs-on: macos-aarch64 - if: startsWith(github.ref, 'refs/tags/v') + # if: startsWith(github.ref, 'refs/tags/v') continue-on-error: true steps: - uses: actions/checkout@v3 From e796f6e307b3739bd6c407307a56c22603c88525 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 18:09:48 +0000 Subject: [PATCH 12/13] update subatomic --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 974a13e..0e7684f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -9,7 +9,7 @@ addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin( - "com.indoorvivants" % "subatomic-plugin" % "0.0.7+111-b6459692-SNAPSHOT" + "com.indoorvivants" % "subatomic-plugin" % "0.0.7+162-f9b59ad1-SNAPSHOT" ) addSbtPlugin( From 0a04bbb8fc73610c7eec18deec17024af4313744 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Thu, 2 Nov 2023 18:19:07 +0000 Subject: [PATCH 13/13] disable macos arm64 again --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3a7825..143d022 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: strategy: fail-fast: true runs-on: macos-aarch64 - # if: startsWith(github.ref, 'refs/tags/v') + if: startsWith(github.ref, 'refs/tags/v') continue-on-error: true steps: - uses: actions/checkout@v3