Start setting up github actions

This commit is contained in:
2025-12-05 02:05:20 -07:00
parent f2aedb96df
commit 320d288a6b
5 changed files with 98 additions and 15 deletions

67
.github/workflows/build.yml vendored Normal file
View File

@@ -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/

19
Dockerfile.build Normal file
View File

@@ -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"]

View File

@@ -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"

View File

@@ -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;

View File

@@ -11,38 +11,36 @@
</PropertyGroup>
<PropertyGroup>
<ManagedDir>$(STATIONEERS_DIR)/rocketstation_Data/Managed</ManagedDir>
<BepInExDir>$(STATIONEERS_DIR)/BepInEx/core</BepInExDir>
</PropertyGroup>
<ItemGroup>
<Reference Include="netstandard">
<HintPath>$(ManagedDir)/netstandard.dll</HintPath>
<HintPath>./ref/netstandard.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx">
<HintPath>$(BepInExDir)/BepInEx.dll</HintPath>
<HintPath>./ref/BepInEx.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="0Harmony">
<HintPath>$(BepInExDir)/0Harmony.dll</HintPath>
<HintPath>./ref/0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>$(ManagedDir)/UnityEngine.dll</HintPath>
<HintPath>./ref/UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(ManagedDir)/UnityEngine.CoreModule.dll</HintPath>
<HintPath>./ref/UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>$(ManagedDir)/Assembly-CSharp.dll</HintPath>
<HintPath>./ref/Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UniTask">
<HintPath>$(ManagedDir)/UniTask.dll</HintPath>
<HintPath>./ref/UniTask.dll</HintPath>
<Private>False</Private>
</Reference>
@@ -51,11 +49,11 @@
<Private>False</Private>
</Reference>
<Reference Include="LaunchPadBooster.dll">
<HintPath>$(STATIONEERS_DIR)/BepInEx/plugins/StationeersLaunchPad/LaunchPadBooster.dll</HintPath>
<HintPath>./ref/LaunchPadBooster.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="StationeersMods.Interface.dll">
<HintPath>$(STATIONEERS_DIR)/BepInEx/plugins/StationeersLaunchPad/StationeersMods.Interface.dll</HintPath>
<HintPath>./ref/StationeersMods.Interface.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>