From ba9db6542ebac3c4e94a1808d98a919fe395d4e8 Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Thu, 19 Sep 2024 21:42:07 -0400 Subject: [PATCH] Add CI --- .github/workflows/ci.yml | 55 ++++++++++++++++++++++++++++++++++++++++ tools/upload_frogress.py | 37 +++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100755 tools/upload_frogress.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8eb2ff6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: Build + +# Build on every branch push, tag push, and pull request change: +on: [push, pull_request_target] + +jobs: + build_repo: + name: Build repo (${{ matrix.version }}) + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + version: [us] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install package requirements + run: sudo apt-get install -y make git build-essential binutils-mips-linux-gnu gcc-mips-linux-gnu python3 python3-pip libfmt-dev libtoml11-dev + + - name: Install Python dependencies + run: pip3 install -r tools/requirements.txt + + - name: Install Splat dependencies + run: pip3 install -r tools/splat/requirements.txt + + - name: Get extra dependencies + uses: actions/checkout@v3 + with: + repository: ${{ secrets.SECRETREPO }} + token: ${{ secrets.SECRETTOKEN }} + path: deps_repo + - name: Get the dependency + run: cp deps_repo/baserom.${{ matrix.version }}.z64 baserom.${{ matrix.version }}.z64 + + - name: Setup + run: make setup -j $(nproc) + + - name: Build Banjo-Tooie + run: make -j $(nproc) + + - name: Print progress + run: python3 tools/progress.py --version ${{ matrix.version }} + + - name: Upload frogress + if: ${{ github.ref == 'refs/heads/master' && github.event_name != 'pull_request_target' }} + run: python3 tools/upload_frogress.py ${{ matrix.version }} --apikey ${{ secrets.PROGRESS_API_KEY }} + + - name: Upload map + uses: actions/upload-artifact@v3 + with: + name: banjotooie.${{ matrix.version }}.map + path: build/${{ matrix.version }}/banjotooie_decompressed.map diff --git a/tools/upload_frogress.py b/tools/upload_frogress.py new file mode 100755 index 0000000..0b0720a --- /dev/null +++ b/tools/upload_frogress.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +# Adapted from https://github.com/zeldaret/af/blob/main/tools/upload_frogress.py, original license is as follows: +# SPDX-FileCopyrightText: © 2023 ZeldaRET +# SPDX-License-Identifier: MIT + +from __future__ import annotations + +import argparse +import mapfile_parser +from pathlib import Path + +import progress + + +BASE_URL = "https://progress.deco.mp" +PROJECT = "tooie" + +def uploadProgressMain(): + parser = argparse.ArgumentParser() + parser.add_argument("version", help="Version slug") + parser.add_argument("--apikey", help="API key") + + args = parser.parse_args() + + version: str = args.version + apikey: str = args.apikey + mapPath = Path("build") / args.version / "banjotooie_decompressed.map" + + codeTotalStats, codeProgressPerFolder = progress.getProgress(mapPath, version) + codeEntries: dict[str, int] = mapfile_parser.frontends.upload_frogress.getFrogressEntriesFromStats(codeTotalStats, codeProgressPerFolder, verbose=True) + + url = mapfile_parser.utils.generateFrogressEndpointUrl(BASE_URL, PROJECT, version) + mapfile_parser.frontends.upload_frogress.uploadEntriesToFrogress(codeEntries, "code", url, apikey=apikey, verbose=True) + +if __name__ == '__main__': + uploadProgressMain()