From 14f4af1e6352e71b5cd8ccb838a6d927f2bbc4a2 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:01:54 -0500 Subject: [PATCH 01/63] feat: :sparkles: Initial Commit - Add initial build action and Docker setup for ZestCode templates --- .github/workflows/build-image.yml | 205 ++++++++++++++++++++++++++++++ .github/workflows/test.yml | 133 +++++++++++++++++++ Dockerfile | 56 ++++++++ action.yml | 36 ++++++ build-tools/build.sh | 4 + 5 files changed, 434 insertions(+) create mode 100644 .github/workflows/build-image.yml create mode 100644 .github/workflows/test.yml create mode 100644 Dockerfile create mode 100644 action.yml create mode 100644 build-tools/build.sh diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 0000000..a8f85eb --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,205 @@ +name: Build Container Image & Test + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + # Publish semver tags as releases. + tags: ["v*.*.*"] + paths-ignore: + - "README.md" + branches: [ "**" ] + pull_request: + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + Build_Container: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }}s + if: github.event_name != 'pull_request' + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build Docker image + id: buildandpush + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 + with: + context: . + push: false + load: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Add Environment Variables + id: env + run: | + echo "GH_PULLREQ_NUM=${{ github.event.number }}" >> $GITHUB_ENV + echo "GH_EEVENT_NAME=${{ github.event_name }}" >> $GITHUB_ENV + echo "GH_RREPOSITORY=${{ github.repository }}" >> $GITHUB_ENV + - name: Create Tar Image For Upload + id: tar + run: | + docker images + tag=$(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' ') + echo $tag + docker save -o image.tar $tag + + - name: Upload Artifact + id: upload + uses: actions/upload-artifact@v4 + with: + name: image.tar + path: image.tar + retention-days: 1 # One Day (The Minimum) + outputs: + prnum: ${{ github.event.number }} + url: ${{ steps.upload.outputs.artifact-url }} + tag: ${{ env.IMAGE_NAME }} + artifact_id: ${{ steps.upload.outputs.artifact-id }} + + test-action: + needs: Build_Container + # strategy: + # fail-fast: true + # matrix: + # repository: [zestcommunity/ZestCode] + # multithreading: [false] + # upload_artifact: [false] + # append_sha_to_version: [false] + # add_extra_files: [false] + # write_job_summary: [false] + # expect_error: [false] + # # exclude: + # # - expect_error: true + # # repository: EZ-Robotics/EZ-Template + + # # - multithreading: false + # # append_sha_to_version: false + # # - multithreading: false + # # upload_artifact: false + # # - multithreading: false + # # add_extra_files: false + # # repository: lemlib/lemlib + # # - multithreading: false + # # write_job_summary: false + + # # - upload_artifact: false + # # append_sha_to_version: true + # # - upload_artifact: false + # # add_extra_files: true + # # - upload_artifact: true + # # expect_error: true + + # # - append_sha_to_version: false + # # add_extra_files: false + # # upload_artifact: true + # # repository: lemlib/lemlib + # # - append_sha_to_version: false + # # write_job_summary: false + + # # - add_extra_files: true + # # repository: EZ-Robotics/EZ-Template + # # - add_extra_files: false + # # write_job_summary: false + + + # include: + # - repository: lemlib/lemlib + # expect_error: false + # ref: build/meson-init + # lib_folder_name: lemlib + uses: ./.github/workflows/test.yml + # repository: ${{ matrix.repository }} + # ref: ${{ matrix.ref }} + # caller_token: ${{ github.token }} + # expect_error: ${{ matrix.expect_error }} + # upload_artifact: ${{ matrix.upload_artifact }} + # multithreading: ${{ matrix.multithreading }} + # append_sha_to_version: ${{ matrix.append_sha_to_version }} + # add_extra_files: ${{ matrix.add_extra_files }} + # lib_folder_name: ${{ matrix.lib_folder_name }} + # write_job_summary: ${{ matrix.write_job_summary }} + # artifact_additional_postfix: | + # ${{ format('---.err{0}.upl{1}.thread{2}.sha{3}.files{4}.summ{5}', matrix.expect_error && 1 || 0, matrix.upload_artifact && 1 || 0, matrix.multithreading && 1 || 0, matrix.append_sha_to_version && 1 || 0, matrix.add_extra_files && 1 || 0, matrix.write_job_summary && 1 || 0 )}} + # publish-build: # Publish the image to the registry + # permissions: + # contents: read + # packages: write + # needs: + # [ + # Build_Container + # # test-action + # ] + # runs-on: ubuntu-latest + # if: ${{ github.event_name != 'pull_request' }} + # steps: + # - name: Checkout repository + # uses: actions/checkout@v4 + # - name: Set up Docker Buildx + # uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + # - name: Log into registry ${{ env.REGISTRY }} + # uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + # with: + # registry: ${{ env.REGISTRY }} + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + # - name: Download Image + # uses: actions/download-artifact@v4 + # with: + # name: image.tar + # github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Load Image + # id: load + # run: | + # echo "tag=$(docker load -i ./image.tar | grep -oP 'Loaded image: \K.*' | tr '\n' ' ')" > $GITHUB_OUTPUT + # - name: Push the image + # if: ${{ github.event_name != 'pull_request' }} + # run: | + # for tag in $(echo "${{ steps.load.outputs.tag }}" | tr ' ' '\n'); do + # echo "$tag" + # docker push "$tag" + # done \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6f7c52e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,133 @@ +name: Tests +on: + workflow_call: +# inputs: +# repository: +# description: The github repository to checkout +# required: true +# type: string +# ref: +# description: The ref of the github repository to checkout +# required: true +# type: string +# caller_token: +# description: "The token of the caller" +# required: true +# type: string +# expect_error: +# description: Whether to expect action to fail, and only to succeed if the action fails +# default: false +# type: boolean +# upload_artifact: +# description: Whether to create an artifact. Disabled if expect_error is true. +# default: true +# type: boolean +# multithreading: +# description: Whether to use multithreading when building the project +# default: true +# type: boolean +# append_sha_to_version: +# description: Whether to append the short commit sha to the version of the artifact +# default: true +# type: boolean +# add_extra_files: +# description: Whether to add LICENSE, README, and VERSION to artifact. +# default: false +# type: boolean +# lib_folder_name: +# description: | +# The name of the folder under the include directory that contains the headers for the project. +# Required if add_extra_files is true +# default: "" +# type: string +# write_job_summary: +# description: Whether to write the artifact URL to the job summary +# default: true +# type: boolean +# artifact_additional_postfix: +# description: Additional postfix to add to the artifact name +# default: "" +# type: string +# required: false + +jobs: + test: + name: "Testing Container" + runs-on: ubuntu-latest + steps: +# - name: Summarize Parameters +# run: | +# echo " +# ## Parameters +# | Param | Value | +# | ------------- | ------------- | +# | :package: repo | ${{ inputs.repository }} | +# | :label: ref | ${{ inputs.ref }} | +# | :rotating_light: expect err | ${{ inputs.expect_error }} | +# | :arrow_up: upload | ${{ inputs.upload_artifact }} | +# | :thread: multithread | ${{ inputs.multithreading }} | +# | :closed_lock_with_key: append sha | ${{ inputs.append_sha_to_version }} | +# | :heavy_plus_sign: add extras | ${{ inputs.add_extra_files }} | +# | :memo: summary | ${{ inputs.write_job_summary }} | +# | :card_file_box: lib folder | ${{ inputs.lib_folder_name }} | +# | :bookmark: postfix | ${{ inputs.artifact_additional_postfix }} +# " | sed "s/true/:white_check_mark: true/g" | sed "s/false/❌ false/g" >> $GITHUB_STEP_SUMMARY + - name: Checkout + uses: actions/checkout@v4 + with: + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref }} + + - name: Checkout + uses: actions/checkout@v4 + with: + path: ./action/ + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + name: image.tar + github-token: ${{ inputs.caller_token }} + + - name: Load Image + id: load + run: | + echo "tag=$(docker load -i ./image.tar | grep -oP 'Loaded image: \K.*' | head -n 1)" > $GITHUB_OUTPUT + + - name: Edit Action.yml With Local Image + run: | + cat action/action.yml + sed -i "s|docker://ghcr.io/.*/pros-build:[^\']*|docker://${{steps.load.outputs.tag}}|g" action/action.yml + cat action/action.yml + + - name: Test Action + id: test-action + uses: ./action/ +# continue-on-error: ${{ inputs.expect_error }} +# with: +# multithreading: ${{ inputs.multithreading }} +# no_commit_hash: ${{ !inputs.append_sha_to_version }} +# copy_readme_and_license_to_include: ${{ inputs.add_extra_files }} +# lib_folder_name: ${{ inputs.lib_folder_name }} +# write_job_summary: ${{ inputs.write_job_summary }} + +# - name: Check for Failure If Expected +# if: ${{ inputs.expect_error }} +# run: | +# if [ "${{ (steps.test-action.outcome == 'success') }}" == "true" ]; then +# echo "Test Action step succeeded when it was expected to fail. Failing job.." +# exit 1 +# else +# echo "Test Action step failed as expected." +# fi + +# - name: Upload Artifact +# id: upload +# if: ${{ inputs.upload_artifact && !inputs.expect_error }} +# uses: actions/upload-artifact@v4 +# with: +# name: "${{ steps.test-action.outputs.name }}${{ inputs.artifact_additional_postfix }}" +# path: "template/*" + +# - name: Add Artifact to Job Summary +# if: ${{ inputs.upload_artifact && !inputs.expect_error }} +# run: 'echo "### 📦 Artifact url: ${{ steps.upload.outputs.artifact-url }}" >> $GITHUB_STEP_SUMMARY' \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d472432 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,56 @@ +# ------------ +# Build Stage: Get Dependencies +# ------------ +FROM alpine:latest AS get-dependencies +LABEL stage=builder + +LABEL org.opencontainers.image.description="A ZestCode Build Container" +LABEL org.opencontainers.image.source=https://github.com/ZestCommunity/build-action +LABEL org.opencontainers.image.licenses=MIT + +# Install Required Packages and ARM Toolchain +RUN apk add --no-cache bash +RUN mkdir "/arm-none-eabi-toolchain" && wget -O- "https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz" \ + | tar Jxf - -C "/arm-none-eabi-toolchain" --strip-components=1 +RUN <<-"EOF" bash + set -e + + toolchain="/arm-none-eabi-toolchain" + mkdir -p "$toolchain" + + rm -rf "$toolchain"/{share,include} + rm -rf "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/arm + rm -f "$toolchain"/bin/arm-none-eabi-{gdb,gdb-py,cpp,gcc-13.3.1} + + find "$toolchain"/arm-none-eabi/lib/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} + + find "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} + + find "$toolchain"/arm-none-eabi/include/c++/13.3.1/arm-none-eabi/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a*' -exec rm -rf {} + + + apk cache clean # Cleanup image +EOF +# ------------ +# Runner Stage +# ------------ +FROM alpine:latest AS runner +LABEL stage=runner +LABEL org.opencontainers.image.description="A ZestCode Build Container" +LABEL org.opencontainers.image.source=https://github.com/ZestCommunity/build-action +LABEL org.opencontainers.image.licenses=MIT +# Copy dependencies from get-dependencies stage +COPY --from=get-dependencies /arm-none-eabi-toolchain /arm-none-eabi-toolchain +RUN apk add --no-cache gcompat libc6-compat libstdc++ git gawk python3 pipx unzip bash && pipx install meson ninja && apk cache clean + +# Set Environment Variables +ENV PATH="/arm-none-eabi-toolchain/bin:/root/.local/bin:${PATH}" + + +# Setup Build +# ENV PROS_PROJECT=${PROS_PROJECT} +# ENV REPOSITORY=${REPOSITORY} +# ENV LIBRARY_PATH=${LIBRARY_PATH} + +COPY build-tools/build.sh /build.sh +RUN chmod +x /build.sh +COPY LICENSE ./LICENSE + +ENTRYPOINT ["/build.sh"] \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..46d5cc2 --- /dev/null +++ b/action.yml @@ -0,0 +1,36 @@ +name: 'Zest Build Action' +description: 'Automatically build ZestCode templates' +branding: + color: 'blue' + icon: 'box' + colorized: true + +inputs: + multithreading: + required: false + default: true + description: Whether to use multithreading when building the project + no_commit_hash: + required: false + default: false + description: Whether to not include the commit hash in the artifact name + copy_readme_and_license_to_include: + required: false + default: false + description: Whether to copy the README.md and LICENSE files to the include directory + lib_folder_name: + required: false + default: '' + description: The name of the folder under the include directory that contains the headers for the project. Required if copy_readme_and_license_to_include is true + write_job_summary: + required: false + default: true + description: Whether to create a GitHub job summary + +outputs: + name: + description: 'The recommended name for the artifact.' + +runs: + using: 'Docker' + image: 'Dockerfile' \ No newline at end of file diff --git a/build-tools/build.sh b/build-tools/build.sh new file mode 100644 index 0000000..4c91b85 --- /dev/null +++ b/build-tools/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +git clone https://github.com/ZestCommunity/ZestCode.git && cd ZestCode && git switch build/meson-init && sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && meson setup --cross-file scripts/v5.ini builddir && meson compile -C builddir +# meson setup --cross-file scripts/v5.ini builddir +# meson compile -C builddir \ No newline at end of file From 4c71528eca81fb84866bc1b11af3fae73b66e740 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:18:50 -0500 Subject: [PATCH 02/63] feat: :sparkles: Update workflows to do moer autonomously and reset build.sh back to the two basic commands. --- .github/workflows/build-image.yml | 7 +++--- .github/workflows/test.yml | 37 ++++++------------------------- build-tools/build.sh | 6 ++--- 3 files changed, 14 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index a8f85eb..4daa8a3 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -153,9 +153,10 @@ jobs: # ref: build/meson-init # lib_folder_name: lemlib uses: ./.github/workflows/test.yml - # repository: ${{ matrix.repository }} - # ref: ${{ matrix.ref }} - # caller_token: ${{ github.token }} + with: + repository: ZestCommunity/ZestCode + ref: build/meson-init + caller_token: ${{ github.token }} # expect_error: ${{ matrix.expect_error }} # upload_artifact: ${{ matrix.upload_artifact }} # multithreading: ${{ matrix.multithreading }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f7c52e..c4fa3a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,6 +77,7 @@ jobs: with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} + path: ./ZestCodeCloned - name: Checkout uses: actions/checkout@v4 @@ -101,33 +102,9 @@ jobs: - name: Test Action id: test-action - uses: ./action/ -# continue-on-error: ${{ inputs.expect_error }} -# with: -# multithreading: ${{ inputs.multithreading }} -# no_commit_hash: ${{ !inputs.append_sha_to_version }} -# copy_readme_and_license_to_include: ${{ inputs.add_extra_files }} -# lib_folder_name: ${{ inputs.lib_folder_name }} -# write_job_summary: ${{ inputs.write_job_summary }} - -# - name: Check for Failure If Expected -# if: ${{ inputs.expect_error }} -# run: | -# if [ "${{ (steps.test-action.outcome == 'success') }}" == "true" ]; then -# echo "Test Action step succeeded when it was expected to fail. Failing job.." -# exit 1 -# else -# echo "Test Action step failed as expected." -# fi - -# - name: Upload Artifact -# id: upload -# if: ${{ inputs.upload_artifact && !inputs.expect_error }} -# uses: actions/upload-artifact@v4 -# with: -# name: "${{ steps.test-action.outputs.name }}${{ inputs.artifact_additional_postfix }}" -# path: "template/*" - -# - name: Add Artifact to Job Summary -# if: ${{ inputs.upload_artifact && !inputs.expect_error }} -# run: 'echo "### 📦 Artifact url: ${{ steps.upload.outputs.artifact-url }}" >> $GITHUB_STEP_SUMMARY' \ No newline at end of file + # uses: ./action/ + run: | + cd ZestCodeCloned + sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini + meson setup --cross-file scripts/v5.ini builddir + meson compile -C builddir \ No newline at end of file diff --git a/build-tools/build.sh b/build-tools/build.sh index 4c91b85..ab56f64 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -1,4 +1,4 @@ #!/bin/bash -git clone https://github.com/ZestCommunity/ZestCode.git && cd ZestCode && git switch build/meson-init && sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && meson setup --cross-file scripts/v5.ini builddir && meson compile -C builddir -# meson setup --cross-file scripts/v5.ini builddir -# meson compile -C builddir \ No newline at end of file +# git clone https://github.com/ZestCommunity/ZestCode.git && cd ZestCode && git switch build/meson-init && sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && meson setup --cross-file scripts/v5.ini builddir && meson compile -C builddir +meson setup --cross-file scripts/v5.ini builddir +meson compile -C builddir \ No newline at end of file From 17f76c49594511c714b271838ef840d751aaad20 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:20:58 -0500 Subject: [PATCH 03/63] fix: :sparkles: Update repository, ref, and caller_token inputs to work. --- .github/workflows/test.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4fa3a5..9569ec5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,19 +1,19 @@ name: Tests on: workflow_call: -# inputs: -# repository: -# description: The github repository to checkout -# required: true -# type: string -# ref: -# description: The ref of the github repository to checkout -# required: true -# type: string -# caller_token: -# description: "The token of the caller" -# required: true -# type: string + inputs: + repository: + description: The github repository to checkout + required: true + type: string + ref: + description: The ref of the github repository to checkout + required: true + type: string + caller_token: + description: "The token of the caller" + required: true + type: string # expect_error: # description: Whether to expect action to fail, and only to succeed if the action fails # default: false From 963d667d07125e3735a1363eae0fa5913ccc237a Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:24:31 -0500 Subject: [PATCH 04/63] feat: :sparkles: Update test workflow to use Docker for action execution --- .github/workflows/test.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9569ec5..e51ba87 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} - path: ./ZestCodeCloned + path: /ZestCodeCloned - name: Checkout uses: actions/checkout@v4 @@ -102,9 +102,10 @@ jobs: - name: Test Action id: test-action - # uses: ./action/ run: | - cd ZestCodeCloned - sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini - meson setup --cross-file scripts/v5.ini builddir - meson compile -C builddir \ No newline at end of file + docker run --rm -v /ZestCodeCloned ${{ steps.load.outputs.tag }} /bin/bash -c " + cd ZestCodeCloned && + sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && + meson setup --cross-file scripts/v5.ini builddir && + meson compile -C builddir + " From 3ed09eda1636a3393217e72b7c0f10d2f2103c40 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:27:24 -0500 Subject: [PATCH 05/63] fix: :bug: Maybe fix Error: Repository path '/ZestCodeCloned' is not under '/home/runner/work/build-action/build-action' --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e51ba87..844c742 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} - path: /ZestCodeCloned + path: ./action/ZestCode - name: Checkout uses: actions/checkout@v4 @@ -103,8 +103,8 @@ jobs: - name: Test Action id: test-action run: | - docker run --rm -v /ZestCodeCloned ${{ steps.load.outputs.tag }} /bin/bash -c " - cd ZestCodeCloned && + docker run --rm -v ${{ github.workspace }}/action/ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} /bin/bash -c " + cd /workspace/ZestCodeCloned && sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && meson setup --cross-file scripts/v5.ini builddir && meson compile -C builddir From 65b92fea2303bda2107492a66e069d55e7a4a811 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:29:16 -0500 Subject: [PATCH 06/63] fix: :bug: Correct directory in test workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 844c742..3abf99c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,7 +104,7 @@ jobs: id: test-action run: | docker run --rm -v ${{ github.workspace }}/action/ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} /bin/bash -c " - cd /workspace/ZestCodeCloned && + cd /workspace/ZestCode && sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && meson setup --cross-file scripts/v5.ini builddir && meson compile -C builddir From addb46651f6175871e7cf46b0e19b020d9879fc7 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:31:16 -0500 Subject: [PATCH 07/63] test: list all files in the directory --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3abf99c..aac2c26 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,7 +104,9 @@ jobs: id: test-action run: | docker run --rm -v ${{ github.workspace }}/action/ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} /bin/bash -c " + ls -a && cd /workspace/ZestCode && + ls -a && sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && meson setup --cross-file scripts/v5.ini builddir && meson compile -C builddir From f89ff1993b4e5aa82dded2482259d096fb093893 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:39:03 -0500 Subject: [PATCH 08/63] test: :bug: Remove meson build commands so list directory command may actually work --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aac2c26..aaa4acf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -107,7 +107,4 @@ jobs: ls -a && cd /workspace/ZestCode && ls -a && - sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && - meson setup --cross-file scripts/v5.ini builddir && - meson compile -C builddir " From 849fb0b7bc804c02b1dd9844cbf7c5da5574bc27 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:43:21 -0500 Subject: [PATCH 09/63] fix: :bug: Update Docker command in test workflow to actually change entrypoint --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aaa4acf..fddbf43 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,8 +103,11 @@ jobs: - name: Test Action id: test-action run: | - docker run --rm -v ${{ github.workspace }}/action/ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} /bin/bash -c " + docker run --rm --entrypoint /bin/bash -v ${{ github.workspace }}/action/ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " ls -a && cd /workspace/ZestCode && ls -a && + sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && + meson setup --cross-file scripts/v5.ini builddir && + meson compile -C builddir " From bfbe1a9579207f726ed2b641459e59242466a3ad Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:49:23 -0500 Subject: [PATCH 10/63] fix: :bug: Change docker run command to maybe correct path --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fddbf43..d7fba45 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,10 +103,11 @@ jobs: - name: Test Action id: test-action run: | - docker run --rm --entrypoint /bin/bash -v ${{ github.workspace }}/action/ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " + docker run --rm --entrypoint /bin/bash -v ./action/ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " ls -a && - cd /workspace/ZestCode && + cd /workspace && ls -a && + cd ZestCode && sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && meson setup --cross-file scripts/v5.ini builddir && meson compile -C builddir From 1c0f1ba6b0a7a013c0a9aa8ec263a0aa30d870c2 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:54:26 -0500 Subject: [PATCH 11/63] fix: :bug: Update paths in test workflow for Docker command --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d7fba45..1a76e73 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} - path: ./action/ZestCode + path: /ZestCode - name: Checkout uses: actions/checkout@v4 @@ -103,7 +103,7 @@ jobs: - name: Test Action id: test-action run: | - docker run --rm --entrypoint /bin/bash -v ./action/ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " + docker run --rm --entrypoint /bin/bash -v /ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " ls -a && cd /workspace && ls -a && From deec2996f1ef5ebb27dbb32d150210714c039d54 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:56:29 -0500 Subject: [PATCH 12/63] fix: :bug: Update Docker paths in test workflow --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1a76e73..aaa7a25 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} - path: /ZestCode + path: ./ZestCode - name: Checkout uses: actions/checkout@v4 @@ -103,7 +103,7 @@ jobs: - name: Test Action id: test-action run: | - docker run --rm --entrypoint /bin/bash -v /ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " + docker run --rm --entrypoint /bin/bash -v ./ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " ls -a && cd /workspace && ls -a && From 9c20f51037a6d057d398f7de065e7ccf262e4a89 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 14:56:55 -0500 Subject: [PATCH 13/63] refactor: :sparkles: Replace shell script with Python build script and update Dockerfile --- .github/workflows/test.yml | 25 ++++--- Dockerfile | 9 ++- action.yml | 16 ----- build-tools/build.py | 142 +++++++++++++++++++++++++++++++++++++ build-tools/build.sh | 73 ++++++++++++++++++- 5 files changed, 234 insertions(+), 31 deletions(-) create mode 100644 build-tools/build.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aaa7a25..a12ff6e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,6 @@ jobs: with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} - path: ./ZestCode - name: Checkout uses: actions/checkout@v4 @@ -100,15 +99,19 @@ jobs: sed -i "s|docker://ghcr.io/.*/pros-build:[^\']*|docker://${{steps.load.outputs.tag}}|g" action/action.yml cat action/action.yml + # - name: Test Action + # id: test-action + # run: | + # docker run --rm --entrypoint /bin/bash -v ./ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " + # ls -a && + # cd /workspace && + # ls -a && + # cd ZestCode && + # sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && + # meson setup --cross-file scripts/v5.ini builddir && + # meson compile -C builddir + # " - name: Test Action id: test-action - run: | - docker run --rm --entrypoint /bin/bash -v ./ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " - ls -a && - cd /workspace && - ls -a && - cd ZestCode && - sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && - meson setup --cross-file scripts/v5.ini builddir && - meson compile -C builddir - " + uses: ./action/ + continue-on-error: ${{ inputs.expect_error }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d472432..20cb5e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,8 +49,11 @@ ENV PATH="/arm-none-eabi-toolchain/bin:/root/.local/bin:${PATH}" # ENV REPOSITORY=${REPOSITORY} # ENV LIBRARY_PATH=${LIBRARY_PATH} -COPY build-tools/build.sh /build.sh -RUN chmod +x /build.sh +# COPY build-tools/build.sh /build.sh +# RUN chmod +x /build.sh +COPY build-tools/build.py /build.py +RUN chmod +x /build.py COPY LICENSE ./LICENSE -ENTRYPOINT ["/build.sh"] \ No newline at end of file +# ENTRYPOINT ["/build.sh"] +RUN ["python3", "/build.py"] \ No newline at end of file diff --git a/action.yml b/action.yml index 46d5cc2..3c3464c 100644 --- a/action.yml +++ b/action.yml @@ -6,22 +6,6 @@ branding: colorized: true inputs: - multithreading: - required: false - default: true - description: Whether to use multithreading when building the project - no_commit_hash: - required: false - default: false - description: Whether to not include the commit hash in the artifact name - copy_readme_and_license_to_include: - required: false - default: false - description: Whether to copy the README.md and LICENSE files to the include directory - lib_folder_name: - required: false - default: '' - description: The name of the folder under the include directory that contains the headers for the project. Required if copy_readme_and_license_to_include is true write_job_summary: required: false default: true diff --git a/build-tools/build.py b/build-tools/build.py new file mode 100644 index 0000000..a09cc29 --- /dev/null +++ b/build-tools/build.py @@ -0,0 +1,142 @@ +#! /usr/bin/env python3 +import os +import sys +import subprocess +import time +import argparse +import logging + + +# Set up logging +logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') +logger = logging.getLogger(__name__) + +# args +parser = argparse.ArgumentParser( + prog='Build Action', + description='The build action for the build-action', + epilog='This is the build.py script for ZestCommunity/build-action. This is not the ZestCli nor is it Meson. THIS IS ONLY INTENDED TO RUN ON THE GITHUB ACTION DOCKER CONTAINER.',) + +parser.add_argument('--multithread', action='store_true', help='Enable multithreading for the build') +parser.add_argument('--debug', action='store_true', help='Enable debug mode for the build') +args = parser.parse_args() + +script_start_time = time.time() +build_start_time = -1 + +def group(name: str): + print(f"::group::{name}") +def endgroup(): + print("::endgroup::") + +def run_command(command: str, check: bool = True): + logger.info(f"Running command: {command}") + try: + result = subprocess.run(command, shell=True, check=check, stdout=sys.stdout, stderr=sys.stderr) + if result.returncode != 0: + logger.error(f"Command failed with return code {result.returncode}") + except subprocess.CalledProcessError as e: + logger.error(f"Command failed with error: {e}") + finally: + return result + + +""" +ECHO LICENSE +""" +try: + group("LICENSE") + with open("LICENSE", "r") as f: + print(f.read()) + endgroup() +except FileNotFoundError: + # print("LICENSE file not found. This is an issue with the action container and not your code.") + logger.error("LICENSE file not found. This is an issue with the action container and not your code.") +except Exception as e: + # print(f"Error reading build-action's LICENSE file: {e}") + logger.error(f"Error reading build-action's LICENSE file: {e}") + + +subprocess.run("git config --global --add safe.directory /github/workspace", shell=True, check=True) +""" +BUILD AND COMPILE PROJECT +""" +group("Setup Project") +# compile_output = run_command("meson setup --cross-file scripts/v5.ini builddir", exit_on_error=True) +try: + setup_output = subprocess.run( + "meson setup --cross-file scripts/v5.ini builddir", + shell=True, + check=True, + stdout=sys.stdout, + stderr=sys.stderr + ) + # setup_output = subprocess.run("meson setup --cross-file scripts/v5.ini builddir", shell=True, check=True, capture_output=True) +except subprocess.CalledProcessError as e: + text = "# 🛑 Meson Setup Failed\n" + text += "An error occurred while running the `meson setup` command. Please check the error output below for more details.\n\n" + text += "#### 📄 Error Output\n" + text += "
Click to expand " + text += "```\n" + text += setup_output.stdout.decode('utf-8') + text += "\n```\n" + text += "
\n" + text += "\n" + # write to $GITHUB_STEP_SUMMARY + with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: + f.write(text) + logger.error(f"Meson setup failed with error: {e}") + logger.error("Meson setup failed. Exiting.") + endgroup() + sys.exit(1) + +""" +BUILD PROJECT +""" +group("Build Project") +build_start_time = time.time() +try: + compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True) + + build_finish_time = time.time() + build_duration = build_finish_time - build_start_time +except subprocess.CalledProcessError as e: + # If build_finish_time is not set, set it to the current time + if 'build_duration' not in locals(): + build_finish_time = time.time() + build_duration = build_finish_time - build_start_time + text = "# 🛑 Meson Compile Failed\n" + text += "An error occurred while running the `meson compile` command. Please check the error output below for more details.\n\n" + text += "#### 📄 Error Output\n" + text += "
Click to expand " + text += "```\n" + text += compile_output.stdout.decode('utf-8') + text += "\n```\n" + text += "
\n" + text += "\n" + # write to $GITHUB_STEP_SUMMARY + with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: + f.write(text) + logger.error(f"Meson compile failed with error: {e}") + logger.error("Meson compile failed. Exiting.") + endgroup() + sys.exit(1) + +endgroup() + +text = "# ✅ Build Successful\n" +text += "The build was successful. Please check the output below for more details.\n\n" +text += "#### 📄 Build Output\n" +text += "
Click to expand " +text += "```\n" +text += compile_output.stdout.decode('utf-8') +text += "\n```\n" +text += "
\n" +text += "\n" +text += f"#### ⏱️ Build Time\n" +text += f"The build took {build_duration:.2f} seconds.\n" +text += "\n" + +# write to $GITHUB_STEP_SUMMARY +with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: + f.write(text) \ No newline at end of file diff --git a/build-tools/build.sh b/build-tools/build.sh index ab56f64..51188d6 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -1,4 +1,75 @@ #!/bin/bash # git clone https://github.com/ZestCommunity/ZestCode.git && cd ZestCode && git switch build/meson-init && sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && meson setup --cross-file scripts/v5.ini builddir && meson compile -C builddir + +# Flag to control error trapping +trap_enabled=true + +alias disable-errors="set +e; trap_enabled=false" +alias enable-errors="set -e; trap_enabled=true" + +# start time in seconds +script_start_time=$(date +%s) +build_start_time=-1 + +# ------------ +# CREATE TRAP +# ------------ +# Create a trap to catch errors and print the error message +trap '[[ $trap_enabled == true ]] && error' ERR + +function error() { + GITHUB_BUILD_SUMMARY_OUTPUT=$(mktemp) + echo "# 🛑 Build Failed\n" + echo "The build failed. Please check the logs for more information.\n" + echo "***" + # if build_start_time is -1, then the build has not started yet + if [ $build_start_time -eq -1 ]; then + echo "The build failed to start. This could mean an error occured in the script itself, and if so, consider opening an issue on https://github.com/ZestCommunity/build-action/issues." + else + # calculate the elapsed time + end_time=$(date +%s) + elapsed_time=$((end_time - $build_start_time)) + echo "The build failed after $elapsed_time seconds." + fi +} +# ------------ +# ECHO LICENSE +# ------------ +disable-errors +echo "::group::License" +cat /LICENSE +echo "::endgroup::" +enable-errors + +git config --global --add safe.directory /github/workspace + +# ------------ +# BUILD AND COMPILE PROJECT +# ------------ +echo "::group::Build Project" meson setup --cross-file scripts/v5.ini builddir -meson compile -C builddir \ No newline at end of file +echo "::endgroup::" + + + +echo "::group::Compile Project" + +STD_OUTPUT=$(mktemp) + +disable-errors +# time this command +start_time=$(date +%s) +meson compile -C builddir | tee $STD_OUTPUT +end_time=$(date +%s) +make_exit_code=${PIPESTATUS[0]} +elapsed_time=$((end_time - start_time)) +echo "Meson compile took $elapsed_time seconds" + +STD_EDITED_OUTPUT=$(mktemp) +# Remove ANSI color codes from the output +# https://stackoverflow.com/a/18000433 +sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" $STD_OUTPUT >$STD_EDITED_OUTPUT +echo "::endgroup::" + + + From cfeb82474c48d75c69eab02caf357020c0000ce6 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 14:58:36 -0500 Subject: [PATCH 14/63] fix: :bug: Change Dockerfile entrypoint to CMD instead of RUN --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 20cb5e0..dc4f357 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,4 +56,4 @@ RUN chmod +x /build.py COPY LICENSE ./LICENSE # ENTRYPOINT ["/build.sh"] -RUN ["python3", "/build.py"] \ No newline at end of file +CMD ["python3", "/build.py"] \ No newline at end of file From 2da63d3072e9f1d930caa53c322741a3f765281b Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 15:02:06 -0500 Subject: [PATCH 15/63] ci: :bug: Fix continue-on-error input not existing by manually setting continue-on-error in test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a12ff6e..08fd55b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -114,4 +114,4 @@ jobs: - name: Test Action id: test-action uses: ./action/ - continue-on-error: ${{ inputs.expect_error }} \ No newline at end of file + continue-on-error: False \ No newline at end of file From 24af438f5a09834ee0071804435d2f2636c9c171 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 15:04:47 -0500 Subject: [PATCH 16/63] fix: :bug: Initialize setup_output and compile_output before try-catch statements in build script --- build-tools/build.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-tools/build.py b/build-tools/build.py index a09cc29..e0989ba 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -63,6 +63,7 @@ def run_command(command: str, check: bool = True): """ group("Setup Project") # compile_output = run_command("meson setup --cross-file scripts/v5.ini builddir", exit_on_error=True) +setup_output = None try: setup_output = subprocess.run( "meson setup --cross-file scripts/v5.ini builddir", @@ -95,6 +96,7 @@ def run_command(command: str, check: bool = True): """ group("Build Project") build_start_time = time.time() +compile_output = None try: compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True) From 1e1ef101ac4c19287ef18077598e4f2703176771 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 15:08:58 -0500 Subject: [PATCH 17/63] fix: :bug: Update LICENSE path in Dockerfile and build script; declare variables as global in build.py --- Dockerfile | 2 +- build-tools/build.py | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index dc4f357..1a69173 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,7 +53,7 @@ ENV PATH="/arm-none-eabi-toolchain/bin:/root/.local/bin:${PATH}" # RUN chmod +x /build.sh COPY build-tools/build.py /build.py RUN chmod +x /build.py -COPY LICENSE ./LICENSE +COPY LICENSE /LICENSE # ENTRYPOINT ["/build.sh"] CMD ["python3", "/build.py"] \ No newline at end of file diff --git a/build-tools/build.py b/build-tools/build.py index e0989ba..dc67ab4 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -46,7 +46,7 @@ def run_command(command: str, check: bool = True): """ try: group("LICENSE") - with open("LICENSE", "r") as f: + with open("/LICENSE", "r") as f: print(f.read()) endgroup() except FileNotFoundError: @@ -63,9 +63,8 @@ def run_command(command: str, check: bool = True): """ group("Setup Project") # compile_output = run_command("meson setup --cross-file scripts/v5.ini builddir", exit_on_error=True) -setup_output = None try: - setup_output = subprocess.run( + global setup_output = subprocess.run( "meson setup --cross-file scripts/v5.ini builddir", shell=True, check=True, @@ -96,12 +95,11 @@ def run_command(command: str, check: bool = True): """ group("Build Project") build_start_time = time.time() -compile_output = None try: - compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True) + global compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True) - build_finish_time = time.time() - build_duration = build_finish_time - build_start_time + global build_finish_time = time.time() + global build_duration = build_finish_time - build_start_time except subprocess.CalledProcessError as e: # If build_finish_time is not set, set it to the current time if 'build_duration' not in locals(): From ae1ed090e88c50d2cc0c25efeca803d70082f030 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 15:12:39 -0500 Subject: [PATCH 18/63] fix: :bug: Correctly declare global variables --- build-tools/build.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/build-tools/build.py b/build-tools/build.py index dc67ab4..d9a6240 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -64,7 +64,8 @@ def run_command(command: str, check: bool = True): group("Setup Project") # compile_output = run_command("meson setup --cross-file scripts/v5.ini builddir", exit_on_error=True) try: - global setup_output = subprocess.run( + global setup_output + setup_output = subprocess.run( "meson setup --cross-file scripts/v5.ini builddir", shell=True, check=True, @@ -96,13 +97,18 @@ def run_command(command: str, check: bool = True): group("Build Project") build_start_time = time.time() try: - global compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True) + global compile_output + compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True) - global build_finish_time = time.time() - global build_duration = build_finish_time - build_start_time + global build_finish_time + build_finish_time = time.time() + global build_duration + build_duration build_finish_time - build_start_time except subprocess.CalledProcessError as e: # If build_finish_time is not set, set it to the current time - if 'build_duration' not in locals(): + if 'build_duration' not in globals(): + global build_finish_time + global build_duration build_finish_time = time.time() build_duration = build_finish_time - build_start_time text = "# 🛑 Meson Compile Failed\n" From 261ac2cc7e8d7a065a1e362f2941b06f2b4bfd83 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 16:02:09 -0500 Subject: [PATCH 19/63] fix: :bug: Actually fix global variables --- build-tools/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/build.py b/build-tools/build.py index d9a6240..4a24864 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -103,7 +103,7 @@ def run_command(command: str, check: bool = True): global build_finish_time build_finish_time = time.time() global build_duration - build_duration build_finish_time - build_start_time + build_duration = build_finish_time - build_start_time except subprocess.CalledProcessError as e: # If build_finish_time is not set, set it to the current time if 'build_duration' not in globals(): From 7ea6d5b6b68e2eecb2b061377c93f8e4877092a6 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 16:05:23 -0500 Subject: [PATCH 20/63] fix: :bug: Declare global variables for setup_output, compile_output, build_finish_time, and build_duration --- build-tools/build.py | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/build-tools/build.py b/build-tools/build.py index 4a24864..1f74312 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -29,17 +29,6 @@ def group(name: str): def endgroup(): print("::endgroup::") -def run_command(command: str, check: bool = True): - logger.info(f"Running command: {command}") - try: - result = subprocess.run(command, shell=True, check=check, stdout=sys.stdout, stderr=sys.stderr) - if result.returncode != 0: - logger.error(f"Command failed with return code {result.returncode}") - except subprocess.CalledProcessError as e: - logger.error(f"Command failed with error: {e}") - finally: - return result - """ ECHO LICENSE @@ -61,10 +50,9 @@ def run_command(command: str, check: bool = True): """ BUILD AND COMPILE PROJECT """ +global setup_output group("Setup Project") -# compile_output = run_command("meson setup --cross-file scripts/v5.ini builddir", exit_on_error=True) try: - global setup_output setup_output = subprocess.run( "meson setup --cross-file scripts/v5.ini builddir", shell=True, @@ -72,7 +60,6 @@ def run_command(command: str, check: bool = True): stdout=sys.stdout, stderr=sys.stderr ) - # setup_output = subprocess.run("meson setup --cross-file scripts/v5.ini builddir", shell=True, check=True, capture_output=True) except subprocess.CalledProcessError as e: text = "# 🛑 Meson Setup Failed\n" text += "An error occurred while running the `meson setup` command. Please check the error output below for more details.\n\n" @@ -94,21 +81,20 @@ def run_command(command: str, check: bool = True): """ BUILD PROJECT """ + +global build_finish_time +global build_duration +global compile_output group("Build Project") build_start_time = time.time() try: - global compile_output compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True) - global build_finish_time build_finish_time = time.time() - global build_duration build_duration = build_finish_time - build_start_time except subprocess.CalledProcessError as e: # If build_finish_time is not set, set it to the current time if 'build_duration' not in globals(): - global build_finish_time - global build_duration build_finish_time = time.time() build_duration = build_finish_time - build_start_time text = "# 🛑 Meson Compile Failed\n" From 10671b9c13182601c3187512b8f7d9dc059cff82 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 16:11:47 -0500 Subject: [PATCH 21/63] fix: :bug: Test to see if the python script is running meson or otherwise --- build-tools/build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-tools/build.py b/build-tools/build.py index 1f74312..735af38 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -6,9 +6,9 @@ import argparse import logging - +print("# ZestCommunity/build-action build.py") # Set up logging -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') +logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') logger = logging.getLogger(__name__) # args From 88b6574d0d5f4c1b7844cafcbb05d73c3d56c190 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 16:14:04 -0500 Subject: [PATCH 22/63] fix: :bug: Capture output in meson setup command instead of redirecting to stdout and stderr --- build-tools/build.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build-tools/build.py b/build-tools/build.py index 735af38..938555f 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -57,8 +57,7 @@ def endgroup(): "meson setup --cross-file scripts/v5.ini builddir", shell=True, check=True, - stdout=sys.stdout, - stderr=sys.stderr + capture_output=True ) except subprocess.CalledProcessError as e: text = "# 🛑 Meson Setup Failed\n" From af85db0e112e25cc85145d4cb2cd1ec257683caf Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 16:18:23 -0500 Subject: [PATCH 23/63] fix: :bug: Enable unbuffered output for Python and capture output in meson compile command --- Dockerfile | 1 + build-tools/build.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1a69173..3ead49a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,7 @@ RUN apk add --no-cache gcompat libc6-compat libstdc++ git gawk python3 pipx unzi # Set Environment Variables ENV PATH="/arm-none-eabi-toolchain/bin:/root/.local/bin:${PATH}" +ENV PYTHONUNBUFFERED=1 # Setup Build # ENV PROS_PROJECT=${PROS_PROJECT} diff --git a/build-tools/build.py b/build-tools/build.py index 938555f..c95ea5a 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -87,7 +87,7 @@ def endgroup(): group("Build Project") build_start_time = time.time() try: - compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True) + compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True, capture_output=True) build_finish_time = time.time() build_duration = build_finish_time - build_start_time From 4215bc48f0168c554909c589ec7490154683be14 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 16:23:52 -0500 Subject: [PATCH 24/63] fix: :bug: Print stdout and stderr output for meson setup and compile commands --- build-tools/build.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build-tools/build.py b/build-tools/build.py index c95ea5a..592d5bc 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -59,6 +59,8 @@ def endgroup(): check=True, capture_output=True ) + print(setup_output.stdout.decode('utf-8'), sys.stdout) + print(setup_output.stderr.decode('utf-8'), sys.stderr) except subprocess.CalledProcessError as e: text = "# 🛑 Meson Setup Failed\n" text += "An error occurred while running the `meson setup` command. Please check the error output below for more details.\n\n" @@ -87,8 +89,14 @@ def endgroup(): group("Build Project") build_start_time = time.time() try: - compile_output = subprocess.run("meson compile -C builddir", shell=True, check=True, capture_output=True) - + compile_output = subprocess.run( + "meson compile -C builddir", + shell=True, + check=True, + capture_output=True + ) + print(compile_output.stdout.decode('utf-8'), sys.stdout) + print(compile_output.stderr.decode('utf-8'), sys.stderr) build_finish_time = time.time() build_duration = build_finish_time - build_start_time except subprocess.CalledProcessError as e: From bf64d92265f00a9dec81e3d738d292684e0e2db1 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 16:30:26 -0500 Subject: [PATCH 25/63] fix: :bug: Ensure stdout and stderr are printed after meson setup and compile commands --- build-tools/build.py | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/build-tools/build.py b/build-tools/build.py index 592d5bc..37bd058 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -53,14 +53,16 @@ def endgroup(): global setup_output group("Setup Project") try: - setup_output = subprocess.run( - "meson setup --cross-file scripts/v5.ini builddir", - shell=True, - check=True, - capture_output=True - ) - print(setup_output.stdout.decode('utf-8'), sys.stdout) - print(setup_output.stderr.decode('utf-8'), sys.stderr) + try: + setup_output = subprocess.run( + "meson setup --cross-file scripts/v5.ini builddir", + shell=True, + check=True, + capture_output=True + ) + finally: + print(setup_output.stdout.decode('utf-8'), sys.stdout) + print(setup_output.stderr.decode('utf-8'), sys.stderr) except subprocess.CalledProcessError as e: text = "# 🛑 Meson Setup Failed\n" text += "An error occurred while running the `meson setup` command. Please check the error output below for more details.\n\n" @@ -88,17 +90,19 @@ def endgroup(): global compile_output group("Build Project") build_start_time = time.time() -try: - compile_output = subprocess.run( - "meson compile -C builddir", - shell=True, - check=True, - capture_output=True - ) - print(compile_output.stdout.decode('utf-8'), sys.stdout) - print(compile_output.stderr.decode('utf-8'), sys.stderr) - build_finish_time = time.time() - build_duration = build_finish_time - build_start_time +try: #outer + try: # inner + compile_output = subprocess.run( + "meson compile -C builddir", + shell=True, + check=True, + capture_output=True + ) + finally: + print(compile_output.stdout.decode('utf-8'), sys.stdout) + print(compile_output.stderr.decode('utf-8'), sys.stderr) + build_finish_time = time.time() + build_duration = build_finish_time - build_start_time except subprocess.CalledProcessError as e: # If build_finish_time is not set, set it to the current time if 'build_duration' not in globals(): From 0a950d2e28d16aaeb1ccf01afab5b1e16e0cd297 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:20:40 -0500 Subject: [PATCH 26/63] fix: :bug: Update meson setup and compile commands to handle errors and print output correctly --- build-tools/build.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/build-tools/build.py b/build-tools/build.py index 37bd058..fb1a06f 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -57,12 +57,15 @@ def endgroup(): setup_output = subprocess.run( "meson setup --cross-file scripts/v5.ini builddir", shell=True, - check=True, - capture_output=True + check=False, + capture_output=True, + text=True ) finally: - print(setup_output.stdout.decode('utf-8'), sys.stdout) - print(setup_output.stderr.decode('utf-8'), sys.stderr) + print(setup_output.stdout, sys.stdout) + print(setup_output.stderr, sys.stderr) + if setup_output.returncode != 0: + raise subprocess.CalledProcessError(setup_output.returncode, setup_output.args, output=setup_output.stdout, stderr=setup_output.stderr) except subprocess.CalledProcessError as e: text = "# 🛑 Meson Setup Failed\n" text += "An error occurred while running the `meson setup` command. Please check the error output below for more details.\n\n" @@ -95,14 +98,18 @@ def endgroup(): compile_output = subprocess.run( "meson compile -C builddir", shell=True, - check=True, - capture_output=True + check=False, + capture_output=True, + text=True ) finally: - print(compile_output.stdout.decode('utf-8'), sys.stdout) - print(compile_output.stderr.decode('utf-8'), sys.stderr) + print(compile_output.stdout, sys.stdout) + print(compile_output.stderr, sys.stderr) build_finish_time = time.time() build_duration = build_finish_time - build_start_time + # if compile_output.returncode != 0, throw an error + if compile_output.returncode != 0: + raise subprocess.CalledProcessError(compile_output.returncode, compile_output.args, output=compile_output.stdout, stderr=compile_output.stderr) except subprocess.CalledProcessError as e: # If build_finish_time is not set, set it to the current time if 'build_duration' not in globals(): From abc17f7b0c67d97e6f1d031eea926d5092537be6 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:23:08 -0500 Subject: [PATCH 27/63] fix: :bug: Remove unnecessary decoding of stdout output in build script --- build-tools/build.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-tools/build.py b/build-tools/build.py index fb1a06f..6116d72 100644 --- a/build-tools/build.py +++ b/build-tools/build.py @@ -72,7 +72,7 @@ def endgroup(): text += "#### 📄 Error Output\n" text += "
Click to expand " text += "```\n" - text += setup_output.stdout.decode('utf-8') + text += setup_output.stdout text += "\n```\n" text += "
\n" text += "\n" @@ -120,7 +120,7 @@ def endgroup(): text += "#### 📄 Error Output\n" text += "
Click to expand " text += "```\n" - text += compile_output.stdout.decode('utf-8') + text += compile_output.stdout text += "\n```\n" text += "
\n" text += "\n" @@ -139,7 +139,7 @@ def endgroup(): text += "#### 📄 Build Output\n" text += "
Click to expand " text += "```\n" -text += compile_output.stdout.decode('utf-8') +text += compile_output.stdout text += "\n```\n" text += "
\n" text += "\n" From adedba9fef6fc81f85c64ba50701526b9436750c Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:35:45 -0500 Subject: [PATCH 28/63] refactor: :fire: Switch back from python to bash shell script --- Dockerfile | 12 ++-- build-tools/{ => archive}/build.py | 64 +++++++++---------- build-tools/build.sh | 99 ++++++++++++++++++++++-------- 3 files changed, 110 insertions(+), 65 deletions(-) rename build-tools/{ => archive}/build.py (77%) diff --git a/Dockerfile b/Dockerfile index 3ead49a..78ad4d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,11 +50,11 @@ ENV PYTHONUNBUFFERED=1 # ENV REPOSITORY=${REPOSITORY} # ENV LIBRARY_PATH=${LIBRARY_PATH} -# COPY build-tools/build.sh /build.sh -# RUN chmod +x /build.sh -COPY build-tools/build.py /build.py -RUN chmod +x /build.py +COPY build-tools/build.sh /build.sh +RUN chmod +x /build.sh +# COPY build-tools/build.py /build.py +# RUN chmod +x /build.py COPY LICENSE /LICENSE -# ENTRYPOINT ["/build.sh"] -CMD ["python3", "/build.py"] \ No newline at end of file +ENTRYPOINT ["/build.sh"] +# CMD ["python3", "/build.py"] \ No newline at end of file diff --git a/build-tools/build.py b/build-tools/archive/build.py similarity index 77% rename from build-tools/build.py rename to build-tools/archive/build.py index 6116d72..03b8e62 100644 --- a/build-tools/build.py +++ b/build-tools/archive/build.py @@ -5,7 +5,9 @@ import time import argparse import logging - +import io +import tempfile + print("# ZestCommunity/build-action build.py") # Set up logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') @@ -44,35 +46,36 @@ def endgroup(): except Exception as e: # print(f"Error reading build-action's LICENSE file: {e}") logger.error(f"Error reading build-action's LICENSE file: {e}") - +endgroup() subprocess.run("git config --global --add safe.directory /github/workspace", shell=True, check=True) """ BUILD AND COMPILE PROJECT """ global setup_output +global setup_process +global setup_output_err group("Setup Project") try: - try: - setup_output = subprocess.run( - "meson setup --cross-file scripts/v5.ini builddir", - shell=True, - check=False, - capture_output=True, - text=True + with tempfile.NamedTemporaryFile(delete=False) as setup_output: + setup_process = subprocess.Popen( + "tasklist", + shell=True, + text=True, + stdout=subprocess.PIPE, ) - finally: - print(setup_output.stdout, sys.stdout) - print(setup_output.stderr, sys.stderr) - if setup_output.returncode != 0: - raise subprocess.CalledProcessError(setup_output.returncode, setup_output.args, output=setup_output.stdout, stderr=setup_output.stderr) + + # setup_output, setup_output_err = setup_process.communicate() + # print(setup_output) + if setup_process.returncode != 0: + raise subprocess.CalledProcessError(setup_process.returncode, setup_process.args, output=setup_process.stdout, stderr=setup_process.stderr) except subprocess.CalledProcessError as e: text = "# 🛑 Meson Setup Failed\n" text += "An error occurred while running the `meson setup` command. Please check the error output below for more details.\n\n" text += "#### 📄 Error Output\n" text += "
Click to expand " text += "```\n" - text += setup_output.stdout + text += setup_output text += "\n```\n" text += "
\n" text += "\n" @@ -91,25 +94,22 @@ def endgroup(): global build_finish_time global build_duration global compile_output +global compile_output_err group("Build Project") build_start_time = time.time() -try: #outer - try: # inner - compile_output = subprocess.run( - "meson compile -C builddir", - shell=True, - check=False, - capture_output=True, - text=True - ) - finally: - print(compile_output.stdout, sys.stdout) - print(compile_output.stderr, sys.stderr) - build_finish_time = time.time() - build_duration = build_finish_time - build_start_time - # if compile_output.returncode != 0, throw an error - if compile_output.returncode != 0: - raise subprocess.CalledProcessError(compile_output.returncode, compile_output.args, output=compile_output.stdout, stderr=compile_output.stderr) +try: + compile_output_process = subprocess.Popen( + "meson compile -C builddir", + shell=True, + text=True + ) + compile_output, compile_output_err = compile_output_process.communicate() + build_finish_time = time.time() + build_duration = build_finish_time - build_start_time + + # if compile_output.returncode != 0, throw an error + if compile_output_process.returncode != 0: + raise subprocess.CalledProcessError(compile_output_process.returncode, compile_output_process.args, output=compile_output_process.stdout, stderr=compile_output_process.stderr) except subprocess.CalledProcessError as e: # If build_finish_time is not set, set it to the current time if 'build_duration' not in globals(): diff --git a/build-tools/build.sh b/build-tools/build.sh index 51188d6..0ce3a84 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -11,27 +11,27 @@ alias enable-errors="set -e; trap_enabled=true" script_start_time=$(date +%s) build_start_time=-1 -# ------------ -# CREATE TRAP -# ------------ -# Create a trap to catch errors and print the error message -trap '[[ $trap_enabled == true ]] && error' ERR - -function error() { - GITHUB_BUILD_SUMMARY_OUTPUT=$(mktemp) - echo "# 🛑 Build Failed\n" - echo "The build failed. Please check the logs for more information.\n" - echo "***" - # if build_start_time is -1, then the build has not started yet - if [ $build_start_time -eq -1 ]; then - echo "The build failed to start. This could mean an error occured in the script itself, and if so, consider opening an issue on https://github.com/ZestCommunity/build-action/issues." - else - # calculate the elapsed time - end_time=$(date +%s) - elapsed_time=$((end_time - $build_start_time)) - echo "The build failed after $elapsed_time seconds." - fi -} +# # ------------ +# # CREATE TRAP +# # ------------ +# # Create a trap to catch errors and print the error message +# trap '[[ $trap_enabled == true ]] && error' ERR + +# function error() { +# GITHUB_BUILD_SUMMARY_OUTPUT=$(mktemp) +# echo "# 🛑 Build Failed\n" +# echo "The build failed. Please check the logs for more information.\n" +# echo "***" +# # if build_start_time is -1, then the build has not started yet +# if [ $build_start_time -eq -1 ]; then +# echo "The build failed to start. This could mean an error occured in the script itself, and if so, consider opening an issue on https://github.com/ZestCommunity/build-action/issues." +# else +# # calculate the elapsed time +# end_time=$(date +%s) +# elapsed_time=$((end_time - $build_start_time)) +# echo "The build failed after $elapsed_time seconds." +# fi +# } # ------------ # ECHO LICENSE # ------------ @@ -39,15 +39,30 @@ disable-errors echo "::group::License" cat /LICENSE echo "::endgroup::" -enable-errors + git config --global --add safe.directory /github/workspace # ------------ # BUILD AND COMPILE PROJECT -# ------------ +# ------------\ +COMPILE_STD_OUTPUT=$(mktemp) echo "::group::Build Project" -meson setup --cross-file scripts/v5.ini builddir +meson setup --cross-file scripts/v5.ini builddir | tee $COMPILE_STD_OUTPUT +if [ $? -ne 0 ]; then + echo "Meson setup failed. Please check the logs for more information." + GH_SUMMARY_OUTPUT=$(mktemp) + echo "# 🛑 Meson Setup Failed " > $GH_SUMMARY_OUTPUT + echo "Meson setup failed. Please check the logs for more information. " >> $GH_SUMMARY_OUTPUT + echo "***" >> $GH_SUMMARY_OUTPUT + echo "
Click to expand " >> $GH_SUMMARY_OUTPUT + echo "\`\`\` " >> $GH_SUMMARY_OUTPUT + echo "$COMPILE_STD_OUTPUT" >> $GH_SUMMARY_OUTPUT + echo "\`\`\` " >> $GH_SUMMARY_OUTPUT + echo "
" >> $GH_SUMMARY_OUTPUT + echo "::endgroup::" + exit 1 +fi echo "::endgroup::" @@ -61,15 +76,45 @@ disable-errors start_time=$(date +%s) meson compile -C builddir | tee $STD_OUTPUT end_time=$(date +%s) -make_exit_code=${PIPESTATUS[0]} +meson_exit_code=${PIPESTATUS[0]} elapsed_time=$((end_time - start_time)) echo "Meson compile took $elapsed_time seconds" - STD_EDITED_OUTPUT=$(mktemp) # Remove ANSI color codes from the output # https://stackoverflow.com/a/18000433 sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" $STD_OUTPUT >$STD_EDITED_OUTPUT -echo "::endgroup::" +if [ $meson_exit_code -ne 0 ]; then + echo "Meson compile failed. Please check the logs for more information." + GH_SUMMARY_OUTPUT=$(mktemp) + echo "# 🛑 Meson Compile Failed " > $GH_SUMMARY_OUTPUT + echo "Meson compile failed. Please check the logs for more information. " >> $GH_SUMMARY_OUTPUT + echo "***" >> $GH_SUMMARY_OUTPUT + echo "
Click to expand " >> $GH_SUMMARY_OUTPUT + echo "\`\`\` " >> $GH_SUMMARY_OUTPUT + echo "$STD_EDITED_OUTPUT" >> $GH_SUMMARY_OUTPUT + echo "\`\`\` " >> $GH_SUMMARY_OUTPUT + echo "
" >> $GH_SUMMARY_OUTPUT + exit 1 +fi +echo "::endgroup::" +# ------------ +# BUILD SUCCESS +# FINAL SUMMARY +# ------------ +echo "The build was successful" +echo "The build took $elapsed_time seconds" + +# job summary +GH_SUMMARY_OUTPUT=$(mktemp) +echo "# ✅ Build Successful " > $GH_SUMMARY_OUTPUT +echo "The build was successful. " >> $GH_SUMMARY_OUTPUT +echo "The build took $elapsed_time seconds. " >> $GH_SUMMARY_OUTPUT +echo "***" >> $GH_SUMMARY_OUTPUT +echo "
Click to expand " >> $GH_SUMMARY_OUTPUT +echo "\`\`\` " >> $GH_SUMMARY_OUTPUT +echo "$STD_EDITED_OUTPUT" >> $GH_SUMMARY_OUTPUT +echo "\`\`\` " >> $GH_SUMMARY_OUTPUT +echo "
" >> $GH_SUMMARY_OUTPUT From 7b2bad6d53d221aa23d56fd833a3a3bb0bc01f80 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:41:55 -0500 Subject: [PATCH 29/63] ci: :bug: switch to main from build/meson-init in test action --- .github/workflows/build-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 4daa8a3..c7f545a 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -155,7 +155,7 @@ jobs: uses: ./.github/workflows/test.yml with: repository: ZestCommunity/ZestCode - ref: build/meson-init + ref: main caller_token: ${{ github.token }} # expect_error: ${{ matrix.expect_error }} # upload_artifact: ${{ matrix.upload_artifact }} From 656754f39a75d25ce50bf7eeeba936509649bf54 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:47:35 -0500 Subject: [PATCH 30/63] fix: :bug: Correctly capture exit code from meson setup for error handling --- build-tools/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index 0ce3a84..55f5a52 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -49,7 +49,8 @@ git config --global --add safe.directory /github/workspace COMPILE_STD_OUTPUT=$(mktemp) echo "::group::Build Project" meson setup --cross-file scripts/v5.ini builddir | tee $COMPILE_STD_OUTPUT -if [ $? -ne 0 ]; then +meson_exit_code = ${PIPESTATUS[0]} +if [ $meson_exit_code -ne 0 ]; then echo "Meson setup failed. Please check the logs for more information." GH_SUMMARY_OUTPUT=$(mktemp) echo "# 🛑 Meson Setup Failed " > $GH_SUMMARY_OUTPUT From 2a9c46d4353489590b82d90c0a235f36286e3f93 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:51:49 -0500 Subject: [PATCH 31/63] fix: :bug: Replace 'Dockerfile' in action.yml with the loaded tag from previous step, complimenting the other replace for ghcr.io things --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 08fd55b..9fceabe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -96,7 +96,8 @@ jobs: - name: Edit Action.yml With Local Image run: | cat action/action.yml - sed -i "s|docker://ghcr.io/.*/pros-build:[^\']*|docker://${{steps.load.outputs.tag}}|g" action/action.yml + sed -i "s|docker://ghcr.io/.*/build-action:[^\']*|docker://${{steps.load.outputs.tag}}|g" action/action.yml + sed -i "s|Dockerfile|docker://${{steps.load.outputs.tag}}|g" action/action.yml cat action/action.yml # - name: Test Action From 21ad29bb14e239a97c9f0d450cfbbbea1270594b Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:53:18 -0500 Subject: [PATCH 32/63] fix: :bug: Ensure GH_SUMMARY_OUTPUT actually written to GITHUB_STEP_SUMMARY --- build-tools/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-tools/build.sh b/build-tools/build.sh index 55f5a52..eaf3bd3 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -62,6 +62,7 @@ if [ $meson_exit_code -ne 0 ]; then echo "\`\`\` " >> $GH_SUMMARY_OUTPUT echo " " >> $GH_SUMMARY_OUTPUT echo "::endgroup::" + echo $GH_SUMMARY_OUTPUT > $GITHUB_STEP_SUMMARY exit 1 fi echo "::endgroup::" @@ -96,6 +97,7 @@ if [ $meson_exit_code -ne 0 ]; then echo "$STD_EDITED_OUTPUT" >> $GH_SUMMARY_OUTPUT echo "\`\`\` " >> $GH_SUMMARY_OUTPUT echo " " >> $GH_SUMMARY_OUTPUT + echo $GH_SUMMARY_OUTPUT > $GITHUB_STEP_SUMMARY exit 1 fi echo "::endgroup::" @@ -118,4 +120,5 @@ echo "\`\`\` " >> $GH_SUMMARY_OUTPUT echo "$STD_EDITED_OUTPUT" >> $GH_SUMMARY_OUTPUT echo "\`\`\` " >> $GH_SUMMARY_OUTPUT echo " " >> $GH_SUMMARY_OUTPUT +echo $GH_SUMMARY_OUTPUT > $GITHUB_STEP_SUMMARY From a4029b3b8271c2fdaf33554b64728f5595fc93b8 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:54:52 -0500 Subject: [PATCH 33/63] refactor: :bug: Add logging for Meson setup and compile exit codes --- build-tools/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-tools/build.sh b/build-tools/build.sh index eaf3bd3..cd988ed 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -50,6 +50,7 @@ COMPILE_STD_OUTPUT=$(mktemp) echo "::group::Build Project" meson setup --cross-file scripts/v5.ini builddir | tee $COMPILE_STD_OUTPUT meson_exit_code = ${PIPESTATUS[0]} +echo "Meson setup exit code: $meson_exit_code" if [ $meson_exit_code -ne 0 ]; then echo "Meson setup failed. Please check the logs for more information." GH_SUMMARY_OUTPUT=$(mktemp) @@ -79,6 +80,7 @@ start_time=$(date +%s) meson compile -C builddir | tee $STD_OUTPUT end_time=$(date +%s) meson_exit_code=${PIPESTATUS[0]} +echo "Meson compile exit code: $meson_exit_code" elapsed_time=$((end_time - start_time)) echo "Meson compile took $elapsed_time seconds" STD_EDITED_OUTPUT=$(mktemp) From d5fd1e703de01a90a94167cfa5edf98d6d0bf32b Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:57:11 -0500 Subject: [PATCH 34/63] refactor: :bug: Simplify disable-errors and enable-errors in build script --- build-tools/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index cd988ed..1d6bc48 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -4,8 +4,8 @@ # Flag to control error trapping trap_enabled=true -alias disable-errors="set +e; trap_enabled=false" -alias enable-errors="set -e; trap_enabled=true" +alias disable-errors="set +e" +alias enable-errors="set -e" # start time in seconds script_start_time=$(date +%s) From 860e6bed4e3c7f685c5961ba648c69951a2c02e0 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 20:58:54 -0500 Subject: [PATCH 35/63] fix: Reorder when I get the exit code from meson --- build-tools/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index 1d6bc48..c99d759 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -78,8 +78,8 @@ disable-errors # time this command start_time=$(date +%s) meson compile -C builddir | tee $STD_OUTPUT -end_time=$(date +%s) meson_exit_code=${PIPESTATUS[0]} +end_time=$(date +%s) echo "Meson compile exit code: $meson_exit_code" elapsed_time=$((end_time - start_time)) echo "Meson compile took $elapsed_time seconds" From b92c51c2a1618b928eb3999e2d99f6f7cb76118f Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 22:27:16 -0500 Subject: [PATCH 36/63] refactor: :art: Change builddir to build in meson commands The docs written for zestcode say to use build, not builddir. This is a styling change to more closely match Zestcode's own documentation --- build-tools/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index c99d759..d7c65c8 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -48,7 +48,7 @@ git config --global --add safe.directory /github/workspace # ------------\ COMPILE_STD_OUTPUT=$(mktemp) echo "::group::Build Project" -meson setup --cross-file scripts/v5.ini builddir | tee $COMPILE_STD_OUTPUT +meson setup --cross-file scripts/v5.ini build | tee $COMPILE_STD_OUTPUT meson_exit_code = ${PIPESTATUS[0]} echo "Meson setup exit code: $meson_exit_code" if [ $meson_exit_code -ne 0 ]; then @@ -77,7 +77,7 @@ STD_OUTPUT=$(mktemp) disable-errors # time this command start_time=$(date +%s) -meson compile -C builddir | tee $STD_OUTPUT +meson compile -C build | tee $STD_OUTPUT meson_exit_code=${PIPESTATUS[0]} end_time=$(date +%s) echo "Meson compile exit code: $meson_exit_code" From a120acc6d352ea6142f2ea2f368fcfc6a7ea2132 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 23:32:55 -0500 Subject: [PATCH 37/63] refactor: :art: Make meson compile verbosely --- build-tools/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index d7c65c8..e1ba22d 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -77,7 +77,7 @@ STD_OUTPUT=$(mktemp) disable-errors # time this command start_time=$(date +%s) -meson compile -C build | tee $STD_OUTPUT +meson compile --verbose -C build | tee $STD_OUTPUT meson_exit_code=${PIPESTATUS[0]} end_time=$(date +%s) echo "Meson compile exit code: $meson_exit_code" From b2e716e40bdb7bfcb513657180c065de0d77f8c7 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 23:38:44 -0500 Subject: [PATCH 38/63] refactor: :beers: Don't purge parts of the toolchain to see if code compiles now --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 78ad4d6..eae08cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,13 +18,13 @@ RUN <<-"EOF" bash toolchain="/arm-none-eabi-toolchain" mkdir -p "$toolchain" - rm -rf "$toolchain"/{share,include} - rm -rf "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/arm - rm -f "$toolchain"/bin/arm-none-eabi-{gdb,gdb-py,cpp,gcc-13.3.1} + # rm -rf "$toolchain"/{share,include} + # rm -rf "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/arm + # rm -f "$toolchain"/bin/arm-none-eabi-{gdb,gdb-py,cpp,gcc-13.3.1} - find "$toolchain"/arm-none-eabi/lib/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} + - find "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} + - find "$toolchain"/arm-none-eabi/include/c++/13.3.1/arm-none-eabi/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a*' -exec rm -rf {} + + # find "$toolchain"/arm-none-eabi/lib/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} + + # find "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} + + # find "$toolchain"/arm-none-eabi/include/c++/13.3.1/arm-none-eabi/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a*' -exec rm -rf {} + apk cache clean # Cleanup image EOF From 336cf236d6a7b2c6800132dba5e8a0b2412e9ce4 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 23:45:10 -0500 Subject: [PATCH 39/63] refactor: :fire: burn fp in the pit of hell, and place simd on the throne --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index eae08cf..03cba2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,13 +18,13 @@ RUN <<-"EOF" bash toolchain="/arm-none-eabi-toolchain" mkdir -p "$toolchain" - # rm -rf "$toolchain"/{share,include} - # rm -rf "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/arm - # rm -f "$toolchain"/bin/arm-none-eabi-{gdb,gdb-py,cpp,gcc-13.3.1} + rm -rf "$toolchain"/{share,include} + rm -rf "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/arm + rm -f "$toolchain"/bin/arm-none-eabi-{gdb,gdb-py,cpp,gcc-13.3.1} - # find "$toolchain"/arm-none-eabi/lib/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} + - # find "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+fp' -exec rm -rf {} + - # find "$toolchain"/arm-none-eabi/include/c++/13.3.1/arm-none-eabi/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a*' -exec rm -rf {} + + find "$toolchain"/arm-none-eabi/lib/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+simd' -exec rm -rf {} + + find "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+simd' -exec rm -rf {} + + find "$toolchain"/arm-none-eabi/include/c++/13.3.1/arm-none-eabi/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a*' -exec rm -rf {} + apk cache clean # Cleanup image EOF From c35f45466035e71c9b7b81b6d79e7f36bfbe2b59 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 23:49:43 -0500 Subject: [PATCH 40/63] refactor: :bug: Write directly to github step summary instead of to a temporary file. --- build-tools/build.sh | 59 +++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index e1ba22d..33886f4 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -53,17 +53,16 @@ meson_exit_code = ${PIPESTATUS[0]} echo "Meson setup exit code: $meson_exit_code" if [ $meson_exit_code -ne 0 ]; then echo "Meson setup failed. Please check the logs for more information." - GH_SUMMARY_OUTPUT=$(mktemp) - echo "# 🛑 Meson Setup Failed " > $GH_SUMMARY_OUTPUT - echo "Meson setup failed. Please check the logs for more information. " >> $GH_SUMMARY_OUTPUT - echo "***" >> $GH_SUMMARY_OUTPUT - echo "
Click to expand " >> $GH_SUMMARY_OUTPUT - echo "\`\`\` " >> $GH_SUMMARY_OUTPUT - echo "$COMPILE_STD_OUTPUT" >> $GH_SUMMARY_OUTPUT - echo "\`\`\` " >> $GH_SUMMARY_OUTPUT - echo "
" >> $GH_SUMMARY_OUTPUT + GITHUB_STEP_SUMMARY=$(mktemp) + echo "# 🛑 Meson Setup Failed " > $GITHUB_STEP_SUMMARY + echo "Meson setup failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY + echo "***" >> $GITHUB_STEP_SUMMARY + echo "
Click to expand " >> $GITHUB_STEP_SUMMARY + echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo "$COMPILE_STD_OUTPUT" >> $GITHUB_STEP_SUMMARY + echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY echo "::endgroup::" - echo $GH_SUMMARY_OUTPUT > $GITHUB_STEP_SUMMARY exit 1 fi echo "::endgroup::" @@ -90,16 +89,15 @@ sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" $STD_OUTPUT >$STD_EDITED_ if [ $meson_exit_code -ne 0 ]; then echo "Meson compile failed. Please check the logs for more information." - GH_SUMMARY_OUTPUT=$(mktemp) - echo "# 🛑 Meson Compile Failed " > $GH_SUMMARY_OUTPUT - echo "Meson compile failed. Please check the logs for more information. " >> $GH_SUMMARY_OUTPUT - echo "***" >> $GH_SUMMARY_OUTPUT - echo "
Click to expand " >> $GH_SUMMARY_OUTPUT - echo "\`\`\` " >> $GH_SUMMARY_OUTPUT - echo "$STD_EDITED_OUTPUT" >> $GH_SUMMARY_OUTPUT - echo "\`\`\` " >> $GH_SUMMARY_OUTPUT - echo "
" >> $GH_SUMMARY_OUTPUT - echo $GH_SUMMARY_OUTPUT > $GITHUB_STEP_SUMMARY + GITHUB_STEP_SUMMARY=$(mktemp) + echo "# 🛑 Meson Compile Failed " > $GITHUB_STEP_SUMMARY + echo "Meson compile failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY + echo "***" >> $GITHUB_STEP_SUMMARY + echo "
Click to expand " >> $GITHUB_STEP_SUMMARY + echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo "$STD_EDITED_OUTPUT" >> $GITHUB_STEP_SUMMARY + echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY exit 1 fi echo "::endgroup::" @@ -112,15 +110,14 @@ echo "The build was successful" echo "The build took $elapsed_time seconds" # job summary -GH_SUMMARY_OUTPUT=$(mktemp) -echo "# ✅ Build Successful " > $GH_SUMMARY_OUTPUT -echo "The build was successful. " >> $GH_SUMMARY_OUTPUT -echo "The build took $elapsed_time seconds. " >> $GH_SUMMARY_OUTPUT -echo "***" >> $GH_SUMMARY_OUTPUT -echo "
Click to expand " >> $GH_SUMMARY_OUTPUT -echo "\`\`\` " >> $GH_SUMMARY_OUTPUT -echo "$STD_EDITED_OUTPUT" >> $GH_SUMMARY_OUTPUT -echo "\`\`\` " >> $GH_SUMMARY_OUTPUT -echo "
" >> $GH_SUMMARY_OUTPUT -echo $GH_SUMMARY_OUTPUT > $GITHUB_STEP_SUMMARY +GITHUB_STEP_SUMMARY=$(mktemp) +echo "# ✅ Build Successful " > $GITHUB_STEP_SUMMARY +echo "The build was successful. " >> $GITHUB_STEP_SUMMARY +echo "The build took $elapsed_time seconds. " >> $GITHUB_STEP_SUMMARY +echo "***" >> $GITHUB_STEP_SUMMARY +echo "
Click to expand " >> $GITHUB_STEP_SUMMARY +echo "\`\`\` " >> $GITHUB_STEP_SUMMARY +echo "$STD_EDITED_OUTPUT" >> $GITHUB_STEP_SUMMARY +echo "\`\`\` " >> $GITHUB_STEP_SUMMARY +echo "
" >> $GITHUB_STEP_SUMMARY From d4162c34a97820ed4e0a37c3d11f14bff2dbadfd Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 23:56:19 -0500 Subject: [PATCH 41/63] refactor: :art: Remove verbose flag from meson compile command --- build-tools/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index 33886f4..e5ed7a4 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -76,7 +76,7 @@ STD_OUTPUT=$(mktemp) disable-errors # time this command start_time=$(date +%s) -meson compile --verbose -C build | tee $STD_OUTPUT +meson compile -C build | tee $STD_OUTPUT meson_exit_code=${PIPESTATUS[0]} end_time=$(date +%s) echo "Meson compile exit code: $meson_exit_code" From 7e5f299a0a5ef53e8904afbc966a6b6060e22381 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 23:58:14 -0500 Subject: [PATCH 42/63] style: :bulb: Add comment highlighting with prefixed defined by the Better Comments Next extension --- build-tools/build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index e5ed7a4..88240fb 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -83,8 +83,8 @@ echo "Meson compile exit code: $meson_exit_code" elapsed_time=$((end_time - start_time)) echo "Meson compile took $elapsed_time seconds" STD_EDITED_OUTPUT=$(mktemp) -# Remove ANSI color codes from the output -# https://stackoverflow.com/a/18000433 +# * Remove ANSI color codes from the output +# * https://stackoverflow.com/a/18000433 sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" $STD_OUTPUT >$STD_EDITED_OUTPUT if [ $meson_exit_code -ne 0 ]; then @@ -103,8 +103,8 @@ fi echo "::endgroup::" # ------------ -# BUILD SUCCESS -# FINAL SUMMARY +# # BUILD SUCCESS +# ! FINAL SUMMARY # ------------ echo "The build was successful" echo "The build took $elapsed_time seconds" From 8ac9f12e6364ecef670478bef35accebb9a7bc74 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Thu, 13 Mar 2025 23:59:08 -0500 Subject: [PATCH 43/63] fix: :bug: Fix Step Summary not being written by removing definiton of $GITHUB_STEP_SUMMARY in the script --- build-tools/build.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index 88240fb..d33c51a 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -53,7 +53,6 @@ meson_exit_code = ${PIPESTATUS[0]} echo "Meson setup exit code: $meson_exit_code" if [ $meson_exit_code -ne 0 ]; then echo "Meson setup failed. Please check the logs for more information." - GITHUB_STEP_SUMMARY=$(mktemp) echo "# 🛑 Meson Setup Failed " > $GITHUB_STEP_SUMMARY echo "Meson setup failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY @@ -89,7 +88,6 @@ sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" $STD_OUTPUT >$STD_EDITED_ if [ $meson_exit_code -ne 0 ]; then echo "Meson compile failed. Please check the logs for more information." - GITHUB_STEP_SUMMARY=$(mktemp) echo "# 🛑 Meson Compile Failed " > $GITHUB_STEP_SUMMARY echo "Meson compile failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY @@ -110,7 +108,6 @@ echo "The build was successful" echo "The build took $elapsed_time seconds" # job summary -GITHUB_STEP_SUMMARY=$(mktemp) echo "# ✅ Build Successful " > $GITHUB_STEP_SUMMARY echo "The build was successful. " >> $GITHUB_STEP_SUMMARY echo "The build took $elapsed_time seconds. " >> $GITHUB_STEP_SUMMARY From 5c298867e63a897c14756f74ed6d88c7a564f994 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 00:05:38 -0500 Subject: [PATCH 44/63] fix: :bug: Use cat instead of echo to write stdout output to summary. --- build-tools/build.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index d33c51a..f0fd3cc 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -58,7 +58,7 @@ if [ $meson_exit_code -ne 0 ]; then echo "***" >> $GITHUB_STEP_SUMMARY echo "
Click to expand " >> $GITHUB_STEP_SUMMARY echo "\`\`\` " >> $GITHUB_STEP_SUMMARY - echo "$COMPILE_STD_OUTPUT" >> $GITHUB_STEP_SUMMARY + cat $COMPILE_STD_OUTPUT >> $GITHUB_STEP_SUMMARY echo "\`\`\` " >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY echo "::endgroup::" @@ -89,12 +89,12 @@ sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" $STD_OUTPUT >$STD_EDITED_ if [ $meson_exit_code -ne 0 ]; then echo "Meson compile failed. Please check the logs for more information." echo "# 🛑 Meson Compile Failed " > $GITHUB_STEP_SUMMARY - echo "Meson compile failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY + echo "Meson compile failed in $elapsed_time seconds. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY echo "
Click to expand " >> $GITHUB_STEP_SUMMARY - echo "\`\`\` " >> $GITHUB_STEP_SUMMARY - echo "$STD_EDITED_OUTPUT" >> $GITHUB_STEP_SUMMARY - echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo "\`\`\`\n " >> $GITHUB_STEP_SUMMARY + cat $STD_EDITED_OUTPUT >> $GITHUB_STEP_SUMMARY + echo "\`\`\`\n " >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY exit 1 fi @@ -109,12 +109,11 @@ echo "The build took $elapsed_time seconds" # job summary echo "# ✅ Build Successful " > $GITHUB_STEP_SUMMARY -echo "The build was successful. " >> $GITHUB_STEP_SUMMARY -echo "The build took $elapsed_time seconds. " >> $GITHUB_STEP_SUMMARY +echo "The build was successful and took $elapsed_time seconds. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY echo "
Click to expand " >> $GITHUB_STEP_SUMMARY echo "\`\`\` " >> $GITHUB_STEP_SUMMARY -echo "$STD_EDITED_OUTPUT" >> $GITHUB_STEP_SUMMARY +cat $STD_EDITED_OUTPUT >> $GITHUB_STEP_SUMMARY echo "\`\`\` " >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY From 90bd2b76f1016d7c6818ae00743ac797b31d31b1 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 00:09:13 -0500 Subject: [PATCH 45/63] fix: :bug: Add spacing to GitHub step summary so formatting will actually occur --- build-tools/build.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build-tools/build.sh b/build-tools/build.sh index f0fd3cc..fc67539 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -57,9 +57,13 @@ if [ $meson_exit_code -ne 0 ]; then echo "Meson setup failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY echo "
Click to expand " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY cat $COMPILE_STD_OUTPUT >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY echo "::endgroup::" exit 1 @@ -92,9 +96,13 @@ if [ $meson_exit_code -ne 0 ]; then echo "Meson compile failed in $elapsed_time seconds. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY echo "
Click to expand " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY echo "\`\`\`\n " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY cat $STD_EDITED_OUTPUT >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY echo "\`\`\`\n " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY exit 1 fi @@ -112,8 +120,12 @@ echo "# ✅ Build Successful " > $GITHUB_STEP_SUMMARY echo "The build was successful and took $elapsed_time seconds. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY echo "
Click to expand " >> $GITHUB_STEP_SUMMARY +echo " " >> $GITHUB_STEP_SUMMARY echo "\`\`\` " >> $GITHUB_STEP_SUMMARY +echo " " >> $GITHUB_STEP_SUMMARY cat $STD_EDITED_OUTPUT >> $GITHUB_STEP_SUMMARY +echo " " >> $GITHUB_STEP_SUMMARY echo "\`\`\` " >> $GITHUB_STEP_SUMMARY +echo " " >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY From 4fadc66b94352eeb5d9c42e1d1f89ad93601616d Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 00:19:04 -0500 Subject: [PATCH 46/63] feat: :sparkles: add write_job_summary input --- .github/workflows/build-image.yml | 11 +++-- .github/workflows/test.yml | 8 +-- build-tools/build.sh | 82 +++++++++++++++++-------------- 3 files changed, 55 insertions(+), 46 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index c7f545a..9da1656 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -153,10 +153,13 @@ jobs: # ref: build/meson-init # lib_folder_name: lemlib uses: ./.github/workflows/test.yml - with: - repository: ZestCommunity/ZestCode - ref: main - caller_token: ${{ github.token }} + strategy: + fail-fast: true + matrix: + write_job_summary: [true, false] + repository: [ZestCommunity/ZestCode] + ref: [main] + caller_token: [${{ github.token }}] # expect_error: ${{ matrix.expect_error }} # upload_artifact: ${{ matrix.upload_artifact }} # multithreading: ${{ matrix.multithreading }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9fceabe..d71fbfb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,10 +40,10 @@ on: # Required if add_extra_files is true # default: "" # type: string -# write_job_summary: -# description: Whether to write the artifact URL to the job summary -# default: true -# type: boolean + write_job_summary: + description: Whether to write the artifact URL to the job summary + default: true + type: boolean # artifact_additional_postfix: # description: Additional postfix to add to the artifact name # default: "" diff --git a/build-tools/build.sh b/build-tools/build.sh index fc67539..7e099cf 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -52,19 +52,21 @@ meson setup --cross-file scripts/v5.ini build | tee $COMPILE_STD_OUTPUT meson_exit_code = ${PIPESTATUS[0]} echo "Meson setup exit code: $meson_exit_code" if [ $meson_exit_code -ne 0 ]; then - echo "Meson setup failed. Please check the logs for more information." - echo "# 🛑 Meson Setup Failed " > $GITHUB_STEP_SUMMARY - echo "Meson setup failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY - echo "***" >> $GITHUB_STEP_SUMMARY - echo "
Click to expand " >> $GITHUB_STEP_SUMMARY - echo " " >> $GITHUB_STEP_SUMMARY - echo "\`\`\` " >> $GITHUB_STEP_SUMMARY - echo " " >> $GITHUB_STEP_SUMMARY - cat $COMPILE_STD_OUTPUT >> $GITHUB_STEP_SUMMARY - echo " " >> $GITHUB_STEP_SUMMARY - echo "\`\`\` " >> $GITHUB_STEP_SUMMARY - echo " " >> $GITHUB_STEP_SUMMARY - echo "
" >> $GITHUB_STEP_SUMMARY + echo "Meson setup failed. Please check the logs for more information." + if [ $INPUT_WRITE_JOB_SUMMARY = true ]; then + echo "# 🛑 Meson Setup Failed " > $GITHUB_STEP_SUMMARY + echo "Meson setup failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY + echo "***" >> $GITHUB_STEP_SUMMARY + echo "
Click to expand " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + cat $COMPILE_STD_OUTPUT >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY + fi echo "::endgroup::" exit 1 fi @@ -91,19 +93,21 @@ STD_EDITED_OUTPUT=$(mktemp) sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" $STD_OUTPUT >$STD_EDITED_OUTPUT if [ $meson_exit_code -ne 0 ]; then - echo "Meson compile failed. Please check the logs for more information." - echo "# 🛑 Meson Compile Failed " > $GITHUB_STEP_SUMMARY - echo "Meson compile failed in $elapsed_time seconds. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY - echo "***" >> $GITHUB_STEP_SUMMARY - echo "
Click to expand " >> $GITHUB_STEP_SUMMARY - echo " " >> $GITHUB_STEP_SUMMARY - echo "\`\`\`\n " >> $GITHUB_STEP_SUMMARY - echo " " >> $GITHUB_STEP_SUMMARY - cat $STD_EDITED_OUTPUT >> $GITHUB_STEP_SUMMARY - echo " " >> $GITHUB_STEP_SUMMARY - echo "\`\`\`\n " >> $GITHUB_STEP_SUMMARY - echo " " >> $GITHUB_STEP_SUMMARY - echo "
" >> $GITHUB_STEP_SUMMARY + if [ $INPUT_WRITE_JOB_SUMMARY = true ]; then + echo "Meson compile failed. Please check the logs for more information." + echo "# 🛑 Meson Compile Failed " > $GITHUB_STEP_SUMMARY + echo "Meson compile failed in $elapsed_time seconds. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY + echo "***" >> $GITHUB_STEP_SUMMARY + echo "
Click to expand " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + echo "\`\`\`\n " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + cat $STD_EDITED_OUTPUT >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + echo "\`\`\`\n " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY + fi exit 1 fi echo "::endgroup::" @@ -116,16 +120,18 @@ echo "The build was successful" echo "The build took $elapsed_time seconds" # job summary -echo "# ✅ Build Successful " > $GITHUB_STEP_SUMMARY -echo "The build was successful and took $elapsed_time seconds. " >> $GITHUB_STEP_SUMMARY -echo "***" >> $GITHUB_STEP_SUMMARY -echo "
Click to expand " >> $GITHUB_STEP_SUMMARY -echo " " >> $GITHUB_STEP_SUMMARY -echo "\`\`\` " >> $GITHUB_STEP_SUMMARY -echo " " >> $GITHUB_STEP_SUMMARY -cat $STD_EDITED_OUTPUT >> $GITHUB_STEP_SUMMARY -echo " " >> $GITHUB_STEP_SUMMARY -echo "\`\`\` " >> $GITHUB_STEP_SUMMARY -echo " " >> $GITHUB_STEP_SUMMARY -echo "
" >> $GITHUB_STEP_SUMMARY +if [ $INPUT_WRITE_JOB_SUMMARY = true ]; then + echo "# ✅ Build Successful " > $GITHUB_STEP_SUMMARY + echo "The build was successful and took $elapsed_time seconds. " >> $GITHUB_STEP_SUMMARY + echo "***" >> $GITHUB_STEP_SUMMARY + echo "
Click to expand " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + cat $STD_EDITED_OUTPUT >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + echo "\`\`\` " >> $GITHUB_STEP_SUMMARY + echo " " >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY +fi From 89a51d8483a843f22461c1691bf1f88bc5e06958 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 02:08:02 -0500 Subject: [PATCH 47/63] fix: :bug: Replace alias with functions for error handling in build script --- build-tools/build.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index 7e099cf..5df3168 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -1,11 +1,13 @@ #!/bin/bash # git clone https://github.com/ZestCommunity/ZestCode.git && cd ZestCode && git switch build/meson-init && sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && meson setup --cross-file scripts/v5.ini builddir && meson compile -C builddir -# Flag to control error trapping -trap_enabled=true +disable-errors() { + set +e +} -alias disable-errors="set +e" -alias enable-errors="set -e" +enable-errors() { + set -e +} # start time in seconds script_start_time=$(date +%s) From 12343eefcde07337276316cbc4275a880bfaa093 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:28:30 -0500 Subject: [PATCH 48/63] ci: :bug: (Maybe?) Correct syntax error in build-image.yml --- .github/workflows/build-image.yml | 63 +------------------------------ 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 9da1656..94122be 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -103,73 +103,14 @@ jobs: test-action: needs: Build_Container - # strategy: - # fail-fast: true - # matrix: - # repository: [zestcommunity/ZestCode] - # multithreading: [false] - # upload_artifact: [false] - # append_sha_to_version: [false] - # add_extra_files: [false] - # write_job_summary: [false] - # expect_error: [false] - # # exclude: - # # - expect_error: true - # # repository: EZ-Robotics/EZ-Template - - # # - multithreading: false - # # append_sha_to_version: false - # # - multithreading: false - # # upload_artifact: false - # # - multithreading: false - # # add_extra_files: false - # # repository: lemlib/lemlib - # # - multithreading: false - # # write_job_summary: false - - # # - upload_artifact: false - # # append_sha_to_version: true - # # - upload_artifact: false - # # add_extra_files: true - # # - upload_artifact: true - # # expect_error: true - - # # - append_sha_to_version: false - # # add_extra_files: false - # # upload_artifact: true - # # repository: lemlib/lemlib - # # - append_sha_to_version: false - # # write_job_summary: false - - # # - add_extra_files: true - # # repository: EZ-Robotics/EZ-Template - # # - add_extra_files: false - # # write_job_summary: false - - - # include: - # - repository: lemlib/lemlib - # expect_error: false - # ref: build/meson-init - # lib_folder_name: lemlib uses: ./.github/workflows/test.yml strategy: fail-fast: true matrix: write_job_summary: [true, false] repository: [ZestCommunity/ZestCode] - ref: [main] - caller_token: [${{ github.token }}] - # expect_error: ${{ matrix.expect_error }} - # upload_artifact: ${{ matrix.upload_artifact }} - # multithreading: ${{ matrix.multithreading }} - # append_sha_to_version: ${{ matrix.append_sha_to_version }} - # add_extra_files: ${{ matrix.add_extra_files }} - # lib_folder_name: ${{ matrix.lib_folder_name }} - # write_job_summary: ${{ matrix.write_job_summary }} - # artifact_additional_postfix: | - # ${{ format('---.err{0}.upl{1}.thread{2}.sha{3}.files{4}.summ{5}', matrix.expect_error && 1 || 0, matrix.upload_artifact && 1 || 0, matrix.multithreading && 1 || 0, matrix.append_sha_to_version && 1 || 0, matrix.add_extra_files && 1 || 0, matrix.write_job_summary && 1 || 0 )}} - # publish-build: # Publish the image to the registry + ref: main + caller_token: ${{ github.token }} # permissions: # contents: read # packages: write From 1dc969bd20dfa415d5d0c5c40b3e8bb7b9b6043e Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:33:05 -0500 Subject: [PATCH 49/63] revert: :green_heart: Undo syntax change since it caused a different issue --- .github/workflows/build-image.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 94122be..532dd91 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -101,7 +101,7 @@ jobs: tag: ${{ env.IMAGE_NAME }} artifact_id: ${{ steps.upload.outputs.artifact-id }} - test-action: + Test_Action: needs: Build_Container uses: ./.github/workflows/test.yml strategy: @@ -109,8 +109,8 @@ jobs: matrix: write_job_summary: [true, false] repository: [ZestCommunity/ZestCode] - ref: main - caller_token: ${{ github.token }} + ref: [main] + caller_token: [${{ github.token }}] # permissions: # contents: read # packages: write From 43a2c7686e875fc1c5b4928e389d5132a976da99 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:34:37 -0500 Subject: [PATCH 50/63] ci: :green_heart: Maybe fix build-image workflow (fr this time) --- .github/workflows/build-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 532dd91..2f0a9ea 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -109,8 +109,8 @@ jobs: matrix: write_job_summary: [true, false] repository: [ZestCommunity/ZestCode] - ref: [main] - caller_token: [${{ github.token }}] + ref: ["main"] + caller_token: ["${{ github.token }}"] # permissions: # contents: read # packages: write From 8c8c4f0f0c2bc2539ff806ace4a2712aeb9999e0 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:35:55 -0500 Subject: [PATCH 51/63] =?UTF-8?q?ci:=20=F0=9F=92=9A=20Correct=20repository?= =?UTF-8?q?=20format=20in=20build-image.yml,=20possibly=20fixing=20build-i?= =?UTF-8?q?mage=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 2f0a9ea..bf88f40 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -108,7 +108,7 @@ jobs: fail-fast: true matrix: write_job_summary: [true, false] - repository: [ZestCommunity/ZestCode] + repository: ["ZestCommunity/ZestCode"] ref: ["main"] caller_token: ["${{ github.token }}"] # permissions: From 72186d670c753406b16101527bc732c776499f57 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:39:25 -0500 Subject: [PATCH 52/63] ci: :green_heart: fix CI build (Hopefully actually fr this time) --- .github/workflows/build-image.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index bf88f40..b5103f4 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -111,6 +111,11 @@ jobs: repository: ["ZestCommunity/ZestCode"] ref: ["main"] caller_token: ["${{ github.token }}"] + with: + write_job_summary: ${{ matrix.write_job_summary }} + repository: ${{ matrix.repository }} + ref: ${{ matrix.ref }} + caller_token: ${{ matrix.caller_token }} # permissions: # contents: read # packages: write From a73f1b579011c6388cbda7c27ac06de1e64a0ff9 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:42:08 -0500 Subject: [PATCH 53/63] fix: :bug: Make the write_job_summary input actually work --- build-tools/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index 5df3168..a39de03 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -55,7 +55,7 @@ meson_exit_code = ${PIPESTATUS[0]} echo "Meson setup exit code: $meson_exit_code" if [ $meson_exit_code -ne 0 ]; then echo "Meson setup failed. Please check the logs for more information." - if [ $INPUT_WRITE_JOB_SUMMARY = true ]; then + if [ $INPUT_WRITE_JOB_SUMMARY -eq true ]; then echo "# 🛑 Meson Setup Failed " > $GITHUB_STEP_SUMMARY echo "Meson setup failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY @@ -95,7 +95,7 @@ STD_EDITED_OUTPUT=$(mktemp) sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" $STD_OUTPUT >$STD_EDITED_OUTPUT if [ $meson_exit_code -ne 0 ]; then - if [ $INPUT_WRITE_JOB_SUMMARY = true ]; then + if [ $INPUT_WRITE_JOB_SUMMARY -eq true ]; then echo "Meson compile failed. Please check the logs for more information." echo "# 🛑 Meson Compile Failed " > $GITHUB_STEP_SUMMARY echo "Meson compile failed in $elapsed_time seconds. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY From 18516fb1015294ad859aa6dd603225a5ef5cd48b Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:49:08 -0500 Subject: [PATCH 54/63] fix: :bug: Fix conditional check for INPUT_WRITE_JOB_SUMMARY --- build-tools/build.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build-tools/build.sh b/build-tools/build.sh index a39de03..7dfc096 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -51,11 +51,11 @@ git config --global --add safe.directory /github/workspace COMPILE_STD_OUTPUT=$(mktemp) echo "::group::Build Project" meson setup --cross-file scripts/v5.ini build | tee $COMPILE_STD_OUTPUT -meson_exit_code = ${PIPESTATUS[0]} +meson_exit_code=${PIPESTATUS[0]} echo "Meson setup exit code: $meson_exit_code" if [ $meson_exit_code -ne 0 ]; then echo "Meson setup failed. Please check the logs for more information." - if [ $INPUT_WRITE_JOB_SUMMARY -eq true ]; then + if [ "$INPUT_WRITE_JOB_SUMMARY" == "true" ]; then echo "# 🛑 Meson Setup Failed " > $GITHUB_STEP_SUMMARY echo "Meson setup failed. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY @@ -95,7 +95,7 @@ STD_EDITED_OUTPUT=$(mktemp) sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" $STD_OUTPUT >$STD_EDITED_OUTPUT if [ $meson_exit_code -ne 0 ]; then - if [ $INPUT_WRITE_JOB_SUMMARY -eq true ]; then + if [ "$INPUT_WRITE_JOB_SUMMARY" == "true" ]; then echo "Meson compile failed. Please check the logs for more information." echo "# 🛑 Meson Compile Failed " > $GITHUB_STEP_SUMMARY echo "Meson compile failed in $elapsed_time seconds. Please check the logs for more information. " >> $GITHUB_STEP_SUMMARY @@ -122,7 +122,7 @@ echo "The build was successful" echo "The build took $elapsed_time seconds" # job summary -if [ $INPUT_WRITE_JOB_SUMMARY = true ]; then +if [ "$INPUT_WRITE_JOB_SUMMARY" == "true" ]; then echo "# ✅ Build Successful " > $GITHUB_STEP_SUMMARY echo "The build was successful and took $elapsed_time seconds. " >> $GITHUB_STEP_SUMMARY echo "***" >> $GITHUB_STEP_SUMMARY @@ -135,5 +135,4 @@ if [ $INPUT_WRITE_JOB_SUMMARY = true ]; then echo "\`\`\` " >> $GITHUB_STEP_SUMMARY echo " " >> $GITHUB_STEP_SUMMARY echo " " >> $GITHUB_STEP_SUMMARY -fi - +fi \ No newline at end of file From 18e610e3690d14a29f3317c77f840f46163c3579 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:50:26 -0500 Subject: [PATCH 55/63] fix: :bug: Add write_job_summary input to Test Action in test.yml --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d71fbfb..9f45d35 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -115,4 +115,6 @@ jobs: - name: Test Action id: test-action uses: ./action/ - continue-on-error: False \ No newline at end of file + continue-on-error: False + with: + write_job_summary: ${{ inputs.write_job_summary }} \ No newline at end of file From 3920da6608c421ca1fdb7f88c731707a333f5995 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Fri, 14 Mar 2025 16:01:17 -0500 Subject: [PATCH 56/63] test: :bug: Add debugging output for Meson setup exit code in build.sh --- build-tools/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build-tools/build.sh b/build-tools/build.sh index 7dfc096..91088ac 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -51,6 +51,7 @@ git config --global --add safe.directory /github/workspace COMPILE_STD_OUTPUT=$(mktemp) echo "::group::Build Project" meson setup --cross-file scripts/v5.ini build | tee $COMPILE_STD_OUTPUT +echo "PIPESTATUS: ${PIPESTATUS[@]}" meson_exit_code=${PIPESTATUS[0]} echo "Meson setup exit code: $meson_exit_code" if [ $meson_exit_code -ne 0 ]; then From e731f342b0446bc6d16abd4daaef93bb3f9332fc Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Sun, 16 Mar 2025 19:56:44 -0500 Subject: [PATCH 57/63] docs: :memo: Start filling out README.md --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9dcc4f6..be99844 100644 --- a/README.md +++ b/README.md @@ -1 +1,35 @@ -# build-action \ No newline at end of file +# ZestCode Build Action +An automated build action for ZestCode projects. + +## Usage: +### Example: +```yml +name: ZestCode Build Action Example + +on: + push: + branches: "**" + pull_request: + branches: "**" + + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run Build Action + id: test + uses: ZestCommunity/build-action@main +``` +### Inputs: +> `write_job_summary` +> - **Whether to output to GitHub's Job Summary** +> - Required: False +> - Default: True + +## Notes +This container was based on LemLib/pros-build. \ No newline at end of file From 5981594afc0a6191f747c3c6cb9e5c992319f5aa Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Sun, 16 Mar 2025 19:58:31 -0500 Subject: [PATCH 58/63] ci: :sparkles: Add Upload_Image job to build-image.yml and upload binary in test.yml --- .github/workflows/build-image.yml | 75 ++++++++++++++++--------------- .github/workflows/test.yml | 9 +++- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index b5103f4..f56e475 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -116,40 +116,41 @@ jobs: repository: ${{ matrix.repository }} ref: ${{ matrix.ref }} caller_token: ${{ matrix.caller_token }} - # permissions: - # contents: read - # packages: write - # needs: - # [ - # Build_Container - # # test-action - # ] - # runs-on: ubuntu-latest - # if: ${{ github.event_name != 'pull_request' }} - # steps: - # - name: Checkout repository - # uses: actions/checkout@v4 - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 - # - name: Log into registry ${{ env.REGISTRY }} - # uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 - # with: - # registry: ${{ env.REGISTRY }} - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} - # - name: Download Image - # uses: actions/download-artifact@v4 - # with: - # name: image.tar - # github-token: ${{ secrets.GITHUB_TOKEN }} - # - name: Load Image - # id: load - # run: | - # echo "tag=$(docker load -i ./image.tar | grep -oP 'Loaded image: \K.*' | tr '\n' ' ')" > $GITHUB_OUTPUT - # - name: Push the image - # if: ${{ github.event_name != 'pull_request' }} - # run: | - # for tag in $(echo "${{ steps.load.outputs.tag }}" | tr ' ' '\n'); do - # echo "$tag" - # docker push "$tag" - # done \ No newline at end of file + Upload_Image: + permissions: + contents: read + packages: write + needs: + [ + Build_Container, + Test_Action + ] + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Download Image + uses: actions/download-artifact@v4 + with: + name: image.tar + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Load Image + id: load + run: | + echo "tag=$(docker load -i ./image.tar | grep -oP 'Loaded image: \K.*' | tr '\n' ' ')" > $GITHUB_OUTPUT + - name: Push the image + if: ${{ github.event_name != 'pull_request' }} + run: | + for tag in $(echo "${{ steps.load.outputs.tag }}" | tr ' ' '\n'); do + echo "$tag" + docker push "$tag" + done \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f45d35..b36d6de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -117,4 +117,11 @@ jobs: uses: ./action/ continue-on-error: False with: - write_job_summary: ${{ inputs.write_job_summary }} \ No newline at end of file + write_job_summary: ${{ inputs.write_job_summary }} + + - name: Upload Binary + id: upload + uses: actions/upload-artifact@v4 + with: + name: "program.bin" + path: "build/program.bin" \ No newline at end of file From a10e40d572357bb9ddaa797c7a62d18192ca1b34 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Sun, 16 Mar 2025 20:00:55 -0500 Subject: [PATCH 59/63] ci: :fire: Disable binary uploading step --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b36d6de..cf4b6e0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -119,9 +119,9 @@ jobs: with: write_job_summary: ${{ inputs.write_job_summary }} - - name: Upload Binary - id: upload - uses: actions/upload-artifact@v4 - with: - name: "program.bin" - path: "build/program.bin" \ No newline at end of file + # - name: Upload Binary + # id: upload + # uses: actions/upload-artifact@v4 + # with: + # name: "program.bin+${{ github.event.number }}" + # path: "build/program.bin" \ No newline at end of file From db0fb07c5484a53a9ac1f01146903ea2806adf71 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Sun, 16 Mar 2025 20:05:19 -0500 Subject: [PATCH 60/63] ci: :sparkles: Update job names in build-image.yml and test.yml --- .github/workflows/build-image.yml | 4 ++++ .github/workflows/test.yml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index f56e475..4993d52 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -24,6 +24,7 @@ concurrency: cancel-in-progress: true jobs: Build_Container: + name: Build Docker Container runs-on: ubuntu-latest permissions: contents: read @@ -102,6 +103,7 @@ jobs: artifact_id: ${{ steps.upload.outputs.artifact-id }} Test_Action: + name: Test Docker Container/GitHub Action needs: Build_Container uses: ./.github/workflows/test.yml strategy: @@ -116,7 +118,9 @@ jobs: repository: ${{ matrix.repository }} ref: ${{ matrix.ref }} caller_token: ${{ matrix.caller_token }} + Upload_Image: + name: Upload Docker Image to ghcr.io Registry permissions: contents: read packages: write diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf4b6e0..bead1e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,7 +52,7 @@ on: jobs: test: - name: "Testing Container" + name: "Testing Container ${{ inputs.write_job_summary }}" runs-on: ubuntu-latest steps: # - name: Summarize Parameters From 4ba928d0d0d1006cb61c7efbcbf412ceaf9467b6 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Sun, 16 Mar 2025 20:08:04 -0500 Subject: [PATCH 61/63] ci: :sparkles: Update job name format in test.yml for clarity --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bead1e5..cb921a2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,7 +52,7 @@ on: jobs: test: - name: "Testing Container ${{ inputs.write_job_summary }}" + name: "Testing Container: Write Job Summary?${{ inputs.write_job_summary }}" runs-on: ubuntu-latest steps: # - name: Summarize Parameters From 72f84c9e85fde5e8cb4a3b2930127cb2bb9ef1f8 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Sun, 16 Mar 2025 20:24:41 -0500 Subject: [PATCH 62/63] refactor: :art: Remove all mentions of pros and commented out code --- .github/workflows/test.yml | 69 +--------------- Dockerfile | 10 +-- build-tools/archive/build.py | 152 ----------------------------------- build-tools/build.sh | 21 ----- 4 files changed, 2 insertions(+), 250 deletions(-) delete mode 100644 build-tools/archive/build.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb921a2..331feef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,64 +14,16 @@ on: description: "The token of the caller" required: true type: string -# expect_error: -# description: Whether to expect action to fail, and only to succeed if the action fails -# default: false -# type: boolean -# upload_artifact: -# description: Whether to create an artifact. Disabled if expect_error is true. -# default: true -# type: boolean -# multithreading: -# description: Whether to use multithreading when building the project -# default: true -# type: boolean -# append_sha_to_version: -# description: Whether to append the short commit sha to the version of the artifact -# default: true -# type: boolean -# add_extra_files: -# description: Whether to add LICENSE, README, and VERSION to artifact. -# default: false -# type: boolean -# lib_folder_name: -# description: | -# The name of the folder under the include directory that contains the headers for the project. -# Required if add_extra_files is true -# default: "" -# type: string write_job_summary: description: Whether to write the artifact URL to the job summary default: true - type: boolean -# artifact_additional_postfix: -# description: Additional postfix to add to the artifact name -# default: "" -# type: string -# required: false + type: boolean jobs: test: name: "Testing Container: Write Job Summary?${{ inputs.write_job_summary }}" runs-on: ubuntu-latest steps: -# - name: Summarize Parameters -# run: | -# echo " -# ## Parameters -# | Param | Value | -# | ------------- | ------------- | -# | :package: repo | ${{ inputs.repository }} | -# | :label: ref | ${{ inputs.ref }} | -# | :rotating_light: expect err | ${{ inputs.expect_error }} | -# | :arrow_up: upload | ${{ inputs.upload_artifact }} | -# | :thread: multithread | ${{ inputs.multithreading }} | -# | :closed_lock_with_key: append sha | ${{ inputs.append_sha_to_version }} | -# | :heavy_plus_sign: add extras | ${{ inputs.add_extra_files }} | -# | :memo: summary | ${{ inputs.write_job_summary }} | -# | :card_file_box: lib folder | ${{ inputs.lib_folder_name }} | -# | :bookmark: postfix | ${{ inputs.artifact_additional_postfix }} -# " | sed "s/true/:white_check_mark: true/g" | sed "s/false/❌ false/g" >> $GITHUB_STEP_SUMMARY - name: Checkout uses: actions/checkout@v4 with: @@ -100,28 +52,9 @@ jobs: sed -i "s|Dockerfile|docker://${{steps.load.outputs.tag}}|g" action/action.yml cat action/action.yml - # - name: Test Action - # id: test-action - # run: | - # docker run --rm --entrypoint /bin/bash -v ./ZestCode:/workspace/ZestCode ${{ steps.load.outputs.tag }} -c " - # ls -a && - # cd /workspace && - # ls -a && - # cd ZestCode && - # sed -i 's/-mfloat-abi=hard/-mfloat-abi=softfp/g' scripts/v5.ini && - # meson setup --cross-file scripts/v5.ini builddir && - # meson compile -C builddir - # " - name: Test Action id: test-action uses: ./action/ continue-on-error: False with: write_job_summary: ${{ inputs.write_job_summary }} - - # - name: Upload Binary - # id: upload - # uses: actions/upload-artifact@v4 - # with: - # name: "program.bin+${{ github.event.number }}" - # path: "build/program.bin" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 03cba2a..7ee5982 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,16 +45,8 @@ ENV PATH="/arm-none-eabi-toolchain/bin:/root/.local/bin:${PATH}" ENV PYTHONUNBUFFERED=1 -# Setup Build -# ENV PROS_PROJECT=${PROS_PROJECT} -# ENV REPOSITORY=${REPOSITORY} -# ENV LIBRARY_PATH=${LIBRARY_PATH} - COPY build-tools/build.sh /build.sh RUN chmod +x /build.sh -# COPY build-tools/build.py /build.py -# RUN chmod +x /build.py COPY LICENSE /LICENSE -ENTRYPOINT ["/build.sh"] -# CMD ["python3", "/build.py"] \ No newline at end of file +ENTRYPOINT ["/build.sh"] \ No newline at end of file diff --git a/build-tools/archive/build.py b/build-tools/archive/build.py deleted file mode 100644 index 03b8e62..0000000 --- a/build-tools/archive/build.py +++ /dev/null @@ -1,152 +0,0 @@ -#! /usr/bin/env python3 -import os -import sys -import subprocess -import time -import argparse -import logging -import io -import tempfile - -print("# ZestCommunity/build-action build.py") -# Set up logging -logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') -logger = logging.getLogger(__name__) - -# args -parser = argparse.ArgumentParser( - prog='Build Action', - description='The build action for the build-action', - epilog='This is the build.py script for ZestCommunity/build-action. This is not the ZestCli nor is it Meson. THIS IS ONLY INTENDED TO RUN ON THE GITHUB ACTION DOCKER CONTAINER.',) - -parser.add_argument('--multithread', action='store_true', help='Enable multithreading for the build') -parser.add_argument('--debug', action='store_true', help='Enable debug mode for the build') -args = parser.parse_args() - -script_start_time = time.time() -build_start_time = -1 - -def group(name: str): - print(f"::group::{name}") -def endgroup(): - print("::endgroup::") - - -""" -ECHO LICENSE -""" -try: - group("LICENSE") - with open("/LICENSE", "r") as f: - print(f.read()) - endgroup() -except FileNotFoundError: - # print("LICENSE file not found. This is an issue with the action container and not your code.") - logger.error("LICENSE file not found. This is an issue with the action container and not your code.") -except Exception as e: - # print(f"Error reading build-action's LICENSE file: {e}") - logger.error(f"Error reading build-action's LICENSE file: {e}") -endgroup() - -subprocess.run("git config --global --add safe.directory /github/workspace", shell=True, check=True) -""" -BUILD AND COMPILE PROJECT -""" -global setup_output -global setup_process -global setup_output_err -group("Setup Project") -try: - with tempfile.NamedTemporaryFile(delete=False) as setup_output: - setup_process = subprocess.Popen( - "tasklist", - shell=True, - text=True, - stdout=subprocess.PIPE, - ) - - # setup_output, setup_output_err = setup_process.communicate() - # print(setup_output) - if setup_process.returncode != 0: - raise subprocess.CalledProcessError(setup_process.returncode, setup_process.args, output=setup_process.stdout, stderr=setup_process.stderr) -except subprocess.CalledProcessError as e: - text = "# 🛑 Meson Setup Failed\n" - text += "An error occurred while running the `meson setup` command. Please check the error output below for more details.\n\n" - text += "#### 📄 Error Output\n" - text += "
Click to expand " - text += "```\n" - text += setup_output - text += "\n```\n" - text += "
\n" - text += "\n" - # write to $GITHUB_STEP_SUMMARY - with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: - f.write(text) - logger.error(f"Meson setup failed with error: {e}") - logger.error("Meson setup failed. Exiting.") - endgroup() - sys.exit(1) - -""" -BUILD PROJECT -""" - -global build_finish_time -global build_duration -global compile_output -global compile_output_err -group("Build Project") -build_start_time = time.time() -try: - compile_output_process = subprocess.Popen( - "meson compile -C builddir", - shell=True, - text=True - ) - compile_output, compile_output_err = compile_output_process.communicate() - build_finish_time = time.time() - build_duration = build_finish_time - build_start_time - - # if compile_output.returncode != 0, throw an error - if compile_output_process.returncode != 0: - raise subprocess.CalledProcessError(compile_output_process.returncode, compile_output_process.args, output=compile_output_process.stdout, stderr=compile_output_process.stderr) -except subprocess.CalledProcessError as e: - # If build_finish_time is not set, set it to the current time - if 'build_duration' not in globals(): - build_finish_time = time.time() - build_duration = build_finish_time - build_start_time - text = "# 🛑 Meson Compile Failed\n" - text += "An error occurred while running the `meson compile` command. Please check the error output below for more details.\n\n" - text += "#### 📄 Error Output\n" - text += "
Click to expand " - text += "```\n" - text += compile_output.stdout - text += "\n```\n" - text += "
\n" - text += "\n" - # write to $GITHUB_STEP_SUMMARY - with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: - f.write(text) - logger.error(f"Meson compile failed with error: {e}") - logger.error("Meson compile failed. Exiting.") - endgroup() - sys.exit(1) - -endgroup() - -text = "# ✅ Build Successful\n" -text += "The build was successful. Please check the output below for more details.\n\n" -text += "#### 📄 Build Output\n" -text += "
Click to expand " -text += "```\n" -text += compile_output.stdout -text += "\n```\n" -text += "
\n" -text += "\n" -text += f"#### ⏱️ Build Time\n" -text += f"The build took {build_duration:.2f} seconds.\n" -text += "\n" - -# write to $GITHUB_STEP_SUMMARY -with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f: - f.write(text) \ No newline at end of file diff --git a/build-tools/build.sh b/build-tools/build.sh index 91088ac..32be56f 100644 --- a/build-tools/build.sh +++ b/build-tools/build.sh @@ -13,27 +13,6 @@ enable-errors() { script_start_time=$(date +%s) build_start_time=-1 -# # ------------ -# # CREATE TRAP -# # ------------ -# # Create a trap to catch errors and print the error message -# trap '[[ $trap_enabled == true ]] && error' ERR - -# function error() { -# GITHUB_BUILD_SUMMARY_OUTPUT=$(mktemp) -# echo "# 🛑 Build Failed\n" -# echo "The build failed. Please check the logs for more information.\n" -# echo "***" -# # if build_start_time is -1, then the build has not started yet -# if [ $build_start_time -eq -1 ]; then -# echo "The build failed to start. This could mean an error occured in the script itself, and if so, consider opening an issue on https://github.com/ZestCommunity/build-action/issues." -# else -# # calculate the elapsed time -# end_time=$(date +%s) -# elapsed_time=$((end_time - $build_start_time)) -# echo "The build failed after $elapsed_time seconds." -# fi -# } # ------------ # ECHO LICENSE # ------------ From dfd605e6fa6602b62b1862adc7cbb21652941000 Mon Sep 17 00:00:00 2001 From: ABUCKY0 <81783950+ABUCKY0@users.noreply.github.com> Date: Mon, 17 Mar 2025 22:16:11 -0500 Subject: [PATCH 63/63] =?UTF-8?q?fix:=20=E2=9C=82=EF=B8=8Fchange=20v7-a*?= =?UTF-8?q?=20to=20v7-a+simd=20in=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ee5982..84a7730 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN <<-"EOF" bash find "$toolchain"/arm-none-eabi/lib/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+simd' -exec rm -rf {} + find "$toolchain"/lib/gcc/arm-none-eabi/13.3.1/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+simd' -exec rm -rf {} + - find "$toolchain"/arm-none-eabi/include/c++/13.3.1/arm-none-eabi/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a*' -exec rm -rf {} + + find "$toolchain"/arm-none-eabi/include/c++/13.3.1/arm-none-eabi/thumb -mindepth 1 -maxdepth 1 ! -name 'v7-a+simd' -exec rm -rf {} + apk cache clean # Cleanup image EOF @@ -49,4 +49,4 @@ COPY build-tools/build.sh /build.sh RUN chmod +x /build.sh COPY LICENSE /LICENSE -ENTRYPOINT ["/build.sh"] \ No newline at end of file +ENTRYPOINT ["/build.sh"]