Skip to content

Commit

Permalink
ci: basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jac3km4 committed Jan 14, 2025
1 parent 16c56b7 commit a2fed8c
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches: ["*.*.x"]
pull_request:
branches: ["*.*.x"]

env:
CARGO_TERM_COLOR: always

jobs:
check-format:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup toolchain install nightly --profile minimal --component rustfmt --no-self-update
- run: cargo +nightly fmt --all -- --check

lint:
name: Lint
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal --component clippy --no-self-update
- uses: Swatinem/rust-cache@v2
with:
shared-key: "debug"
cache-on-failure: true
- run: cargo clippy --all-features -- -D warnings

test:
name: Test
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal --no-self-update
- uses: Swatinem/rust-cache@v2
with:
shared-key: "debug"
cache-on-failure: true
- run: cargo test --all-features

build:
name: Build
runs-on: windows-latest
env:
ARCHIVE_NAME: redscript-${{ github.ref_name }}.zip
steps:
- uses: actions/checkout@v4
- run: rustup toolchain install stable --profile minimal --no-self-update
- uses: Swatinem/rust-cache@v2
with:
shared-key: "release"
- run: cargo build --release
- run: .\build\package.ps1 -zipPath ${{ env.ARCHIVE_NAME }}
- uses: actions/upload-artifact@v4
with:
path: |
${{ env.ARCHIVE_NAME }}
target/release/redscript-cli.exe
if-no-files-found: error
2 changes: 2 additions & 0 deletions assets/archive/engine/config/base/scripts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Scripts]
EnableCompilation = "true"
8 changes: 8 additions & 0 deletions assets/archive/r6/config/cybercmd/scc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[args]
scriptsBlobPath = "{game_dir}\\r6\\cache\\modded\\final.redscripts"

[[tasks]]
command = "InvokeScc"
path = "{game_dir}\\r6\\scripts"
custom_cache_dir = "{game_dir}\\r6\\cache\\modded"
terminate_on_errors = false
34 changes: 34 additions & 0 deletions build/package.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
param (
[string]$zipPath
)

if (-not $zipPath) {
Write-Error "No output path provided. Please provide a path to write the zip archive to."
exit 1
}

if (-not (Test-Path "target/release/scc.exe")) {
Write-Error "scc.exe not found in target/release. Please ensure you have built it."
exit 1
}

if ($env:RUNNER_TEMP) {
$tempDir = $env:RUNNER_TEMP
} else {
$tempDir = $env:TEMP
}

$stagingDir = Join-Path $tempDir "redscript-archive"
if (Test-Path $stagingDir) {
Remove-Item -Recurse -Force $stagingDir
}

New-Item -ItemType Directory -Path $stagingDir

Copy-Item -Path "assets/archive/*" -Destination $stagingDir -Recurse
New-Item -ItemType Directory -Path (Join-Path $stagingDir "engine/tools")
Copy-Item -Path "target/release/scc.exe" -Destination (Join-Path $stagingDir "engine/tools/scc.exe")

Compress-Archive -Path (Join-Path $stagingDir '*') -DestinationPath $zipPath

Write-Output "Archive created at $zipPath"

0 comments on commit a2fed8c

Please sign in to comment.