mirror of https://github.com/zeldaret/tp.git
TP Progress step for displaying (#350)
* d_a_obj_prop OK * tp-progress (#1) * Tp-progress-work-2 (#2) * seperate (#3)
This commit is contained in:
parent
2e6e468928
commit
9ba4267e6f
|
@ -0,0 +1,35 @@
|
|||
name: CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
WORKFLOW: "ci.yml"
|
||||
|
||||
jobs:
|
||||
download:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Get latest workflow run ID
|
||||
id: get_run_id
|
||||
run: |
|
||||
RUN_ID=$(curl --request GET \
|
||||
--url https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ env.WORKFLOW }}/runs \
|
||||
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
|
||||
--header 'content-type: application/json' | jq '.workflow_runs[0].id')
|
||||
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
|
||||
- name: Download artifact
|
||||
uses: dawidd6/action-download-artifact@v2.27.0
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run_id: ${{ steps.get_run_id.outputs.run_id }}
|
||||
name: artifact-${{ steps.get_run_id.outputs.run_id }}
|
||||
workflow: ${{ env.WORKFLOW }}
|
||||
- name: Upload Progress to Frogress
|
||||
env:
|
||||
PROGRESS_API_KEY: ${{ secrets.FROGRESS_API_KEY }}
|
||||
run: ./tools/upload-progress.py -b https://progress.deco.mp/ -p twilightprincess -v gcn_usa progress-${{ steps.get_run_id.outputs.run_id }}.json
|
|
@ -1,20 +1,27 @@
|
|||
name: OK Check
|
||||
name: CI
|
||||
|
||||
on: pull_request
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/pheenoh/zeldaret-tp:latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
token: ${{secrets.MY_REPO_PAT}}
|
||||
uses: actions/checkout@v3
|
||||
- name: Copy in dol and compilers
|
||||
run: cp /tmp/baserom.dol ./baserom.dol && cp -r /tmp/mwcc_compiler/ tools/mwcc_compiler && cp tools/mwcc_compiler/2.7/mwcceppc.exe tools/mwcc_compiler/2.7/mwcceppc_modded.exe && chown root /github/home/
|
||||
- name: Run Make (OK)
|
||||
run: make all rels && ./tp check --rels
|
||||
- name: Create JSON for Progress
|
||||
run: ./tp progress -f JSON > progress-${{ github.run_id }}.json
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: artifact-${{ github.run_id }}
|
||||
path: ./progress-${{ github.run_id }}.json
|
||||
|
47
tools/tp.py
47
tools/tp.py
|
@ -717,43 +717,16 @@ def calculate_progress(build_path: Path, matching: bool, format: str, print_rels
|
|||
)
|
||||
)
|
||||
elif format == "JSON":
|
||||
matching = {}
|
||||
non_matching = {}
|
||||
|
||||
matching["main.dol"] = {
|
||||
"decompiled": dol_progress.decompiled,
|
||||
"total": dol_progress.size,
|
||||
"sections": [
|
||||
{
|
||||
name: {
|
||||
"decompiled": sec.decompiled,
|
||||
"total": sec.size,
|
||||
}
|
||||
}
|
||||
for name, sec in dol_progress.sections.items()
|
||||
],
|
||||
}
|
||||
|
||||
if rels_progress:
|
||||
matching["rels"] = {
|
||||
"decompiled": rel_decompiled,
|
||||
"total": rel_size,
|
||||
}
|
||||
|
||||
for rel in rels_progress:
|
||||
matching[rel.name] = {
|
||||
"decompiled": rel.decompiled,
|
||||
"total": rel.size,
|
||||
}
|
||||
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
"matching": matching,
|
||||
"non-matchgin": non_matching,
|
||||
}
|
||||
)
|
||||
)
|
||||
# TODO: add dol sections instead of total dol.
|
||||
data = {
|
||||
"code": decompiled_size,
|
||||
"code/total": total_size,
|
||||
"dol": dol_progress.decompiled,
|
||||
"dol/total": dol_progress.size,
|
||||
"rels": rel_decompiled,
|
||||
"rels/total": rel_size,
|
||||
}
|
||||
print(json.dumps(data))
|
||||
else:
|
||||
print(dol_progress.percentage)
|
||||
print(100 * (rel_decompiled / rel_size))
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from pprint import pprint
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
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.replace('.', '-')]:
|
||||
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 "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": {
|
||||
"default": data,
|
||||
},
|
||||
})
|
||||
|
||||
print("Publishing entries to", url)
|
||||
pprint(entries)
|
||||
data = {
|
||||
"api_key": api_key,
|
||||
"entries": entries,
|
||||
}
|
||||
r = requests.post(url, json=data)
|
||||
r.raise_for_status()
|
||||
print("Done!")
|
Loading…
Reference in New Issue