Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
commit b7809b9
Author: EpochFlame <[email protected]>
Date:   Mon Jan 1 10:52:02 2024 -0500

    fix missing files with workflow

commit 0cb6273
Author: EpochFlame <[email protected]>
Date:   Mon Jan 1 10:22:55 2024 -0500

    update workflow
  • Loading branch information
EpochFlame committed Jan 1, 2024
1 parent 17220af commit 9b42ea1
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 2 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,35 @@ jobs:
- name: Git config
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Build
run: make -j$(nproc) VERSION=${{matrix.version}} COMPILERS=/compilers/GC
run: |
python configure.py -m -v ${{matrix.version}} --compilers /compilers/GC --powerpc /opt/devkitpro/devkitPPC/bin
ninja
- name: Upload progress
if: github.ref == 'refs/heads/main'
continue-on-error: true
env:
PROGRESS_API_KEY: ${{secrets.PROGRESS_API_KEY}}
run: |
python tools/upload-progress.py -b https://progress.decomp.club/ -p pikmin -v ${{matrix.version}} \
build/pikmin.${{matrix.version}}/main.dol.progress
- name: Upload map
uses: actions/upload-artifact@v3
with:
name: pikmin-${{matrix.version}}.map
name: build-${{matrix.version}}.map
path: build/*/build.map

build_make:
name: Build (legacy)
runs-on: ubuntu-latest
container: ghcr.io/projectpiki/build:main
strategy:
fail-fast: false
matrix:
version: [usa.1]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Git config
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Build
run: make -j$(nproc) MAPGENFLAG=1 VERSION=${{matrix.version}} COMPILERS=/compilers/GC POWERPC=/opt/devkitpro/devkitPPC/bin
77 changes: 77 additions & 0 deletions tools/transform-dep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3
# borrowed from prime-decomp
import argparse
import os
from platform import uname
from typing import List

if os.name != 'nt':
wineprefix = os.environ.get('WINEPREFIX', os.path.join(os.environ['HOME'], '.wine'))
winedevices = os.path.join(wineprefix, 'dosdevices')


def in_wsl() -> bool:
# wsl1 has Microsoft, wsl2 has microsoft-standard
release = uname().release
return 'microsoft-standard' in release or 'Microsoft' in release


def convert_path(path: str) -> str:
# lowercase drive letter
path = path[0].lower() + path[1:]
if os.name == 'nt':
return path.replace('\\', '/')
elif path[0] == 'z':
# shortcut for z:
return path[2:].replace('\\', '/')
elif in_wsl():
if path.startswith(r'\\wsl'):
# first part could be wsl$ or wsl.localhost
pos = path.find('\\', 2)
pos = path.find('\\', pos + 1)
path = path[pos:]
return path.replace('\\', '/')
else:
path = path[0:1] + path[2:]
return os.path.join('/mnt', path.replace('\\', '/'))
else:
# use $WINEPREFIX/dosdevices to resolve path
return os.path.realpath(os.path.join(winedevices, path.replace('\\', '/')))


def import_d_file(in_file: str) -> str:
out_lines: List[str] = []

with open(in_file, 'r') as file:
it = iter(file)
line = next(it)
if line.endswith(' \\\n'):
out_lines.append(line[:-3].replace('\\', '/') + " \\\n")
else:
out_lines.append(line.replace('\\', '/'))

return ''.join(out_lines)


def main():
parser = argparse.ArgumentParser(
description="""Transform a .d file from Wine paths to normal paths"""
)
parser.add_argument(
"d_file",
help="""Dependency file in""",
)
parser.add_argument(
"d_file_out",
help="""Dependency file out""",
)
args = parser.parse_args()

output = import_d_file(args.d_file)

with open(args.d_file_out, "w", encoding="UTF-8") as f:
f.write(output)


if __name__ == "__main__":
main()
45 changes: 45 additions & 0 deletions tools/transform-win.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
import argparse

def import_d_file(in_file) -> str:
out_text = ''

with open(in_file) as file:
for idx, line in enumerate(file):
if idx != 0:
path_found_pos = line.find("include")
line = "\t" + line[path_found_pos:]
if line.endswith(' \\\n'):
out_text += line[:-3].replace('\\', '/') + " \\\n"
else:
out_text += line.replace('\\', '/')
else:
if line.endswith(' \\\n'):
out_text += line[:-3].replace('\\', '/') + " \\\n"
else:
out_text += line.replace('\\', '/')

return out_text

def main():
parser = argparse.ArgumentParser(
description="""Transform a .d file from Wine paths to normal paths"""
)
parser.add_argument(
"d_file",
help="""Dependency file in""",
)
parser.add_argument(
"d_file_out",
help="""Dependency file out""",
)
args = parser.parse_args()

output = import_d_file(args.d_file)

with open(args.d_file_out, "w", encoding="UTF-8") as f:
f.write(output)


if __name__ == "__main__":
main()
60 changes: 60 additions & 0 deletions tools/upload-progress.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/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": 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!")

0 comments on commit 9b42ea1

Please sign in to comment.