Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .flake8

This file was deleted.

29 changes: 29 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copilot instructions (terra_invicta_save_editor)

## No “magic strings” in Rust UI or save logic

This repo intentionally avoids sprinkling important string literals throughout the Rust code, because typos like `"publicOpinon"` won’t fail at compile time.

### Use `tise2/src/statics.rs` for constants

- **UI strings** go in `tise2/src/statics.rs` with an `EN_` prefix.
- Example: `EN_BTN_OPEN`, `EN_WINDOW_ABOUT`, `EN_PUBLIC_OPINION_HELPER`.
- In code, use `statics::EN_*` rather than inline `"Open…"`, `"About"`, etc.

- **Terra Invicta save-structure keys** go in `tise2/src/statics.rs` with a `TI_` prefix.
- Example: `TI_PROP_PUBLIC_OPINION`, `TI_PUBLIC_OPINION_UNDECIDED`, `TI_GAMESTATES`, `TI_REF_FIELD_VALUE`, `TI_REF_FIELD_TYPE`.
- In code, use `statics::TI_*` rather than inline `"publicOpinion"`, `"Undecided"`, `"gamestates"`, `"value"`, `"$type"`, etc.

### What to do when adding/editing features

- If you need a new UI label/heading/button text: **add an `EN_*` const** in `tise2/src/statics.rs`, then reference it from the UI.
- If you need a new key/property name for parsing/formatting TI saves: **add a `TI_*` const** in `tise2/src/statics.rs`, then reference it everywhere.
- Prefer compile-time string reuse over retyping literals in `gui.rs`, `save.rs`, `value.rs`, tests, etc.

### Validation expectations

- Keep changes minimal and consistent with existing style.
- Before considering work “done”, run:
- `cargo fmt --all`
- `cargo clippy --all-targets -- -D warnings`
- `cargo test`
21 changes: 0 additions & 21 deletions .github/workflows/build-windows-exe.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: fmt + clippy + test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Rust cache
uses: Swatinem/rust-cache@v2

- name: cargo fmt --check
run: cargo fmt --all -- --check

- name: cargo clippy (deny warnings)
run: cargo clippy --all-targets -- -D warnings

- name: cargo test
run: cargo test --locked
117 changes: 117 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Release

on:
push:
tags:
- "v*"

permissions:
contents: write

env:
CARGO_TERM_COLOR: always

jobs:
build-windows:
name: Build Windows (x86_64)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc

- name: Rust cache
uses: Swatinem/rust-cache@v2

- name: Build (release)
run: cargo build --release --locked --target x86_64-pc-windows-msvc

- name: Stage artifact
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item -Force target\x86_64-pc-windows-msvc\release\tise.exe dist\tise-windows-x86_64.exe

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows
path: dist/tise-windows-x86_64.exe
if-no-files-found: error

build-linux-musl:
name: Build Linux musl (x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install cross
uses: taiki-e/install-action@v2
with:
tool: cross

- name: Build (release, musl)
run: cross build --release --locked --target x86_64-unknown-linux-musl

- name: Stage artifact
run: |
mkdir -p dist
cp target/x86_64-unknown-linux-musl/release/tise dist/tise-linux-x86_64-musl
chmod +x dist/tise-linux-x86_64-musl

- name: Verify static linking (musl)
shell: bash
run: |
set -euo pipefail
bin="dist/tise-linux-x86_64-musl"

echo "::group::file(1) output"
file "$bin" || true
echo "::endgroup::"

# Accept either fully static or static-PIE.
file "$bin" | grep -Eiq 'statically linked|static-pie'

echo "::group::ldd output"
set +e
out=$(ldd "$bin" 2>&1)
code=$?
set -e
echo "$out"
echo "ldd exit code: $code"
echo "::endgroup::"

# For static binaries on glibc, ldd often prints "not a dynamic executable".
echo "$out" | grep -Eiq 'not a dynamic executable|statically linked'

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: linux-musl
path: dist/tise-linux-x86_64-musl
if-no-files-found: error

publish:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs: [build-windows, build-linux-musl]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist

- name: Publish
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/windows/tise-windows-x86_64.exe
dist/linux-musl/tise-linux-x86_64-musl
fail_on_unmatched_files: true
Loading