]> git.puffer.fish Git - matthieu/nova.git/commitdiff
new build infrastructure
authorMatthieuCoder <matthieu@matthieu-dev.xyz>
Fri, 20 Jan 2023 15:32:03 +0000 (19:32 +0400)
committerMatthieuCoder <matthieu@matthieu-dev.xyz>
Fri, 20 Jan 2023 15:32:03 +0000 (19:32 +0400)
.cargo/config.toml
.ci/build.sh [new file with mode: 0755]
.github/workflows/build.yml
Cargo.lock
Cargo.toml
Cross.toml [new file with mode: 0644]
Dockerfile.cross [new file with mode: 0644]
exes/gateway/Cargo.toml
libs/leash/src/lib.rs
libs/proto/Cargo.toml

index 656e08b0117fdaae52fa76742ec796caa97e0be5..c91c3f38b7b3ee09bdca168167855324db35608a 100644 (file)
@@ -1,2 +1,2 @@
 [net]
-git-fetch-with-cli = true
\ No newline at end of file
+git-fetch-with-cli = true
diff --git a/.ci/build.sh b/.ci/build.sh
new file mode 100755 (executable)
index 0000000..0ff94c4
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+N=4
+i=0
+TARGETS=(
+   # Linux builds
+   "linux-arm64-gnuc:aarch64-unknown-linux-gnu"
+   "linux-arm64-musl:aarch64-unknown-linux-musl"
+   "linux-armv7-gnuc:armv7-unknown-linux-gnueabi"
+   "linux-armv7-musl:armv7-unknown-linux-musleabi"
+   "linux-86_64-gnuc:x86_64-unknown-linux-gnu"
+   "linux-86_64-musl:x86_64-unknown-linux-musl"
+
+   # windows builds
+   "windows-86_64-gnu:x86_64-pc-windows-gnu"
+)
+
+for thing in "${TARGETS[@]}"; do 
+   KEY=${thing%%:*}
+   VALUE=${thing#*:}
+   
+   echo "* BUILDING FOR $VALUE"
+   cross build --release --target $VALUE
+
+   # Copy intol folders
+   mkdir -p ./build/$KEY/
+   cp target/$VALUE/release/* ./build/$KEY/
+
+   rm ./build/$KEY/*.{d,rlib}
+done
+
+wait < <(jobs -p)
index dfb9c89bb69862c2817f386b099e52089ecbdc2d..d42eb8d731612bde9abf2f9e91ca86466217c9d1 100644 (file)
@@ -66,45 +66,13 @@ jobs:
           name: macos
           path: build/*
 
-  build_windows:
-    name: 'Build for Windows'
-    runs-on: windows-latest
-
-    defaults:
-      run:
-        shell: msys2 {0}
-
-    steps:
-      - uses: actions/checkout@v2
-      - uses: actions/cache@v3
-        with:
-          path: |
-            ~/.cargo/bin/
-            ~/.cargo/registry/index/
-            ~/.cargo/registry/cache/
-            ~/.cargo/git/db/
-            target/
-          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
-
-      - uses: msys2/setup-msys2@v2
-        with:
-          install: git mingw-w64-x86_64-go mingw-w64-x86_64-make mingw-w64-x86_64-protobuf mingw-w64-x86_64-rust mingw-w64-x86_64-gcc mingw-w64-x86_64-dlfcn
-
-      - name: Build all
-        run: |
-          export CGO_LDFLAGS='-lntdll -lWs2_32 -lcrypt32 -lSecur32 -luserenv -lNcrypt -lbcrypt'
-          mingw32-make.exe all
-      - uses: actions/upload-artifact@v3
-        with:
-          name: windows
-          path: build/*
-
   build_linux:
     name: 'Build for Linux'
     runs-on: ubuntu-latest
-
     steps:
       - uses: actions/checkout@v2
+      - uses: docker-practice/actions-setup-docker@master
+        timeout-minutes: 12
       - uses: actions/cache@v3
         with:
           path: |
@@ -113,47 +81,11 @@ jobs:
             ~/.cargo/registry/cache/
             ~/.cargo/git/db/
             target/
-          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
-
-      - uses: arduino/setup-protoc@v1
-        with:
-          repo-token: ${{ secrets.GITHUB_TOKEN }}
-      - uses: ATiltedTree/setup-rust@v1
-        with:
-          rust-version: stable
-      - uses: actions/setup-go@v3
-        with:
-          go-version: '1.18.4'
-      
+          key: ${{ runner.os }}-cargo
       - name: Build all
         run: |
-          make all
+          ./.ci/build.sh
       - uses: actions/upload-artifact@v3
         with:
-          name: linux
+          name: release
           path: build/*
-
-  release:
-    if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
-    runs-on: ubuntu-latest
-    permissions:
-      contents: write
-    steps:
-      - uses: actions/download-artifact@v3
-        with:
-          name: windows
-          path: windows
-      - uses: actions/download-artifact@v3
-        with:
-          name: linux_glibc
-          path: linux_glibc
-      - uses: actions/download-artifact@v3
-        with:
-          name: macos
-          path: macos
-      - uses: ncipollo/release-action@v1
-        with:
-          artifacts: "windows/*,macos/*,linux_glibc/*"
-          draft: true
-          generateReleaseNotes: true
-          skipIfReleaseExists: true
index da521bdfc52a7408cdc6c9bc8c462eb57d0d6758..0b7dccafe2359601a7d178372f2484396c09e406 100644 (file)
@@ -471,15 +471,6 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff"
 
-[[package]]
-name = "crc32fast"
-version = "1.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
-dependencies = [
- "cfg-if",
-]
-
 [[package]]
 name = "criterion"
 version = "0.4.0"
@@ -750,17 +741,6 @@ version = "0.4.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
 
-[[package]]
-name = "flate2"
-version = "1.0.25"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
-dependencies = [
- "crc32fast",
- "libz-sys",
- "miniz_oxide",
-]
-
 [[package]]
 name = "fnv"
 version = "1.0.7"
@@ -1097,6 +1077,7 @@ dependencies = [
  "rustls-native-certs",
  "tokio",
  "tokio-rustls",
+ "webpki-roots",
 ]
 
 [[package]]
@@ -1234,17 +1215,6 @@ version = "0.2.139"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
 
-[[package]]
-name = "libz-sys"
-version = "1.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf"
-dependencies = [
- "cc",
- "pkg-config",
- "vcpkg",
-]
-
 [[package]]
 name = "linked-hash-map"
 version = "0.5.6"
@@ -1719,12 +1689,6 @@ dependencies = [
  "zeroize",
 ]
 
-[[package]]
-name = "pkg-config"
-version = "0.3.26"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
-
 [[package]]
 name = "plotters"
 version = "0.3.4"
@@ -2708,11 +2672,11 @@ dependencies = [
  "futures-util",
  "log",
  "rustls",
- "rustls-native-certs",
  "tokio",
  "tokio-rustls",
  "tungstenite",
  "webpki",
+ "webpki-roots",
 ]
 
 [[package]]
@@ -2979,11 +2943,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ba43f8e8dc9f92f61c9ac4d339f7a8483c3ebef2b4f56fe62fb19e151dc79dae"
 dependencies = [
  "bitflags",
- "flate2",
  "futures-util",
  "leaky-bucket-lite",
  "rustls",
- "rustls-native-certs",
  "serde",
  "serde_json",
  "tokio",
@@ -2993,6 +2955,7 @@ dependencies = [
  "twilight-http",
  "twilight-model",
  "url",
+ "webpki-roots",
 ]
 
 [[package]]
@@ -3138,12 +3101,6 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
 
-[[package]]
-name = "vcpkg"
-version = "0.2.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
-
 [[package]]
 name = "version_check"
 version = "0.9.4"
@@ -3276,6 +3233,15 @@ dependencies = [
  "untrusted",
 ]
 
+[[package]]
+name = "webpki-roots"
+version = "0.22.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
+dependencies = [
+ "webpki",
+]
+
 [[package]]
 name = "which"
 version = "4.3.0"
index 2c746fab1a181fb0c3b7be4cb08d18b67e5feb83..c26fa4d9d1e0de89c978cd430e4ec4e360a11d35 100644 (file)
@@ -36,4 +36,4 @@ tokio-test = "0.4.2"
 tracing-test = "0.2.3"\r
 tracing-subscriber = "0.3.16"\r
 test-log = { version = "*", features = ["trace"] }\r
-env_logger = "0.10.0"
\ No newline at end of file
+env_logger = "0.10.0"\r
diff --git a/Cross.toml b/Cross.toml
new file mode 100644 (file)
index 0000000..9fb3099
--- /dev/null
@@ -0,0 +1,6 @@
+[build]
+pre-build = [
+    "dpkg --add-architecture $CROSS_DEB_ARCH",
+    "apt-get update && apt-get --assume-yes install libc6-dev",
+]
+dockerfile = "Dockerfile.cross"
\ No newline at end of file
diff --git a/Dockerfile.cross b/Dockerfile.cross
new file mode 100644 (file)
index 0000000..7b37a9d
--- /dev/null
@@ -0,0 +1,13 @@
+ARG CROSS_BASE_IMAGE
+
+FROM debian as db
+WORKDIR /dl
+RUN apt-get update && apt-get install -y curl zip
+RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-linux-x86_64.zip && \
+    unzip protoc-21.12-linux-x86_64.zip -d protoc3
+
+FROM $CROSS_BASE_IMAGE
+
+COPY --from=db /dl/protoc3 /dl/
+RUN mv /dl/bin/* /usr/local/bin/ && \
+    mv /dl/include/* /usr/local/include/
index 39161381d8b7f0fbb3c0b987dbbd171ff0b7370e..3e6b8a53f03fb5629d057ed7a52401b62ac1a31c 100644 (file)
@@ -18,7 +18,7 @@ serde = { workspace = true }
 serde_json = { workspace = true }
 
 tokio-stream = "0.1.11"
-twilight-gateway = { version = "0.14" }
+twilight-gateway = { default-features = false, features = ["rustls-webpki-roots"], version = "0.14" }
 twilight-model = "0.14"
 bytes = "1.3.0"
 async-nats = "0.26.0"
index f3c947292b1717c9f1301bf1a2086c907f1eb930..d45d6c86737008e160c733ad842d6b78be7fa791 100644 (file)
@@ -133,7 +133,7 @@ where
                 .recv()
                 .await;
             #[cfg(not(unix))]
-            return tokio::signal::ctrl_c().await.unwrap();
+            tokio::signal::ctrl_c().await.unwrap();
 
             stop.send(()).unwrap();
             shutdown_tracer_provider();
index 2556dfec5a5da9ab1ae9d9b309c14f1780dedc2f..901249d21e276d674a277a5ebfe5c1db5644615a 100644 (file)
@@ -9,4 +9,4 @@ prost = "0.11.5"
 
 [build-dependencies]
 tonic-build = "0.8.4"
-glob = "0.3.0"
\ No newline at end of file
+glob = "0.3.0"