Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump asm to a separate branch #1000

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/packages/build-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ COPY .github/packages/gen-pages/entrypoint.sh /usr/local/bin
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT entrypoint.sh

FROM linux-base AS dump-asm
VOLUME [ "/input", "/output" ]
COPY .github/packages/dump-asm/entrypoint.sh /usr/local/bin
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT entrypoint.sh

# TODO
FROM rust:latest AS check-issues
COPY .github/packages/check-issues/setup.sh /usr/local/bin
Expand Down
16 changes: 16 additions & 0 deletions .github/packages/dump-asm/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
set -e

git clone /input /tmp/input
cd /tmp/input
ln -s /opt/mwcc_compiler tools/

. /opt/venv/bin/activate
pip install --no-cache-dir -r requirements.txt

make -j"$(nproc)" WINE="$WINE" GENERATE_MAP=1 MAX_ERRORS=1
cp build/ssbm.us.1.2/GALE01.map /output/
python tools/parse_map.py
dadosod dol build/ssbm.us.1.2/main.dol \
-m build/map.csv \
-o /output
10 changes: 0 additions & 10 deletions .github/packages/gen-pages/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,5 @@ doxygen Doxyfile
touch build/doxygen/html/.nojekyll
python tools/m2ctx/m2ctx.py -pqr
melee-mwcc build/ctx.c -v -o build/ctx.c.o
make -j"$(nproc)" WINE="$WINE" GENERATE_MAP=1 MAX_ERRORS=1
mkdir build/doxygen/html/dump
cp build/ssbm.us.1.2/GALE01.map build/doxygen/html/dump/
python tools/parse_map.py
dadosod dol build/ssbm.us.1.2/main.dol \
-m build/map.csv \
-o build/doxygen/html/dump
python tools/dump_tree.py \
build/doxygen/html/dump \
build/doxygen/html/dump/index.html
cp build/ctx.html build/doxygen/html/
cp -r build/doxygen/html/* /output
93 changes: 93 additions & 0 deletions .github/workflows/dump-asm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
run-name: Dump assembly
name: dump-asm

on:
push:
paths: [ "**" ]
pull_request:

jobs:
dump-asm:
name: Dump assembly
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
steps:
- name: Get image name
env:
EVENT_NAME: ${{ github.event_name }}
PUSH_REPO_NAME: ${{ github.repository }}
PR_REPO_NAME: ${{ github.event.repository.full_name }}
IMAGE_SUFFIX: dump-asm:latest
shell: bash
run: |
result=""
case "$EVENT_NAME" in
push)
result="$PUSH_REPO_NAME"
;;
pull_request)
result="$PR_REPO_NAME"
;;
esac

result=$(echo "$result/$IMAGE_SUFFIX" | tr '[:upper:]' '[:lower:]')
echo "IMAGE=$result" >> $GITHUB_ENV

- name: Checkout Melee repository
uses: actions/checkout@v3

- name: Log into container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull assembly dump image
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE }}

- name: Dump assembly
run: |
docker run --rm \
--volume "$PWD:/input:ro" \
--volume /tmp/output:/output \
${{ env.REGISTRY }}/${{ env.IMAGE }}

- name: Upload dumped assembly
uses: actions/upload-artifact@v3
with:
name: dump
path: /tmp/output

push-dump:
name: Push dump
runs-on: ubuntu-latest
needs: dump-asm
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
concurrency:
group: "dump"
cancel-in-progress: true

steps:
- name: Download dumped assembly
uses: actions/download-artifact@v3
with:
name: dump
path: /tmp/output

- name: Checkout Melee repository
uses: actions/checkout@v4
with:
ref: dump

- name: Push to dump branch
run: |
rsync -r --delete --exclude '.git' /tmp/output/ .
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit --allow-empty \
--author "${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>" \
-m "Dump of ${{ github.sha }}"
git push
10 changes: 9 additions & 1 deletion .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
CONTAINERFILE: .github/packages/build-linux/Dockerfile
strategy:
matrix:
target: [ "build-linux", "gen-pages", "check-issues" ]
target: [ "build-linux", "gen-pages", "check-issues", "dump-asm" ]
fail-fast: false
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -94,6 +94,14 @@ jobs:
--volume /tmp/output:/output \
"$IMAGE:test"

- name: Try dumping assembly
if: matrix.target == 'dump-asm'
run: |
docker run --rm \
--volume "$PWD:/input:ro" \
--volume /tmp/output:/output \
"$IMAGE:test"

- name: Extract tags and labels
id: meta
uses: docker/metadata-action@v4
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ build.bat
clean.bat

# Other
src/m2ctx.py
expected/
dump/
/src/m2ctx.py
/expected/
/dump/
*.log

# Epilogue hack folder
Expand Down
Loading