Skip to content

chore: add missing LunaSettings keys, audit script, and CI audit step #59

chore: add missing LunaSettings keys, audit script, and CI audit step

chore: add missing LunaSettings keys, audit script, and CI audit step #59

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Download Starsector core jars (optional)
env:
STARSECTOR_CORE_URL_SECRET: ${{ secrets.STARSECTOR_CORE_URL }}
run: |
# Prefer environment variable, then secrets
if [ -n "$STARSECTOR_CORE_URL" ]; then
URL="$STARSECTOR_CORE_URL"
elif [ -n "$STARSECTOR_CORE_URL_SECRET" ]; then
URL="$STARSECTOR_CORE_URL_SECRET"
else
echo "No STARSECTOR_CORE_URL provided (set env.STARSECTOR_CORE_URL or secrets.STARSECTOR_CORE_URL). Skipping Starsector core download. If your build requires Starsector API jars, provide a download URL via repository secrets."
exit 0
fi
echo "Downloading Starsector core from $URL"
curl -L -o starsector-core.zip "$URL"
unzip starsector-core.zip -d starsector_core
# Set STARSECTOR_DIR so build.ps1 picks up the extracted core
echo "STARSECTOR_DIR=$PWD/starsector_core" >> $GITHUB_ENV
- name: Validate Java files
run: |
# Check that Java source files exist and have content
if [ ! -d "src/ramscoop" ]; then
echo "Error: Source directory missing"
exit 1
fi
if [ ! -f "src/ramscoop/ModPlugin.java" ] || [ ! -f "src/ramscoop/Ramscoop.java" ]; then
echo "Error: Core Java source files missing"
exit 1
fi
- name: Validate mod structure
run: |
# Check that essential mod files exist
for file in "mod_info.json" "settings.json" "README.md" "LICENSE.txt" "Ramscoop.version"; do
if [ ! -f "$file" ]; then
echo "Error: $file is missing"
exit 1
fi
done
# Check that LunaSettings.csv exists
if [ ! -f "data/config/LunaSettings.csv" ]; then
echo "Error: data/config/LunaSettings.csv is missing"
exit 1
fi
# Run LunaLib key audit script to ensure CSV contains all keys referenced in code
echo "Running LunaLib key audit (no fixes)"
pwsh -NoProfile -NonInteractive -Command "Set-Location '${{ github.workspace }}'; ./.github/scripts/audit_lunalib_keys.ps1"
# Verify that a prebuilt JAR is committed in the repository
if [ ! -f "jars/Ramscoop.jar" ]; then
echo "Error: jars/Ramscoop.jar is missing. Please commit the prebuilt Ramscoop.jar to the repository.";
exit 1
fi
# Sanity-check the JAR: list contents and verify expected classes and MANIFEST
echo "Sanity-checking jars/Ramscoop.jar"
unzip -l jars/Ramscoop.jar | sed -n '1,120p'
# Verify required classes are present
if ! unzip -l jars/Ramscoop.jar | grep -q "ramscoop/ModPlugin.class"; then
echo "Error: ramscoop/ModPlugin.class missing from JAR"; exit 1
fi
if ! unzip -l jars/Ramscoop.jar | grep -q "ramscoop/Ramscoop.class"; then
echo "Error: ramscoop/Ramscoop.class missing from JAR"; exit 1
fi
# Show manifest if present and check for common version attributes
if unzip -p jars/Ramscoop.jar META-INF/MANIFEST.MF 2>/dev/null | tee manifest.txt; then
if grep -qi "version" manifest.txt; then
echo "Manifest contains version info:"; grep -i "version" manifest.txt || true
else
echo "Manifest present but no version entry found (this is informational)"
fi
else
echo "Warning: No MANIFEST.MF found in JAR (informational)"
fi
- name: Generate and validate changelog.txt
run: |
# Test the changelog generation process
sed 's/^## Version /Version /g' CHANGELOG.md | \
sed 's/^# .*//g' | \
sed 's/^- /- /g' | \
sed '/^$/N;/^\n$/d' > test-changelog.txt
echo "Generated test changelog.txt:"
cat test-changelog.txt
# Verify it has content
if [ ! -s "test-changelog.txt" ]; then
echo "Error: Generated changelog is empty"
exit 1
fi
- name: Package validation
run: |
# Create a mock release package to ensure the packaging process works
mkdir -p release
mkdir -p release/jars
touch release/jars/Ramscoop.jar
# Generate changelog.txt for testing
sed 's/^## Version /Version /g' CHANGELOG.md | \
sed 's/^# .*//g' | \
sed 's/^- /- /g' | \
sed '/^$/N;/^\n$/d' > changelog.txt
for file in "mod_info.json" "settings.json" "README.md" "LICENSE.txt" "changelog.txt"; do
cp "$file" release/
done
cd release
zip -r "../Ramscoop-test.zip" ./*
cd ..
# Verify the zip was created and has content
if [ ! -f "Ramscoop-test.zip" ]; then
echo "Error: Failed to create test package"
exit 1
fi
echo "Package validation successful"