From 1350a5b54246499084bd53579ec2d025cbea1756 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 14 Aug 2025 08:57:21 -0600 Subject: [PATCH] Add CI cache --- .github/workflows/build.yml | 41 +++++++++---------- tools/upload_progress.py | 79 ------------------------------------- 2 files changed, 18 insertions(+), 102 deletions(-) delete mode 100644 tools/upload_progress.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a77d4085..ffb76036 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,28 +19,36 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: + fetch-depth: 0 submodules: recursive - # Normalize file mod times - - name: restore timestamps - uses: chetan/git-restore-mtime-action@v2 - # Set Git config - name: Git config run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + # Normalize file mod times + - name: Restore timestamps + run: uv run https://raw.githubusercontent.com/MestreLion/git-tools/refs/tags/v2022.12/git-restore-mtime + # Copy the original files to the workspace - name: Prepare - run: cp -R /orig . + run: cp -a /orig . - # Restore any cached files + # Restore cached files - name: Cache build uses: actions/cache@v4 with: - path: build/${{ matrix.version }} - key: ${{ runner.os }}-${{ matrix.version }}-${{ hashFiles('configure.py', '.ninja_deps', 'build_scripts/**') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.version }}- + path: | + build + .ninja_deps + .ninja_log + include/PR/abi.h + include/PR/gbi.h + include/PR/gs2dex.h + include/PR/mbi.h + include/PR/ultratypes.h + include/compiler/gcc/stdlib.h + key: ${{ runner.os }}-${{ matrix.version }} # Build the project - name: Build @@ -50,19 +58,6 @@ jobs: ninja all_source build/${{ matrix.version }}/progress.json \ build/${{ matrix.version }}/report.json - # Upload progress if we're on the main branch - - name: Upload progress - if: github.ref == 'refs/heads/master' - continue-on-error: true - env: - PROGRESS_SLUG: animalcrossing - PROGRESS_API_KEY: ${{ secrets.PROGRESS_API_KEY }} - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} # for accessing github endpoints - run: | - python tools/upload_progress.py -b https://progress.decomp.club/ \ - -p $PROGRESS_SLUG -v ${{ matrix.version }} \ - build/${{ matrix.version }}/progress.json - # Upload map files - name: Upload map uses: actions/upload-artifact@v4 diff --git a/tools/upload_progress.py b/tools/upload_progress.py deleted file mode 100644 index dc61d156..00000000 --- a/tools/upload_progress.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 - -### -# Uploads progress information to https://github.com/decompals/frogress. -# -# Usage: -# python3 tools/upload_progress.py -b https://progress.decomp.club/ -p [project] -v [version] build/[version]/progress.json -# -# If changes are made, please submit a PR to -# https://github.com/encounter/dtk-template -### - -import argparse -import json -import os -import requests -import subprocess -import sys - - -def get_git_commit_timestamp() -> int: - return int( - subprocess.check_output(["git", "show", "-s", "--format=%ct"]) - .decode("ascii") - .rstrip() - ) - - -def get_git_commit_sha() -> str: - return subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii").strip() - - -def generate_url(args: argparse.Namespace) -> str: - url_components = [args.base_url.rstrip("/"), "data"] - - for arg in [args.project, args.version]: - if arg != "": - url_components.append(arg) - - return str.join("/", url_components) + "/" - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Upload progress information.") - parser.add_argument("-b", "--base_url", help="API base URL", required=True) - parser.add_argument("-a", "--api_key", help="API key (env var PROGRESS_API_KEY)") - parser.add_argument("-p", "--project", help="Project slug", required=True) - parser.add_argument("-v", "--version", help="Version slug", required=True) - parser.add_argument("input", help="Progress JSON input") - - args = parser.parse_args() - api_key = args.api_key or os.environ.get("PROGRESS_API_KEY") - if not api_key: - raise KeyError("API key required") - url = generate_url(args) - - entries = [] - with open(args.input, "r") as f: - data = json.load(f) - entries.append( - { - "timestamp": get_git_commit_timestamp(), - "git_hash": get_git_commit_sha(), - "categories": data, - } - ) - - print("Publishing entry to", url) - json.dump(entries[0], sys.stdout, indent=4) - print() - r = requests.post( - url, - json={ - "api_key": api_key, - "entries": entries, - }, - ) - r.raise_for_status() - print("Done!")