diff --git a/.github/packages/build-linux/Dockerfile b/.github/packages/build-linux/Dockerfile index adce38144a..c3acd53b84 100644 --- a/.github/packages/build-linux/Dockerfile +++ b/.github/packages/build-linux/Dockerfile @@ -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 diff --git a/.github/packages/dump-asm/entrypoint.sh b/.github/packages/dump-asm/entrypoint.sh new file mode 100644 index 0000000000..e73bec3f4b --- /dev/null +++ b/.github/packages/dump-asm/entrypoint.sh @@ -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 diff --git a/.github/packages/gen-pages/entrypoint.sh b/.github/packages/gen-pages/entrypoint.sh index 1c028b820a..d9420edf9f 100644 --- a/.github/packages/gen-pages/entrypoint.sh +++ b/.github/packages/gen-pages/entrypoint.sh @@ -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 diff --git a/.github/workflows/dump-asm.yml b/.github/workflows/dump-asm.yml new file mode 100644 index 0000000000..b9359f5672 --- /dev/null +++ b/.github/workflows/dump-asm.yml @@ -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 diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index e078977530..61d321f641 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -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: @@ -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 diff --git a/.gitignore b/.gitignore index 548b7d19d4..e0e2b44a0d 100644 --- a/.gitignore +++ b/.gitignore @@ -30,9 +30,9 @@ build.bat clean.bat # Other -src/m2ctx.py -expected/ -dump/ +/src/m2ctx.py +/expected/ +/dump/ *.log # Epilogue hack folder