From fbfc94e829174cdb15690ecb320f86c303a6f836 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Mon, 6 Mar 2023 08:59:07 -0500 Subject: [PATCH] Publish packages for building Melee and generating documentation (#752) --- .dockerignore | 4 + .github/packages/build-linux/Dockerfile | 25 +++ .github/packages/build-linux/entrypoint.sh | 20 ++ .github/packages/build-linux/setup.sh | 26 +++ .github/packages/build-windows/Dockerfile | 35 +++ .github/packages/build-windows/entrypoint.ps1 | 49 +++++ .github/packages/build-windows/setup.ps1 | 68 ++++++ .github/packages/gen-pages/Dockerfile | 10 + .github/packages/gen-pages/entrypoint.sh | 16 ++ .github/packages/gen-pages/setup.sh | 21 ++ .github/workflows/build-melee.yml | 134 ++++++++++++ .github/workflows/build.yml | 92 -------- .github/workflows/publish-packages.yml | 207 ++++++++++++++++++ .github/workflows/publish-pages.yml | 92 ++++++++ .github/workflows/publish.yml | 69 ------ Makefile | 18 +- tools/calcprogress/requirements.txt | 1 + tools/calcprogress/src/requirements.txt | 1 + 18 files changed, 718 insertions(+), 170 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/packages/build-linux/Dockerfile create mode 100644 .github/packages/build-linux/entrypoint.sh create mode 100644 .github/packages/build-linux/setup.sh create mode 100644 .github/packages/build-windows/Dockerfile create mode 100644 .github/packages/build-windows/entrypoint.ps1 create mode 100644 .github/packages/build-windows/setup.ps1 create mode 100644 .github/packages/gen-pages/Dockerfile create mode 100644 .github/packages/gen-pages/entrypoint.sh create mode 100644 .github/packages/gen-pages/setup.sh create mode 100644 .github/workflows/build-melee.yml delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/publish-packages.yml create mode 100644 .github/workflows/publish-pages.yml delete mode 100644 .github/workflows/publish.yml create mode 100644 tools/calcprogress/requirements.txt create mode 100644 tools/calcprogress/src/requirements.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..ca7cd5a39 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +**/.git/ +**/__pycache/ +**/venv/ +**/.idea/ diff --git a/.github/packages/build-linux/Dockerfile b/.github/packages/build-linux/Dockerfile new file mode 100644 index 000000000..1c0154d13 --- /dev/null +++ b/.github/packages/build-linux/Dockerfile @@ -0,0 +1,25 @@ +FROM ubuntu:latest AS build-linux +ARG WIBO_PATH="/usr/local/sbin/wibo" +COPY --from=ghcr.io/decompals/wibo:latest \ + ${WIBO_PATH} \ + ${WIBO_PATH} +ARG DEVKITPRO=/opt/devkitpro +ARG DEVKITPPC=${DEVKITPRO}/devkitPPC +COPY --from=devkitpro/devkitppc:latest \ + ${DEVKITPPC}/bin/powerpc-eabi-as \ + ${DEVKITPPC}/bin/powerpc-eabi-as +COPY .github/packages/build-linux/setup.sh /usr/local/bin +ENV DEBIAN_FRONTEND=noninteractive +ENV LANG=C +ENV MELEE_COMPILERS_URL="https://cdn.discordapp.com/attachments/727909624342380615/1079286377230909440/MELEE_COMPILERS.zip" +RUN chmod +x /usr/local/bin/setup.sh && setup.sh +VOLUME [ "/input", "/output" ] +ENV WINE=${WIBO_PATH} +ENV DEVKITPRO=${DEVKITPRO} +ENV DEVKITPPC=${DEVKITPPC} +ENV PATH="$DEVKITPRO/tools/bin:$PATH" +ENV PATH="$DEVKITPPC/bin:$PATH" +ENV MAKE_FLAGS="GENERATE_MAP=1" +COPY .github/packages/build-linux/entrypoint.sh /usr/local/bin +RUN chmod +x /usr/local/bin/entrypoint.sh +ENTRYPOINT entrypoint.sh diff --git a/.github/packages/build-linux/entrypoint.sh b/.github/packages/build-linux/entrypoint.sh new file mode 100644 index 000000000..e9786ac07 --- /dev/null +++ b/.github/packages/build-linux/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +git clone /input /tmp/input +cd /tmp/input +ln -s /opt/mwcc_compiler tools/ + +echo "$MAKE_FLAGS" | + xargs make -j"$(nproc)" WINE="$WINE" + +if [ -f "build/ssbm.us.1.2/GALE01.map" ]; then + python tools/calcprogress/calcprogress.py \ + --dol build/ssbm.us.1.2/main.dol \ + --map build/ssbm.us.1.2/GALE01.map \ + --asm-obj-ext .s.o \ + --old-map true \ + >build/PROGRESS.md +fi + +cp -r build/* /output diff --git a/.github/packages/build-linux/setup.sh b/.github/packages/build-linux/setup.sh new file mode 100644 index 000000000..2ffad1768 --- /dev/null +++ b/.github/packages/build-linux/setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -e + +apt update + +apt install -y --no-install-recommends \ + git \ + make \ + gcc \ + libc6-dev \ + python3-full \ + python-is-python3 \ + curl \ + libarchive-tools + +curl -L "$MELEE_COMPILERS_URL" | + bsdtar -xvf- -C /tmp +mv /tmp/GC /tmp/mwcc_compiler +mv /tmp/mwcc_compiler /opt + +apt remove -y \ + curl \ + libarchive-tools +apt autoremove -y +apt clean +rm -rf /var/lib/apt/lists/* diff --git a/.github/packages/build-windows/Dockerfile b/.github/packages/build-windows/Dockerfile new file mode 100644 index 000000000..fc3f4d02b --- /dev/null +++ b/.github/packages/build-windows/Dockerfile @@ -0,0 +1,35 @@ +# Unlike our Linux packages, the only reason for this to exist is to smoke test +# our developer experience for Windows users. As such, it does things like install +# a Python venv and our requirements.txt packages, without actually using them, +# and it doesn't generate our documentation pages or output PROGRESS.md. +# It's also excruciatingly slow, both to build the package and to build melee. +# +# Note: Microsoft does not offer a "latest" (or equivalent) tag, instead they +# offer year-specific LTSC releases that seem to roughly match the cadence of +# Visual Studio releases (every three years or so). +FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS build-windows +# PowerShell 5.1 is included in Windows Server and should mirror a fresh +# install of Windows 10/11. By default, PowerShell doesn't exit when a command +# fails so we need to set those options. Also note that even with these +# settings, it will not exit when a native command (exe) fails, so in the +# scripts we need to check the error code and exit if it's not 0, every time. +# There is an experimental fix to this but it's only available in PowerShell 7: +# https://github.com/PowerShell/PowerShell/issues/3996 +SHELL [ "powershell", "-command", \ + "Set-StrictMode -Version 'Latest'; \ + $ErrorActionPreference = 'Stop';" ] +# "C:/Windows/system32/WindowsPowerShell/v1.0/" is on PATH by default +COPY .github/packages/build-windows/setup.ps1 \ + C:/Windows/system32/WindowsPowerShell/v1.0/ +COPY .github/packages/build-windows/entrypoint.ps1 \ + C:/Windows/system32/WindowsPowerShell/v1.0/ +COPY requirements.txt C:/Windows/Temp +# on Windows we support a fully unprivileged installation +RUN net user melee /add; \ + # grant melee user read access to requirements.txt + icacls 'C:/Windows/Temp/requirements.txt' /grant 'melee:(R)'; +USER melee +ENV MELEE_COMPILERS_URL="https://cdn.discordapp.com/attachments/727909624342380615/1079286377230909440/MELEE_COMPILERS.zip" +RUN setup.ps1 +VOLUME [ "C:/Input", "C:/Output" ] +ENTRYPOINT entrypoint.ps1 diff --git a/.github/packages/build-windows/entrypoint.ps1 b/.github/packages/build-windows/entrypoint.ps1 new file mode 100644 index 000000000..91fa67427 --- /dev/null +++ b/.github/packages/build-windows/entrypoint.ps1 @@ -0,0 +1,49 @@ +#!/usr/bin/env pwsh + +# clone into temp directory for write access +& { + $inDir = New-Item -ItemType Directory -Path (Join-Path $env:Temp 'Input') + & git clone 'C:/Input' $inDir + if ($LASTEXITCODE -ne 0) + { + Exit $LASTEXITCODE + } + + Set-Location $inDir +} + +$data = Join-Path $env:LocalAppData 'Melee' -Resolve + +# source the venv and restore python requirements +# +# The container image's venv will already have these installed, but if +# requirements.txt has changed since it was built, this will sync the packages. +& { + & (Join-Path $data 'venv/Scripts/Activate.ps1' -Resolve) + + # https://github.com/pypa/pip/issues/8559#issue-653473661 + & pip3 install --no-cache-dir -r 'requirements.txt' --use-pep517 + if ($LASTEXITCODE -ne 0) + { + Exit $LASTEXITCODE + } +} + +& { + # copy compilers to expected location + Copy-Item -Path (Join-Path $data 'mwcc_compiler' -Resolve) ` + -Destination 'tools/mwcc_compiler' -Recurse + + # run make + # + # Our Makefile doesn't support cmd or PowerShell, so we're calling it from + # the bash executable installed by MinGW. + & bash -c 'make -j"$NUMBER_OF_PROCESSORS" "$MAKE_FLAGS"' + if ($LASTEXITCODE -ne 0) + { + Exit $LASTEXITCODE + } + + # copy to output volume + Copy-Item -Path 'build/*' -Destination 'C:/Output' -Recurse +} diff --git a/.github/packages/build-windows/setup.ps1 b/.github/packages/build-windows/setup.ps1 new file mode 100644 index 000000000..d1be241f7 --- /dev/null +++ b/.github/packages/build-windows/setup.ps1 @@ -0,0 +1,68 @@ +#!/usr/bin/env pwsh + +# install packages with scoop +# +# Compared to Chocolatey, scoop is newer and is FOSS (dual Unlicense/MIT). +# +# Winget, while built into Windows, requires Windows Store shenanigans just to +# install and doesn't provide as many packages yet. +# +# It's also not supported on Windows Server, which this container requires: +# https://github.com/microsoft/winget-cli/issues/754#issuecomment-902798802 +# +# However, because this container image is meant to smoke test our Windows DX, +# we should revisit winget later when it's more promoted by Microsoft. +& { + Set-ExecutionPolicy RemoteSigned -Scope CurrentUser + Invoke-RestMethod get.scoop.sh | Invoke-Expression + + & scoop install ` + git ` + python ` + mingw + if ($LASTEXITCODE -ne 0) + { + Exit $LASTEXITCODE + } +} + +$data = New-Item -Path "$env:LocalAppData/Melee" -ItemType Directory + +& { + # create a venv for our Python tooling + $venvPath = Join-Path $data 'venv' + & python -m venv --upgrade-deps $venvPath + if ($LASTEXITCODE -ne 0) + { + Exit $LASTEXITCODE + } + + & (Join-Path $venvPath 'Scripts/Activate.ps1' -Resolve) + + # https://github.com/pypa/pip/issues/8559#issue-653473661 + & pip install --no-cache-dir -r 'C:/Windows/Temp/requirements.txt' --use-pep517 + if ($LASTEXITCODE -ne 0) + { + Exit $LASTEXITCODE + } +} + +# download and save melee compilers +& { + $tmp = New-TemporaryFile + Invoke-WebRequest -Uri "$env:MELEE_COMPILERS_URL" -OutFile $tmp + # Expand-Archive won't unzip it if its extension isn't .zip lol + $zip = Rename-Item $tmp -NewName ($tmp.BaseName + '.zip') -PassThru + + $dir = New-Item -ItemType Directory ` + -Path (Join-Path $env:Temp 'MELEE_COMPILERS') + + Expand-Archive -Path $zip -DestinationPath $dir + + $path = Get-ChildItem -Path $dir.FullName | ` + Select-Object -ExpandProperty FullName + Copy-Item -Path $path -Destination "$data/mwcc_compiler" -Recurse + + Remove-Item -Force $zip + Remove-Item -Recurse -Force $dir +} diff --git a/.github/packages/gen-pages/Dockerfile b/.github/packages/gen-pages/Dockerfile new file mode 100644 index 000000000..7ec934d82 --- /dev/null +++ b/.github/packages/gen-pages/Dockerfile @@ -0,0 +1,10 @@ +FROM ubuntu:latest AS gen-pages +COPY .github/packages/gen-pages/setup.sh /usr/local/bin +COPY requirements.txt /tmp/ +ENV DEBIAN_FRONTEND=noninteractive +ENV LANG=C +RUN chmod +x /usr/local/bin/setup.sh && setup.sh +VOLUME [ "/input", "/output" ] +COPY .github/packages/gen-pages/entrypoint.sh /usr/local/bin +RUN chmod +x /usr/local/bin/entrypoint.sh +ENTRYPOINT entrypoint.sh diff --git a/.github/packages/gen-pages/entrypoint.sh b/.github/packages/gen-pages/entrypoint.sh new file mode 100644 index 000000000..1d949e5b6 --- /dev/null +++ b/.github/packages/gen-pages/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +git clone /input /tmp/input +cd /tmp/input + +. /opt/venv/bin/activate +pip install --no-cache-dir -r requirements.txt + +mkdir -p build/doxygen +ln -s /opt/doxygen-awesome-css tools/ +doxygen Doxyfile +touch build/doxygen/html/.nojekyll +python tools/m2ctx/m2ctx.py -pqr +cp build/ctx.html build/doxygen/html/ +cp -r build/doxygen/html/* /output diff --git a/.github/packages/gen-pages/setup.sh b/.github/packages/gen-pages/setup.sh new file mode 100644 index 000000000..a133073b6 --- /dev/null +++ b/.github/packages/gen-pages/setup.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +apt update + +apt install -y --no-install-recommends \ + git \ + doxygen \ + python3-full \ + python-is-python3 + +python -m venv --upgrade-deps /opt/venv +. /opt/venv/bin/activate +pip install --no-cache-dir -r /tmp/requirements.txt + +git clone 'https://github.com/jothepro/doxygen-awesome-css' --depth=1 \ + /opt/doxygen-awesome-css + +apt autoremove -y +apt clean +rm -rf /var/lib/apt/lists/* diff --git a/.github/workflows/build-melee.yml b/.github/workflows/build-melee.yml new file mode 100644 index 000000000..26efcdaf4 --- /dev/null +++ b/.github/workflows/build-melee.yml @@ -0,0 +1,134 @@ +name: build-melee +run-name: Build Melee + +on: + push: + paths: [ "**" ] + pull_request: + +jobs: + build-linux: + name: Linux + runs-on: ubuntu-latest + env: + REGISTRY: ghcr.io + strategy: + matrix: + make_flags: ["GENERATE_MAP=1", "NON_MATCHING=1"] + fail-fast: false + + 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: build-linux:latest + run: | + result="" + case "$EVENT_NAME" in + push) + result="$PUSH_REPO_NAME" + ;; + pull_request) + result="$PR_REPO_NAME" + ;; + esac + echo "IMAGE=$result/$IMAGE_SUFFIX" >> $GITHUB_ENV + + - name: Checkout Melee repository + uses: actions/checkout@v3 + + - name: Log into container registry + uses: docker/login-action@v2.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pull build image + run: docker pull "$REGISTRY/$IMAGE" + + - name: Build Melee + env: + MAKE_FLAGS: ${{ matrix.make_flags }} + run: | + docker run --rm \ + --volume "$PWD:/input:ro" \ + --volume /tmp/output:/output \ + --env MAKE_FLAGS="$MAKE_FLAGS" \ + "$REGISTRY/$IMAGE" + + - name: Upload map + if: matrix.make_flags == 'GENERATE_MAP=1' + uses: actions/upload-artifact@v3 + with: + name: GALE01.map + path: /tmp/output/ssbm.us.1.2/GALE01.map + + - name: Set step summary + if: matrix.make_flags == 'GENERATE_MAP=1' + run: cat /tmp/output/PROGRESS.md >> $GITHUB_STEP_SUMMARY + + build-windows: + name: Windows + runs-on: windows-latest + env: + REGISTRY: ghcr.io + MAKE_FLAGS: ${{ matrix.make_flags }} + strategy: + matrix: + make_flags: ["GENERATE_MAP=1", "NON_MATCHING=1"] + fail-fast: false + + 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: build-windows:latest + shell: bash + run: | + result="" + case "$EVENT_NAME" in + push) + result="$PUSH_REPO_NAME" + ;; + pull_request) + result="$PR_REPO_NAME" + ;; + esac + echo "IMAGE=$result/$IMAGE_SUFFIX" >> $GITHUB_ENV + + - name: Checkout Melee repository + uses: actions/checkout@v3 + + - name: Log into container registry + uses: docker/login-action@v2.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pull build image + shell: bash + run: docker pull "$REGISTRY/$IMAGE" + + - name: Build Melee + env: + MAKE_FLAGS: ${{ matrix.make_flags }} + run: | + $output = New-Item ` + -Path "$env:TEMP/Output" ` + -ItemType Directory ` + -Force + + # the container's user needs to be able to write to the runner's dir + icacls $output /T /grant 'Everyone:(OI)(CI)(F)' + + docker run --rm ` + --volume "${PWD}:C:/Input:ro" ` + --volume "${output}:C:/Output" ` + --env MAKE_FLAGS="$env:MAKE_FLAGS" ` + "$env:REGISTRY/$env:IMAGE" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 7cf883871..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Build - -on: - push: - pull_request: - -jobs: - build-ubuntu: - strategy: - matrix: - makeflags: ["GENERATE_MAP=1", "NON_MATCHING=1"] - runs-on: ubuntu-22.04 - container: devkitpro/devkitppc:20230110 - steps: - - name: Install GCC - uses: awalsh128/cache-apt-pkgs-action@v1.2.4 - with: - packages: build-essential libc6-dev - version: 1.0.0 - - name: Checkout Melee repo - uses: actions/checkout@v3 - - name: Download WiBo - shell: bash - run: | - curl -L 'https://github.com/decompals/wibo/releases/download/0.4.1/wibo' \ - -o tools/wibo - sha1sum -c <(echo "23f5eee8793f7bb93a1a5de4380d153bc360f7b0 tools/wibo") - chmod +x tools/wibo - - name: Download compilers - run: | - curl -L 'https://cdn.discordapp.com/attachments/727909624342380615/1079286377230909440/MELEE_COMPILERS.zip' \ - | bsdtar -xvf- -C tools - mv tools/GC tools/mwcc_compiler - - name: Build Melee - run: | - make \ - WINE=./tools/wibo \ - -j$(nproc) \ - ${{ matrix.makeflags }} - - name: Upload map - if: matrix.makeflags == 'GENERATE_MAP=1' - uses: actions/upload-artifact@v3 - with: - name: GALE01.map - path: build/ssbm.us.1.2/GALE01.map - - name: Calc progress - if: matrix.makeflags == 'GENERATE_MAP=1' - run: | - python3 tools/calcprogress/calcprogress.py \ - --dol build/ssbm.us.1.2/main.dol \ - --map build/ssbm.us.1.2/GALE01.map \ - --asm-obj-ext .s.o \ - --old-map true \ - >> $GITHUB_STEP_SUMMARY - - build-windows: - strategy: - matrix: - makeflags: ["GENERATE_MAP=1", "NON_MATCHING=1"] - runs-on: windows-2022 - steps: - - name: Checkout Melee repo - uses: actions/checkout@v3 - - name: Download compilers - run: | - $uri = "https://cdn.discordapp.com/attachments/727909624342380615/1079286377230909440/MELEE_COMPILERS.zip" - $zip = New-TemporaryFile - - Invoke-WebRequest -Uri $uri -OutFile $zip - $target = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "MELEE_COMPILERS") - Expand-Archive -LiteralPath $zip.FullName -DestinationPath $target.FullName - - $path = Get-ChildItem -Path $target.FullName | Select-Object -ExpandProperty FullName - Copy-Item -Path $path -Destination "tools\mwcc_compiler" -Recurse - - $zip | Remove-Item -Force - $target | Remove-Item -Recurse -Force - - name: Build Melee - run: - make WINDOWS=1 ` - AS=".\tools\mwcc_compiler\powerpc-eabi-as.exe" ` - -j "$env:NUMBER_OF_PROCESSORS" ` - ${{ matrix.makeflags }} - - name: Calc progress - if: matrix.makeflags == 'GENERATE_MAP=1' - run: | - python3 tools/calcprogress/calcprogress.py ` - --dol build/ssbm.us.1.2/main.dol ` - --map build/ssbm.us.1.2/GALE01.map ` - --asm-obj-ext .s.o ` - --old-map true ` - >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml new file mode 100644 index 000000000..df02427bb --- /dev/null +++ b/.github/workflows/publish-packages.yml @@ -0,0 +1,207 @@ +name: publish-packages +run-name: Publish packages + +on: + push: + paths: + - .github/workflows/publish-packages.yml + - .github/packages/** + pull_request: + paths: + - .github/workflows/publish-packages.yml + - .github/packages/** + schedule: + # Monday at 5am EST + - cron: "0 10 * * 1" + +concurrency: + group: "packages" + cancel-in-progress: true + +jobs: + build-linux: + name: Publish package + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}/${{ matrix.target }} + CONTAINERFILE: .github/packages/${{ matrix.target }}/Dockerfile + strategy: + matrix: + target: [ "build-linux", "gen-pages" ] + fail-fast: false + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build package + id: build + uses: docker/build-push-action@v4 + with: + context: . + file: ${{ env.CONTAINERFILE }} + target: ${{ matrix.target }} + load: true + tags: ${{ env.IMAGE_NAME }}:test + + - name: Try building Melee (GENERATE_MAP=1) + if: startsWith(matrix.target, 'build-') + run: | + docker run --rm \ + --volume "$PWD:/input:ro" \ + --volume /tmp/output/generate_map:/output \ + --env MAKE_FLAGS="GENERATE_MAP=1" \ + "$IMAGE_NAME:test" + + - name: Try building Melee (NON_MATCHING=1) + if: startsWith(matrix.target, 'build-') + run: | + docker run --rm \ + --volume "$PWD":/input:ro \ + --volume /tmp/output/non_matching:/output \ + --env MAKE_FLAGS="NON_MATCHING=1" \ + "$IMAGE_NAME:test" + + - name: Try generating pages + if: matrix.target == 'gen-pages' + run: | + docker run --rm \ + --volume "$PWD:/input:ro" \ + --volume /tmp/output:/output \ + "$IMAGE_NAME:test" + + - name: Extract tags and labels + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,priority=1000,value=latest,enable={{is_default_branch}} + type=schedule,pattern={{date 'YYYYMMDD'}} + type=ref,event=branch + type=ref,event=pr + type=edge + type=sha + + - name: Log into container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push package + uses: docker/build-push-action@v4 + if: github.event_name == 'push' + with: + context: . + file: ${{ env.CONTAINERFILE }} + target: ${{ matrix.target }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + build-windows: + name: Publish package + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}/${{ matrix.target }} + CONTAINERFILE: .github/packages/${{ matrix.target }}/Dockerfile + strategy: + matrix: + target: [ "build-windows" ] + fail-fast: false + runs-on: windows-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # build-push-action and buildx are not supported on Windows hosts + - name: Build package + env: + IMAGE_TARGET: ${{ matrix.target }} + shell: bash + run: | + docker build \ + --target "$IMAGE_TARGET" \ + --tag "$IMAGE_NAME:test" \ + --file "$CONTAINERFILE" \ + . + + - name: Try building Melee (GENERATE_MAP=1) + if: startsWith(matrix.target, 'build-') + run: | + $output = New-Item ` + -Path "$env:TEMP/Output/GenerateMap" ` + -ItemType Directory ` + -Force + + # the container's user needs to be able to write to the runner's dir + icacls $output /T /grant 'Everyone:(OI)(CI)(F)' + + docker run --rm ` + --volume "${PWD}:C:/Input:ro" ` + --volume "${output}:C:/Output" ` + --env MAKE_FLAGS="GENERATE_MAP=1" ` + "${env:IMAGE_NAME}:test" + + - name: Try building Melee (NON_MATCHING=1) + if: startsWith(matrix.target, 'build-') + run: | + $output = New-Item ` + -Path "$env:TEMP/Output/NonMatching" ` + -ItemType Directory ` + -Force + + # the container's user needs to be able to write to the runner's dir + icacls $output /T /grant 'Everyone:(OI)(CI)(F)' + + docker run --rm ` + --volume "${PWD}:C:/Input:ro" ` + --volume "${output}:C:/Output" ` + --env MAKE_FLAGS="NON_MATCHING=1" ` + ${env:IMAGE_NAME}:test + + - name: Extract tags and labels + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,priority=1000,value=latest,enable={{is_default_branch}} + type=schedule,pattern={{date 'YYYYMMDD'}} + type=ref,event=branch + type=ref,event=pr + type=edge + type=sha + + - name: Log into container registry + uses: docker/login-action@v2.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push package + if: github.event_name == 'push' + shell: bash + run: | + echo $( + echo "$DOCKER_METADATA_OUTPUT_TAGS" | xargs -I{} echo --tag \'{}\' + echo "$DOCKER_METADATA_OUTPUT_LABELS" | xargs -I{} echo --label \'{}\' + ) | xargs docker build -f "$CONTAINERFILE" . + docker push --all-tags "$REGISTRY/$IMAGE_NAME" diff --git a/.github/workflows/publish-pages.yml b/.github/workflows/publish-pages.yml new file mode 100644 index 000000000..d9360ca20 --- /dev/null +++ b/.github/workflows/publish-pages.yml @@ -0,0 +1,92 @@ +run-name: Publish GitHub pages +name: publish-pages + +on: + push: + paths: [ "**" ] + pull_request: + +jobs: + # Single deploy job since we're just deploying + gen-pages: + name: Generate pages + 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: gen-pages:latest + shell: bash + run: | + result="" + case "$EVENT_NAME" in + push) + result="$PUSH_REPO_NAME" + ;; + pull_request) + result="$PR_REPO_NAME" + ;; + esac + echo "IMAGE=$result/$IMAGE_SUFFIX" >> $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 generator image + run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE }} + + - name: Generate pages + run: | + docker run --rm \ + --volume "$PWD:/input:ro" \ + --volume /tmp/output:/output \ + ${{ env.REGISTRY }}/${{ env.IMAGE }} + + - name: Upload generated pages + uses: actions/upload-artifact@v3 + with: + name: pages + path: /tmp/output + + deploy-pages: + name: Deploy to GitHub Pages + runs-on: ubuntu-latest + needs: gen-pages + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' + concurrency: + group: "pages" + cancel-in-progress: true + permissions: + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Download generated pages + uses: actions/download-artifact@v3 + with: + name: pages + path: /tmp/output + + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@v1.0.7 + with: + path: /tmp/output + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1.2.4 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 6472ded1c..000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: Publish - -on: - push: - branches: - - master - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow one concurrent deployment -concurrency: - group: "pages" - cancel-in-progress: true - -jobs: - # Single deploy job since we're just deploying - publish: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - submodules: "true" - - - name: Checkout Doxygen Awesome repo - uses: actions/checkout@v3 - with: - repository: jothepro/doxygen-awesome-css - path: tools/doxygen-awesome-css - - - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: doxygen graphviz - version: 1.0 - - - name: Create build directory - run: mkdir -p build/doxygen - - - name: Generate Doxygen documentation - run: doxygen Doxyfile - shell: bash - - - name: Create .nojekyll (ensures pages with underscores work on gh pages) - run: touch build/doxygen/html/.nojekyll - shell: bash - - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - cache: 'pip' - - run: pip install -r requirements.txt - - run: python tools/m2ctx/m2ctx.py -pqr - - run: cp build/ctx.html build/doxygen/html - - - name: Upload GitHub Pages artifact - uses: actions/upload-pages-artifact@v1.0.5 - with: - path: build/doxygen/html - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 diff --git a/Makefile b/Makefile index 5bb1435ed..2e0f8c0f5 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,3 @@ -ifneq ($(findstring MINGW,$(shell uname)),) - WINDOWS := 1 -endif -ifneq ($(findstring MSYS,$(shell uname)),) - WINDOWS := 1 -endif GENERATE_MAP ?= 0 NON_MATCHING ?= 0 @@ -56,7 +50,7 @@ endif MWCC_LD_VERSION := 1.1 # Programs -ifeq ($(WINDOWS),1) +ifeq ($(OS),Windows_NT) WINE := else WINE ?= wine @@ -70,7 +64,13 @@ ifeq ($(shell uname),Darwin) else SHA1SUM := sha1sum endif -AS := $(DEVKITPPC)/bin/powerpc-eabi-as + +ifeq ($(OS),Windows_NT) + AS := $(WINE) tools/mwcc_compiler/powerpc-eabi-as.exe +else + AS := $(DEVKITPPC)/bin/powerpc-eabi-as +endif + CC := $(WINE) tools/mwcc_compiler/$(MWCC_VERSION)/mwcceppc.exe ifeq ($(EPILOGUE_PROCESS),1) CC_EPI = $(WINE) tools/mwcc_compiler/$(MWCC_EPI_VERSION)/$(MWCC_EPI_EXE) @@ -78,7 +78,7 @@ endif LD := $(WINE) tools/mwcc_compiler/$(MWCC_LD_VERSION)/mwldeppc.exe ELF2DOL := tools/elf2dol HOSTCC := gcc -PYTHON := python3 +PYTHON := python FORMAT := clang-format -i -style=file FRANK := tools/frank.py diff --git a/tools/calcprogress/requirements.txt b/tools/calcprogress/requirements.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tools/calcprogress/requirements.txt @@ -0,0 +1 @@ + diff --git a/tools/calcprogress/src/requirements.txt b/tools/calcprogress/src/requirements.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tools/calcprogress/src/requirements.txt @@ -0,0 +1 @@ +