From 3f9797cc0f14afede9fc61e92c390ac3c7111bcf Mon Sep 17 00:00:00 2001 From: Avi Vajpeyi Date: Wed, 11 Dec 2024 12:49:29 +1300 Subject: [PATCH 1/8] update COMPAS complie workflow with newer versions of actions --- .github/workflows/compas-compile-ci.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/compas-compile-ci.yml b/.github/workflows/compas-compile-ci.yml index 6d30caa96..5493335a4 100644 --- a/.github/workflows/compas-compile-ci.yml +++ b/.github/workflows/compas-compile-ci.yml @@ -12,6 +12,12 @@ name: COMPAS compile test push: branches: - dev + - +# Ensures only the latest workflow run for the same branch is active, canceling any in-progress runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: compas: env: @@ -25,10 +31,10 @@ jobs: fail-fast: false matrix: os: - - ubuntu-20.04 + - ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.9' cache: pip @@ -36,7 +42,7 @@ jobs: - name: Install TeXLive uses: teatimeguest/setup-texlive-action@v3 - name: Install dependencies on ubuntu - if: 'startsWith(matrix.os, ''ubuntu-20'')' + if: 'startsWith(matrix.os, ''ubuntu-2'')' run: | cd misc/cicd-scripts chmod 755 linux-dependencies @@ -67,7 +73,7 @@ jobs: coverage html coverage-badge -o coverage_badge.svg -f - name: Archive code coverage results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: code-coverage path: | @@ -75,8 +81,15 @@ jobs: coverage_badge.svg - name: Archive COMPAS detailed-evolution plot id: upload - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4 with: name: '${{ env.ARTIFACT_NAME }}' path: '${{ env.ARTIFACT_PATH }}/${{ env.ARTIFACT_NAME }}' if-no-files-found: error + - name: Test Summary + run: | + echo "### Test Results" >> $GITHUB_STEP_SUMMARY + echo "- Compas Build: Success" >> $GITHUB_STEP_SUMMARY + echo "- Python Utils Installation: Success" >> $GITHUB_STEP_SUMMARY + echo "- Example COMPAS Job: Success" >> $GITHUB_STEP_SUMMARY + echo "- Pytest Execution: Success" >> $GITHUB_STEP_SUMMARY From c52f715e7b8dad1a1dd852a9347abe2323e7f863 Mon Sep 17 00:00:00 2001 From: Avi Vajpeyi Date: Wed, 11 Dec 2024 12:52:59 +1300 Subject: [PATCH 2/8] use the dockerhub login action and docker buildx to speed up docker image building --- .github/workflows/dockerhub-ci.yml | 43 ++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/.github/workflows/dockerhub-ci.yml b/.github/workflows/dockerhub-ci.yml index 2fadc4412..f032aa9a7 100755 --- a/.github/workflows/dockerhub-ci.yml +++ b/.github/workflows/dockerhub-ci.yml @@ -5,26 +5,41 @@ on: branches: [ dev ] workflow_dispatch: null +# Ensures only the latest workflow run for the same branch is active, canceling any in-progress runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: release: name: Build Docker image and push to DockerHub - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v4 + - name: Log in to Dockerhub - run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} - + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Get release version run: echo "COMPAS_VERSION=$(sed -n '/const std::string VERSION_STRING/,/^$/p' ./src/changelog.h | sed 's/.*"\(.*\)"[^"]*$/\1/')" >> $GITHUB_ENV - + - name: Print version run: echo $COMPAS_VERSION - - - name: Build and tag Docker image - run: docker build -t teamcompas/compas:$COMPAS_VERSION -t teamcompas/compas:latest . - - - name: Push Docker image - run: | - docker push teamcompas/compas:$COMPAS_VERSION - docker push teamcompas/compas:latest + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + teamcompas/compas:${{ env.COMPAS_VERSION }} + teamcompas/compas:latest + cache-from: type=gha + cache-to: type=gha,mode=max + From d68f8e71383359b8e207eff7a0adf70118ea5bdf Mon Sep 17 00:00:00 2001 From: Avi Vajpeyi Date: Wed, 11 Dec 2024 13:02:24 +1300 Subject: [PATCH 3/8] update the PR commenter and precommit checker --- .../workflows/pr_artifact_url_commenter.yml | 44 ++++++++----------- .github/workflows/precommit-checks.yml | 14 ++++-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/pr_artifact_url_commenter.yml b/.github/workflows/pr_artifact_url_commenter.yml index dae1097fd..50abed9b3 100644 --- a/.github/workflows/pr_artifact_url_commenter.yml +++ b/.github/workflows/pr_artifact_url_commenter.yml @@ -1,4 +1,4 @@ -name: Comment on Pull request +name: Comment on Pull Request on: workflow_run: @@ -9,60 +9,51 @@ on: jobs: comment: runs-on: ubuntu-latest - continue-on-error: true + if: ${{ github.event.workflow_run.conclusion == 'success' }} + continue-on-error: true # THIS SHOULD BE REMOVED IN THE FUTURE steps: - - name: Get Artifact and Pull request info + - name: Get Artifact and Pull Request Info env: - GITHUB_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }} OWNER: ${{ github.repository_owner }} REPO: ${{ github.event.repository.name }} run: | PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ") - echo "Previous Job ID: $PREVIOUS_JOB_ID" echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV" SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ") - echo "Previous Suite ID: $SUITE_ID" echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV" ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \ - --jq ".artifacts.[] | - select(.workflow_run.id==${PREVIOUS_JOB_ID}) | - select(.expired==false) | - .id") - - echo "Artifact ID: $ARTIFACT_ID" + --jq ".artifacts[] | select(.workflow_run.id==$PREVIOUS_JOB_ID and .expired==false) | .id" | head -n1) echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV" - PR_NUMBER=$(jq -r '.pull_requests[0].number' \ - <<< "$WORKFLOW_RUN_EVENT_OBJ") - - echo "Pull request Number: $PR_NUMBER" + PR_NUMBER=$(jq -r '.pull_requests[0].number // empty' <<< "$WORKFLOW_RUN_EVENT_OBJ") echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV" - HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \ - <<< "$WORKFLOW_RUN_EVENT_OBJ") - - echo "Head SHA: $HEAD_SHA" + HEAD_SHA=$(jq -r '.head_sha' <<< "$WORKFLOW_RUN_EVENT_OBJ") echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV" + - name: Find Comment - uses: peter-evans/find-comment@v2 + uses: peter-evans/find-comment@v3 id: find-comment + if: env.PR_NUMBER with: issue-number: ${{ env.PR_NUMBER }} comment-author: 'github-actions[bot]' + - name: Update Comment + uses: peter-evans/create-or-update-comment@v3 + if: env.PR_NUMBER env: JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}" - ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/$SUITE_ID/artifacts/$ARTIFACT_ID" - HEAD_SHA: "${{ env.HEAD_SHA }}" - uses: peter-evans/create-or-update-comment@v3 + ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}" with: issue-number: ${{ env.PR_NUMBER }} comment-id: ${{ steps.find-comment.outputs.comment-id }} edit-mode: replace - body: |- + body: | ![badge] Build Successful! You can find a link to the downloadable artifact below. @@ -73,4 +64,5 @@ jobs: | Logs | ${{ env.JOB_PATH }} | | Download | ${{ env.ARTIFACT_URL }} | - [badge]: https://img.shields.io/badge/Build_Success!-0d1117?style=for-the-badge&labelColor=3fb950&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNMjEuMDMgNS43MmEuNzUuNzUgMCAwIDEgMCAxLjA2bC0xMS41IDExLjVhLjc0Ny43NDcgMCAwIDEtMS4wNzItLjAxMmwtNS41LTUuNzVhLjc1Ljc1IDAgMSAxIDEuMDg0LTEuMDM2bDQuOTcgNS4xOTVMMTkuOTcgNS43MmEuNzUuNzUgMCAwIDEgMS4wNiAwWiI+PC9wYXRoPjwvc3ZnPg== + [badge]: https://img.shields.io/badge/Build_Success!-0d1117?style=for-the-badge&labelColor=3fb950&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNMjEuMDMgNS43MmEuNzUuNzUgMCAwIDEgMCAxLjA2bC0xMS41IDExLjVhLjc0Ny43NDcgMCAwIDEtMS4wNzItLjAxMmwtNS41LTUuNzVhLjc1Ljc1IDMgMSAxIDEuMDg0LTEuMDM2bDQuOTcgNS4xOTVMMTkuOTcgNS43MmEuNzUuNzUgMCAwIDEgMS4wNiAwWiI+PC9wYXRoPjwvc3ZnPg== + diff --git a/.github/workflows/precommit-checks.yml b/.github/workflows/precommit-checks.yml index bc7f4762c..66885dc15 100644 --- a/.github/workflows/precommit-checks.yml +++ b/.github/workflows/precommit-checks.yml @@ -1,16 +1,24 @@ -name: precommit checks +name: Pre-commit Checks on: push: + pull_request: + +# Ensures only the latest workflow run for the same branch is active, canceling any in-progress runs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: '3.9' - uses: pre-commit/action@v3.0.0 + - uses: pre-commit-ci/lite-action@v1.0.1 + if: always() From c31e8ffe38f6f8c7887773fffaf05b56076e9765 Mon Sep 17 00:00:00 2001 From: Avi Vajpeyi Date: Wed, 11 Dec 2024 13:06:51 +1300 Subject: [PATCH 4/8] try to make commenter work even when using a fork --- .github/workflows/pr_artifact_url_commenter.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr_artifact_url_commenter.yml b/.github/workflows/pr_artifact_url_commenter.yml index 50abed9b3..766274bca 100644 --- a/.github/workflows/pr_artifact_url_commenter.yml +++ b/.github/workflows/pr_artifact_url_commenter.yml @@ -10,7 +10,6 @@ jobs: comment: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} - continue-on-error: true # THIS SHOULD BE REMOVED IN THE FUTURE steps: - name: Get Artifact and Pull Request Info env: @@ -30,22 +29,22 @@ jobs: echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV" PR_NUMBER=$(jq -r '.pull_requests[0].number // empty' <<< "$WORKFLOW_RUN_EVENT_OBJ") - echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV" + echo "PR_NUMBER=${PR_NUMBER:-null}" >> "$GITHUB_ENV" - HEAD_SHA=$(jq -r '.head_sha' <<< "$WORKFLOW_RUN_EVENT_OBJ") - echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV" + HEAD_SHA=$(jq -r '.head_sha // empty' <<< "$WORKFLOW_RUN_EVENT_OBJ") + echo "HEAD_SHA=${HEAD_SHA:-null}" >> "$GITHUB_ENV" - name: Find Comment uses: peter-evans/find-comment@v3 id: find-comment - if: env.PR_NUMBER + if: env.PR_NUMBER != 'null' with: issue-number: ${{ env.PR_NUMBER }} comment-author: 'github-actions[bot]' - name: Update Comment uses: peter-evans/create-or-update-comment@v3 - if: env.PR_NUMBER + if: env.PR_NUMBER != 'null' env: JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}" ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}" @@ -65,4 +64,3 @@ jobs: | Download | ${{ env.ARTIFACT_URL }} | [badge]: https://img.shields.io/badge/Build_Success!-0d1117?style=for-the-badge&labelColor=3fb950&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNMjEuMDMgNS43MmEuNzUuNzUgMCAwIDEgMCAxLjA2bC0xMS41IDExLjVhLjc0Ny43NDcgMCAwIDEtMS4wNzItLjAxMmwtNS41LTUuNzVhLjc1Ljc1IDMgMSAxIDEuMDg0LTEuMDM2bDQuOTcgNS4xOTVMMTkuOTcgNS43MmEuNzUuNzUgMCAwIDEgMS4wNiAwWiI+PC9wYXRoPjwvc3ZnPg== - From d0430ee4d63716d049ca34e8a32cb60b3076d521 Mon Sep 17 00:00:00 2001 From: Avi Vajpeyi Date: Wed, 11 Dec 2024 13:16:30 +1300 Subject: [PATCH 5/8] nuke the old latex-compile file --- .github/workflows/latex-compile-ci.yml | 71 -------------------------- 1 file changed, 71 deletions(-) delete mode 100644 .github/workflows/latex-compile-ci.yml diff --git a/.github/workflows/latex-compile-ci.yml b/.github/workflows/latex-compile-ci.yml deleted file mode 100644 index 46d61c65b..000000000 --- a/.github/workflows/latex-compile-ci.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: LaTeX compile test - -# Test Latex compiles on pull_requests -# Public documentation on push to dev - -on: - pull_request: - paths: ['main/**'] # only changes to src/ trigger this workflow - push: - branches: [dev] - paths: ['main/**'] - - -jobs: - latex: - name: Build LaTeX documentation - runs-on: ubuntu-18.04 - - steps: - - uses: actions/checkout@v2 - - - name: Install dependencies - run: sudo apt install texlive-base - - # Need to do pdflatex, bibtex, pdflatex, pdflatex - - name: pdflatex main - uses: dante-ev/latex-action@latest - with: - working_directory: docs/COMPAS_LaTeX - root_file: main.tex - compiler: pdflatex - args: -interaction=nonstopmode -shell-escape - - - name: bibtex main - uses: dante-ev/latex-action@latest - with: - working_directory: docs/COMPAS_LaTeX - root_file: main.aux - compiler: bibtex - args: - - - name: pdflatex main - uses: dante-ev/latex-action@latest - with: - working_directory: docs/COMPAS_LaTeX - root_file: main.tex - compiler: pdflatex - args: -interaction=nonstopmode -shell-escape - - - name: pdflatex main - uses: dante-ev/latex-action@latest - with: - working_directory: docs/COMPAS_LaTeX - root_file: main.tex - compiler: pdflatex - args: -interaction=nonstopmode -shell-escape - - - # If push to dev, publish the documentation - - name: publish documentation - if: github.event_name == 'push' - run: | - git checkout --orphan Documentation - PDF_FILE=COMPAS_Documentation.pdf - mv docs/COMPAS_LaTeX/main.pdf $PDF_FILE - git rm -rf . - git add -f $PDF_FILE - git config user.name "Team COMPAS" - git config user.email "<>" - git commit -m "Documentation update" - git push -f --set-upstream origin Documentation From d244a2bdb521bfae883d912609c1753a2c82954b Mon Sep 17 00:00:00 2001 From: Avi Vajpeyi Date: Wed, 11 Dec 2024 13:38:15 +1300 Subject: [PATCH 6/8] attempt at making the commenter work on non-TEAMCompas forks --- .../workflows/pr_artifact_url_commenter.yml | 91 +++++++++++-------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/.github/workflows/pr_artifact_url_commenter.yml b/.github/workflows/pr_artifact_url_commenter.yml index 766274bca..e443e7512 100644 --- a/.github/workflows/pr_artifact_url_commenter.yml +++ b/.github/workflows/pr_artifact_url_commenter.yml @@ -1,4 +1,4 @@ -name: Comment on Pull Request +name: Comment on Pull Request and Show Summary on: workflow_run: @@ -7,60 +7,71 @@ on: - completed jobs: - comment: + comment-and-summarize: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - - name: Get Artifact and Pull Request Info - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }} - OWNER: ${{ github.repository_owner }} - REPO: ${{ github.event.repository.name }} + - name: Download artifact + uses: actions/github-script@v6 + with: + script: | + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.name, + run_id: ${{ github.event.workflow_run.id }}, + }); + const matchArtifact = artifacts.data.artifacts.find((artifact) => { + return artifact.name == "detailedEvolutionPlot.png" + }); + const download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.name, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + const fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/detailedEvolutionPlot.zip', Buffer.from(download.data)); + + - run: unzip detailedEvolutionPlot.zip + + - name: Get PR Number + id: get-pr-number run: | - PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ") - echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV" - - SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ") - echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV" - - ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \ - --jq ".artifacts[] | select(.workflow_run.id==$PREVIOUS_JOB_ID and .expired==false) | .id" | head -n1) - echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV" - - PR_NUMBER=$(jq -r '.pull_requests[0].number // empty' <<< "$WORKFLOW_RUN_EVENT_OBJ") - echo "PR_NUMBER=${PR_NUMBER:-null}" >> "$GITHUB_ENV" - - HEAD_SHA=$(jq -r '.head_sha // empty' <<< "$WORKFLOW_RUN_EVENT_OBJ") - echo "HEAD_SHA=${HEAD_SHA:-null}" >> "$GITHUB_ENV" + PR_NUMBER=$(gh api /repos/${{ github.repository }}/commits/${{ github.event.workflow_run.head_sha }}/pulls --jq '.[0].number') + echo "PR_NUMBER=${PR_NUMBER:-null}" >> $GITHUB_OUTPUT - name: Find Comment uses: peter-evans/find-comment@v3 id: find-comment - if: env.PR_NUMBER != 'null' + if: steps.get-pr-number.outputs.PR_NUMBER != 'null' with: - issue-number: ${{ env.PR_NUMBER }} + issue-number: ${{ steps.get-pr-number.outputs.PR_NUMBER }} comment-author: 'github-actions[bot]' - - name: Update Comment + - name: Update or Create Comment uses: peter-evans/create-or-update-comment@v3 - if: env.PR_NUMBER != 'null' - env: - JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}" - ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}" + if: steps.get-pr-number.outputs.PR_NUMBER != 'null' with: - issue-number: ${{ env.PR_NUMBER }} + issue-number: ${{ steps.get-pr-number.outputs.PR_NUMBER }} comment-id: ${{ steps.find-comment.outputs.comment-id }} - edit-mode: replace body: | - ![badge] + ## COMPAS Test Results - Build Successful! You can find a link to the downloadable artifact below. + The COMPAS compile test has completed successfully. - | Name | Link | - | -------- | ----------------------- | - | Commit | ${{ env.HEAD_SHA }} | - | Logs | ${{ env.JOB_PATH }} | - | Download | ${{ env.ARTIFACT_URL }} | + ![Detailed Evolution Plot](detailedEvolutionPlot.png) - [badge]: https://img.shields.io/badge/Build_Success!-0d1117?style=for-the-badge&labelColor=3fb950&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNMjEuMDMgNS43MmEuNzUuNzUgMCAwIDEgMCAxLjA2bC0xMS41IDExLjVhLjc0Ny43NDcgMCAwIDEtMS4wNzItLjAxMmwtNS41LTUuNzVhLjc1Ljc1IDMgMSAxIDEuMDg0LTEuMDM2bDQuOTcgNS4xOTVMMTkuOTcgNS43MmEuNzUuNzUgMCAwIDEgMS4wNiAwWiI+PC9wYXRoPjwvc3ZnPg== + [Link to workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}) + + - name: Create Summary + run: | + echo "## COMPAS Test Results" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "The COMPAS compile test has completed successfully." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "![Detailed Evolution Plot](detailedEvolutionPlot.png)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "- Compas Build: Success" >> $GITHUB_STEP_SUMMARY + echo "- Python Utils Installation: Success" >> $GITHUB_STEP_SUMMARY + echo "- Example COMPAS Job: Success" >> $GITHUB_STEP_SUMMARY + echo "- Pytest Execution: Success" >> $GITHUB_STEP_SUMMARY From c0ede3e4aaaa61b2b41762213a7f39e06222b650 Mon Sep 17 00:00:00 2001 From: Avi Vajpeyi Date: Wed, 11 Dec 2024 13:59:10 +1300 Subject: [PATCH 7/8] add image in summary --- .github/workflows/compas-compile-ci.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/compas-compile-ci.yml b/.github/workflows/compas-compile-ci.yml index 5493335a4..57db1939d 100644 --- a/.github/workflows/compas-compile-ci.yml +++ b/.github/workflows/compas-compile-ci.yml @@ -1,6 +1,7 @@ name: COMPAS compile test -'on': - workflow_dispatch: null + +on: + workflow_dispatch: pull_request: branches: - dev @@ -25,13 +26,7 @@ jobs: ARTIFACT_PATH: py_tests/test_artifacts name: Build COMPAS - runs-on: '${{ matrix.os}}' - container: '${{matrix.container}}' - strategy: - fail-fast: false - matrix: - os: - - ubuntu-22.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -42,7 +37,6 @@ jobs: - name: Install TeXLive uses: teatimeguest/setup-texlive-action@v3 - name: Install dependencies on ubuntu - if: 'startsWith(matrix.os, ''ubuntu-2'')' run: | cd misc/cicd-scripts chmod 755 linux-dependencies @@ -86,6 +80,10 @@ jobs: name: '${{ env.ARTIFACT_NAME }}' path: '${{ env.ARTIFACT_PATH }}/${{ env.ARTIFACT_NAME }}' if-no-files-found: error + - name: Encode image to base64 # otherwise it wont be able to render i think... + run: | + BASE64_IMAGE=$(base64 -w 0 ${{ env.ARTIFACT_PATH }}/${{ env.ARTIFACT_NAME }}) + echo "BASE64_IMAGE=$BASE64_IMAGE" >> $GITHUB_ENV - name: Test Summary run: | echo "### Test Results" >> $GITHUB_STEP_SUMMARY @@ -93,3 +91,6 @@ jobs: echo "- Python Utils Installation: Success" >> $GITHUB_STEP_SUMMARY echo "- Example COMPAS Job: Success" >> $GITHUB_STEP_SUMMARY echo "- Pytest Execution: Success" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Detailed Evolution Plot" >> $GITHUB_STEP_SUMMARY + echo "Detailed Evolution Plot" >> $GITHUB_STEP_SUMMARY From cb14228937bcfa3ddbb6cd06d2bc168a72ecc615 Mon Sep 17 00:00:00 2001 From: Avi Vajpeyi Date: Wed, 11 Dec 2024 14:24:51 +1300 Subject: [PATCH 8/8] reattempt PR commenter --- .github/workflows/compas-compile-ci.yml | 23 ++-- .../workflows/pr_artifact_url_commenter.yml | 118 +++++++++--------- 2 files changed, 69 insertions(+), 72 deletions(-) diff --git a/.github/workflows/compas-compile-ci.yml b/.github/workflows/compas-compile-ci.yml index 57db1939d..e860330e4 100644 --- a/.github/workflows/compas-compile-ci.yml +++ b/.github/workflows/compas-compile-ci.yml @@ -1,7 +1,6 @@ name: COMPAS compile test - -on: - workflow_dispatch: +'on': + workflow_dispatch: null pull_request: branches: - dev @@ -26,7 +25,13 @@ jobs: ARTIFACT_PATH: py_tests/test_artifacts name: Build COMPAS - runs-on: ubuntu-22.04 + runs-on: '${{ matrix.os}}' + container: '${{matrix.container}}' + strategy: + fail-fast: false + matrix: + os: + - ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -37,6 +42,7 @@ jobs: - name: Install TeXLive uses: teatimeguest/setup-texlive-action@v3 - name: Install dependencies on ubuntu + if: 'startsWith(matrix.os, ''ubuntu-2'')' run: | cd misc/cicd-scripts chmod 755 linux-dependencies @@ -80,17 +86,10 @@ jobs: name: '${{ env.ARTIFACT_NAME }}' path: '${{ env.ARTIFACT_PATH }}/${{ env.ARTIFACT_NAME }}' if-no-files-found: error - - name: Encode image to base64 # otherwise it wont be able to render i think... - run: | - BASE64_IMAGE=$(base64 -w 0 ${{ env.ARTIFACT_PATH }}/${{ env.ARTIFACT_NAME }}) - echo "BASE64_IMAGE=$BASE64_IMAGE" >> $GITHUB_ENV - name: Test Summary run: | echo "### Test Results" >> $GITHUB_STEP_SUMMARY echo "- Compas Build: Success" >> $GITHUB_STEP_SUMMARY echo "- Python Utils Installation: Success" >> $GITHUB_STEP_SUMMARY echo "- Example COMPAS Job: Success" >> $GITHUB_STEP_SUMMARY - echo "- Pytest Execution: Success" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### Detailed Evolution Plot" >> $GITHUB_STEP_SUMMARY - echo "Detailed Evolution Plot" >> $GITHUB_STEP_SUMMARY + echo "- Pytest Execution: Success" >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/.github/workflows/pr_artifact_url_commenter.yml b/.github/workflows/pr_artifact_url_commenter.yml index e443e7512..62bca978d 100644 --- a/.github/workflows/pr_artifact_url_commenter.yml +++ b/.github/workflows/pr_artifact_url_commenter.yml @@ -1,4 +1,4 @@ -name: Comment on Pull Request and Show Summary +name: Comment on Pull request on: workflow_run: @@ -7,71 +7,69 @@ on: - completed jobs: - comment-and-summarize: + comment: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: + - name: Get Artifact and Pull request info + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + run: | + PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ") + echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV" + + SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ") + echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV" + + ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \ + --jq ".artifacts[] | select(.workflow_run.id==$PREVIOUS_JOB_ID and .expired==false and .name=='detailedEvolutionPlot.png') | .id" | head -n1) + echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV" + + PR_NUMBER=$(gh api "/repos/$OWNER/$REPO/commits/${{ github.event.workflow_run.head_sha }}/pulls" --jq '.[0].number') + echo "PR_NUMBER=${PR_NUMBER:-null}" >> "$GITHUB_ENV" + + HEAD_SHA=${{ github.event.workflow_run.head_sha }} + echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV" + - name: Download artifact + if: env.PR_NUMBER != 'null' && env.ARTIFACT_ID != '' + run: | + gh api /repos/${{ github.repository }}/actions/artifacts/${{ env.ARTIFACT_ID }}/zip -H "Accept: application/vnd.github.v3+json" --output artifact.zip + unzip artifact.zip + rm artifact.zip + + - name: Update Comment + if: env.PR_NUMBER != 'null' && env.ARTIFACT_ID != '' + env: + JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}" + ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}" uses: actions/github-script@v6 with: + github-token: ${{secrets.GITHUB_TOKEN}} script: | - const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.name, - run_id: ${{ github.event.workflow_run.id }}, - }); - const matchArtifact = artifacts.data.artifacts.find((artifact) => { - return artifact.name == "detailedEvolutionPlot.png" - }); - const download = await github.rest.actions.downloadArtifact({ + const fs = require('fs'); + const imageData = fs.readFileSync('detailedEvolutionPlot.png', {encoding: 'base64'}); + github.rest.issues.createComment({ + issue_number: process.env.PR_NUMBER, owner: context.repo.owner, repo: context.repo.name, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - const fs = require('fs'); - fs.writeFileSync('${{github.workspace}}/detailedEvolutionPlot.zip', Buffer.from(download.data)); - - - run: unzip detailedEvolutionPlot.zip - - - name: Get PR Number - id: get-pr-number - run: | - PR_NUMBER=$(gh api /repos/${{ github.repository }}/commits/${{ github.event.workflow_run.head_sha }}/pulls --jq '.[0].number') - echo "PR_NUMBER=${PR_NUMBER:-null}" >> $GITHUB_OUTPUT - - - name: Find Comment - uses: peter-evans/find-comment@v3 - id: find-comment - if: steps.get-pr-number.outputs.PR_NUMBER != 'null' - with: - issue-number: ${{ steps.get-pr-number.outputs.PR_NUMBER }} - comment-author: 'github-actions[bot]' - - - name: Update or Create Comment - uses: peter-evans/create-or-update-comment@v3 - if: steps.get-pr-number.outputs.PR_NUMBER != 'null' - with: - issue-number: ${{ steps.get-pr-number.outputs.PR_NUMBER }} - comment-id: ${{ steps.find-comment.outputs.comment-id }} - body: | - ## COMPAS Test Results - - The COMPAS compile test has completed successfully. - - ![Detailed Evolution Plot](detailedEvolutionPlot.png) - - [Link to workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}) - - - name: Create Summary - run: | - echo "## COMPAS Test Results" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "The COMPAS compile test has completed successfully." >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "![Detailed Evolution Plot](detailedEvolutionPlot.png)" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "- Compas Build: Success" >> $GITHUB_STEP_SUMMARY - echo "- Python Utils Installation: Success" >> $GITHUB_STEP_SUMMARY - echo "- Example COMPAS Job: Success" >> $GITHUB_STEP_SUMMARY - echo "- Pytest Execution: Success" >> $GITHUB_STEP_SUMMARY + body: ` + ![badge] + + Build Successful! You can find a link to the downloadable artifact below. + + | Name | Link | + | -------- | ----------------------- | + | Commit | ${process.env.HEAD_SHA} | + | Logs | ${process.env.JOB_PATH} | + | Download | ${process.env.ARTIFACT_URL} | + + ### Detailed Evolution Plot + ![Detailed Evolution Plot](data:image/png;base64,${imageData}) + + [badge]: https://img.shields.io/badge/Build_Success!-0d1117?style=for-the-badge&labelColor=3fb950&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNMjEuMDMgNS43MmEuNzUuNzUgMCAwIDEgMCAxLjA2bC0xMS41IDExLjVhLjc0Ny43NDcgMCAwIDEtMS4wNzItLjAxMmwtNS41LTUuNzVhLjc1Ljc1IDAgMSAxIDEuMDg0LTEuMDM2bDQuOTcgNS4xOTVMMTkuOTcgNS43MmEuNzUuNzUgMCAwIDEgMS4wNiAwWiI+PC9wYXRoPjwvc3ZnPg== + ` + })