From 1f7bb7dbbfe5d85ea9d987fe9607a25ed76c7939 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Mon, 9 Oct 2023 00:38:12 -0400 Subject: [PATCH] Create CI job to run `melee-issues` --- .github/packages/check-issues/Dockerfile | 11 +++++ .github/packages/check-issues/entrypoint.sh | 6 +++ .github/packages/check-issues/setup.sh | 13 ++++++ .github/workflows/build-melee.yml | 52 ++++++++++++++++++++- .github/workflows/publish-packages.yml | 9 +++- 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 .github/packages/check-issues/Dockerfile create mode 100644 .github/packages/check-issues/entrypoint.sh create mode 100644 .github/packages/check-issues/setup.sh diff --git a/.github/packages/check-issues/Dockerfile b/.github/packages/check-issues/Dockerfile new file mode 100644 index 0000000000..e94583f409 --- /dev/null +++ b/.github/packages/check-issues/Dockerfile @@ -0,0 +1,11 @@ +FROM rust:latest AS check-issues +COPY .github/packages/check-issues/setup.sh /usr/local/bin +COPY . /input +ENV DEBIAN_FRONTEND=noninteractive +ENV LANG=C +RUN chmod +x /usr/local/bin/setup.sh && setup.sh +RUN rm -rf /input +VOLUME [ "/input" ] +COPY .github/packages/check-issues/entrypoint.sh /usr/local/bin +RUN chmod +x /usr/local/bin/entrypoint.sh +ENTRYPOINT entrypoint.sh diff --git a/.github/packages/check-issues/entrypoint.sh b/.github/packages/check-issues/entrypoint.sh new file mode 100644 index 0000000000..cc4d545d1a --- /dev/null +++ b/.github/packages/check-issues/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e + +cd /input + +melee-issues diff --git a/.github/packages/check-issues/setup.sh b/.github/packages/check-issues/setup.sh new file mode 100644 index 0000000000..ad9746ad30 --- /dev/null +++ b/.github/packages/check-issues/setup.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +apt update + +apt install -y --no-install-recommends \ + libclang-dev + +cargo install --path /input/tools/issues + +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 index 4593c25795..6b3b28143c 100644 --- a/.github/workflows/build-melee.yml +++ b/.github/workflows/build-melee.yml @@ -70,7 +70,9 @@ jobs: - name: Set step summary if: matrix.make_flags == 'GENERATE_MAP=1' - run: cat /tmp/output/PROGRESS.md >> $GITHUB_STEP_SUMMARY + run: | + printf "\`\`\`\n%s\n\`\`\`" "$(cat /tmp/output/PROGRESS.md)" \ + >> $GITHUB_STEP_SUMMARY build-windows: name: Windows @@ -136,3 +138,51 @@ jobs: --volume "${output}:C:/Output" ` --env MAKE_FLAGS="$env:MAKE_FLAGS" ` "$env:REGISTRY/$env:IMAGE" + + check-issues: + name: Issues + 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: check-issues:latest + 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.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pull build image + run: docker pull "$REGISTRY/$IMAGE" + + - name: Check for code issues + run: | + result=$(docker run --rm \ + --volume "$PWD:/input:ro" \ + "$REGISTRY/$IMAGE") + echo "$result" + printf "\`\`\`\n%s\n\`\`\`" "$result" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index 386ebac6e3..c601de328e 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -26,7 +26,7 @@ jobs: CONTAINERFILE: .github/packages/${{ matrix.target }}/Dockerfile strategy: matrix: - target: [ "build-linux", "gen-pages" ] + target: [ "build-linux", "gen-pages", "check-issues" ] fail-fast: false runs-on: ubuntu-latest permissions: @@ -79,6 +79,13 @@ jobs: --env MAKE_FLAGS="NON_MATCHING=1" \ "$IMAGE:test" + - name: Try checking for code issues + if: matrix.target == 'check-issues' + run: | + docker run --rm \ + --volume "$PWD:/input:ro" \ + "$IMAGE:test" + - name: Try generating pages if: matrix.target == 'gen-pages' run: |