Skip to content

En Garde, Avant Guard? #7754

En Garde, Avant Guard?

En Garde, Avant Guard? #7754

Workflow file for this run

# This is a workflow to perform basic verification for KoLmafia ASH scripts
name: CI
env:
SCRIPT_NAMES: "autoscend.ash auto_pre_adv.ash auto_post_adv.ash auto_choice_adv.ash relay_autoscend.ash autoscend_settings_extra.ash"
on: [push, pull_request]
jobs:
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Java 17
uses: actions/setup-java@v2
with:
distribution: "temurin"
java-version: "17"
- name: Determine KoLmafia version
id: mafia
run: |
set -o pipefail
export GITHUB_RELEASE=$(curl --fail --silent --globoff 'https://api.github.com/repos/kolmafia/kolmafia/releases/latest')
if [[ -z "$GITHUB_RELEASE" ]]; then
echo "Could not get KoLmafia latst release from GitHub!"
exit 1
fi
export GITHUB_BUILD=$(echo $GITHUB_RELEASE | jq --raw-output '.name')
export GITHUB_URL=$(echo $GITHUB_RELEASE | jq --raw-output '.assets[] | select(.browser_download_url | contains(".jar")).browser_download_url')
echo "::set-output name=github::$GITHUB_URL"
echo "GitHub URL = ${GITHUB_URL}"
echo "::set-output name=build::$GITHUB_BUILD"
echo "GitHub Mafia Build = ${GITHUB_BUILD}"
- name: Cache KoLmafia
id: cache
uses: actions/cache@v2
with:
path: .github/kolmafia.jar
key: kolmafia-${{steps.mafia.outputs.build}}
- name: Download KoLmafia
if: steps.cache.outputs.cache-hit != 'true'
run: |
curl -L "${{steps.mafia.outputs.github}}" --output .github/kolmafia.jar
- name: Install and verify
run: |
cd RELEASE
if [[ -f "dependencies.txt" ]]; then
# Install dependencies
echo "Installing dependencies..."
output_file="scripts/_ci_dependencies.ash"
while read -r line || [ -n "$line" ]; do
if [[ "$line" == *".git"* ]]; then
echo "cli_execute('git checkout ${line}');" >> "$output_file"
elif [[ "$line" == "github "* ]]; then
echo "cli_execute('git checkout ${line:7}');" >> "$output_file"
else
echo "cli_execute('svn checkout ${line}');" >> "$output_file"
fi
done < "dependencies.txt"
echo "cli_execute('exit');" >> "$output_file"
java -DuseCWDasROOT=true -jar ../.github/kolmafia.jar --CLI _ci_dependencies
fi
errors=0
for ashfile in ${SCRIPT_NAMES}; do
# Run the verification
echo "Verifying ${ashfile}..."
echo "try { cli_execute('verify ${ashfile}'); } finally { cli_execute('exit'); }" > scripts/_ci_verify.ash
output=$(java -DuseCWDasROOT=true -jar ../.github/kolmafia.jar --CLI _ci_verify)
if [[ $output == *"Script verification complete." ]]; then
echo "Verified ${ashfile}!"
else
echo $output
errors=$((errors+1))
fi
done
exit ${errors}