Skip to content

fix low-health alarm when using alternate energy HUD #672

fix low-health alarm when using alternate energy HUD

fix low-health alarm when using alternate energy HUD #672

Workflow file for this run

name: Makefile CI
on:
push:
branches: [ "main" ]
tags:
- '*'
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
strategy:
matrix:
config:
- zip-name: Randomizer Patches
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Copy game file
run: cp --no-preserve=mode $METROID_FUSION_U_PATH ./metroid4.gba
- name: Run make
run: make dist AS=armips FLIPS=flips BUILD_TYPE=release
- name: Remove ROM
run: rm ./bin/m4rs.gba
- name: Zip the patches up
run: zip -9 "${{ matrix.config.zip-name }}.zip" ./bin/*.ips ./bin/*.bps
- name: Upload patches as artifacts
uses: actions/upload-artifact@v4.0.0
with:
name: ${{ matrix.config.zip-name }}.zip
if-no-files-found: error
path: ${{ matrix.config.zip-name }}.zip
check_size:
runs-on: 'ubuntu-latest'
permissions: write-all
needs:
- build
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Unzip patches
run: |
mkdir ./patches
tree ./artifacts
unzip "./artifacts/Randomizer Patches.zip/Randomizer Patches.zip"
mv ./bin/*.ips ./patches
- name: Check patch sizes
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require("fs");
const path = require("path");
const ALLOW_LIST = [];
const THRESHOLD = 250;
let table_msg = "| File | Size (Bytes) |\n|-----|-----|\n";
let warnings = "";
const patch_path = "patches";
const files = fs.readdirSync(patch_path);
for (const file of files) {
const size = fs.statSync(path.join(patch_path, file)).size;
if (size >= THRESHOLD && !ALLOW_LIST.includes(file)) {
warnings += `- \`${file}\` (${size}B)\n`;
}
table_msg += `| ${file} | ${size} |\n`;
}
let final_message = "";
if (warnings) {
final_message += `⚠️ Big files detected: ⚠️\n${warnings}\n`;
}
final_message += "<details><summary>Expand for detailed file sizes</summary>\n<p>\n\n";
final_message += `${table_msg}`;
final_message += "\n\n</p>\n</details>";
console.log(final_message)
if (warnings) {
core.setFailed(`Big files detected.\n ${warnings}`);
}
if (context.eventName === "pull_request") {
// PRs and issues go over same endpoints
const {data: comments} = await github.rest.issues.listComments({repo: context.repo.repo, owner: context.repo.owner, issue_number: context.payload.pull_request.number});
const does_comment_exist = comments.find((c) => c.user.login === "github-actions[bot]");
if (does_comment_exist) {
core.info(`Comment ${does_comment_exist.id} in PR ${context.payload.pull_request.number} found, updating`);
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: does_comment_exist.id,
body: final_message,
});
}
else {
core.info(`Creating new comment on PR ${context.payload.pull_request.number}`);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: final_message,
});
}
}
release:
runs-on: 'ubuntu-latest'
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs:
- build
- check_size
permissions: write-all
steps:
- name: Download all the artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Create a Draft Release
uses: svenstaro/upload-release-action@2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
release_name: ${{ github.event.release.tag_name }}
file: artifacts/**
file_glob: true
tag: ${{ github.ref }}
draft: true
body: "Insert Changelog here"