From 320d288a6b8aa1903126987703d18db60b6e9ac8 Mon Sep 17 00:00:00 2001 From: Devin Bidwell Date: Fri, 5 Dec 2025 02:05:20 -0700 Subject: [PATCH] Start setting up github actions --- .github/workflows/build.yml | 67 ++++++++++++++++++++++++++++++ Dockerfile.build | 19 +++++++++ build.sh | 2 - csharp_mod/Plugin.cs | 5 ++- csharp_mod/stationeersSlang.csproj | 20 ++++----- 5 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile.build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..71eabaf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,67 @@ +name: CI/CD Pipeline + +# Trigger conditions +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + # JOB 1: RUN TESTS + # This runs on every PR and every push to master. + # It validates that the Rust code is correct. + test: + runs-on: self-hosted + steps: + - uses: actions/checkout@v4 + + # 1. Build the Docker Image (Cached) + - name: Build Docker Image + run: docker build -t slang-builder -f Dockerfile.build . + + # 2. Run Rust Tests + # --manifest-path: Point to the nested Cargo.toml + # --workspace: Test all crates (compiler, parser, tokenizer, helpers) + # --all-targets: Test lib, bin, and tests folder (skips doc-tests for speed) + - name: Run Rust Tests + run: | + docker run --rm \ + -v "$PWD":/app \ + slang-builder \ + cargo test --manifest-path rust_compiler/Cargo.toml --workspace --all-targets + + build: + needs: test + runs-on: self-hosted + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@v4 + + # 1. Build Image (Fast, uses cache from previous job if available/local) + - name: Build Docker Image + run: docker build -t slang-builder -f Dockerfile.build . + + # 2. Run the Build Script + # Mounts the references from the server's secure storage + - name: Build Release Artifacts + run: | + docker run --rm \ + -v "$PWD":/app \ + -v "/home/github-runner/permanent-refs":/app/csharp_mod/refs \ + slang-builder \ + ./build.sh + + # 3. Fix Permissions + # Docker writes files as root. We need to own them to upload them. + - name: Fix Permissions + if: always() + run: sudo chown -R $USER:$USER release/ + + # 4. Upload to GitHub + - name: Upload Release Artifacts + uses: actions/upload-artifact@v4 + with: + name: StationeersSlang-Release + path: release/ diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000..cbb06c5 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,19 @@ +FROM rust:latest + +RUN apt-get update && apt-get install -y \ + mingw-w64 \ + wget \ + apt-transport-https \ + && rm -rf /var/lib/apt/lists/* + +RUN wget --progress=dot:giga https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh \ + && chmod +x ./dotnet-install.sh \ + && ./dotnet-install.sh --channel 8.0 --install-dir /usr/share/dotnet \ + && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet + +RUN rustup target add x86_64-pc-windows-gnu && rustup target add x86_64-unknown-linux-gnu + +WORKDIR /app + +# The command will be provided at runtime +CMD ["./build.sh"] diff --git a/build.sh b/build.sh index 0bbc5a5..2164aba 100755 --- a/build.sh +++ b/build.sh @@ -39,7 +39,6 @@ echo "--------------------" RUST_WIN_EXE="$RUST_DIR/target/x86_64-pc-windows-gnu/release/slang.exe" RUST_LINUX_BIN="$RUST_DIR/target/x86_64-unknown-linux-gnu/release/slang" CHARP_DLL="$CSHARP_DIR/bin/Release/net48/StationeersSlang.dll" -CHARP_PDB="$CSHARP_DIR/bin/Release/net48/StationeersSlang.pdb" # Check if the release dir exists, if not: create it. if [[ ! -d "$RELEASE_DIR" ]]; then @@ -49,4 +48,3 @@ fi cp "$RUST_WIN_EXE" "$RELEASE_DIR/slang.exe" cp "$RUST_LINUX_BIN" "$RELEASE_DIR/slang" cp "$CHARP_DLL" "$RELEASE_DIR/StationeersSlang.dll" -cp "$CHARP_PDB" "$RELEASE_DIR/StationeersSlang.pdb" diff --git a/csharp_mod/Plugin.cs b/csharp_mod/Plugin.cs index d4a8740..94d177b 100644 --- a/csharp_mod/Plugin.cs +++ b/csharp_mod/Plugin.cs @@ -35,14 +35,15 @@ namespace Slang } } - [BepInPlugin(PluginGuid, PluginName, "0.1.0")] + [BepInPlugin(PluginGuid, PluginName, PluginVersion)] [BepInDependency(StationeersIC10Editor.IC10EditorPlugin.PluginGuid)] public class SlangPlugin : BaseUnityPlugin { public const string PluginGuid = "com.biddydev.slang"; public const string PluginName = "Slang"; + public const string PluginVersion = "0.1.0"; - public static Mod MOD = new Mod(PluginName, "0.1.0"); + public static Mod MOD = new Mod(PluginName, PluginVersion); private Harmony? _harmony; diff --git a/csharp_mod/stationeersSlang.csproj b/csharp_mod/stationeersSlang.csproj index e464914..0880395 100644 --- a/csharp_mod/stationeersSlang.csproj +++ b/csharp_mod/stationeersSlang.csproj @@ -11,38 +11,36 @@ - $(STATIONEERS_DIR)/rocketstation_Data/Managed - $(STATIONEERS_DIR)/BepInEx/core - $(ManagedDir)/netstandard.dll + ./ref/netstandard.dll False - $(BepInExDir)/BepInEx.dll + ./ref/BepInEx.dll False - $(BepInExDir)/0Harmony.dll + ./ref/0Harmony.dll False - $(ManagedDir)/UnityEngine.dll + ./ref/UnityEngine.dll False - $(ManagedDir)/UnityEngine.CoreModule.dll + ./ref/UnityEngine.CoreModule.dll False - $(ManagedDir)/Assembly-CSharp.dll + ./ref/Assembly-CSharp.dll False - $(ManagedDir)/UniTask.dll + ./ref/UniTask.dll False @@ -51,11 +49,11 @@ False - $(STATIONEERS_DIR)/BepInEx/plugins/StationeersLaunchPad/LaunchPadBooster.dll + ./ref/LaunchPadBooster.dll False - $(STATIONEERS_DIR)/BepInEx/plugins/StationeersLaunchPad/StationeersMods.Interface.dll + ./ref/StationeersMods.Interface.dll False