diff --git a/.github/workflows/compas-compile-ci.yml b/.github/workflows/compas-compile-ci.yml index 6d30caa96..e860330e4 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 \ No newline at end of file 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 + 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 diff --git a/.github/workflows/pr_artifact_url_commenter.yml b/.github/workflows/pr_artifact_url_commenter.yml index dae1097fd..62bca978d 100644 --- a/.github/workflows/pr_artifact_url_commenter.yml +++ b/.github/workflows/pr_artifact_url_commenter.yml @@ -9,68 +9,67 @@ on: jobs: comment: runs-on: ubuntu-latest - continue-on-error: true + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - 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 and .name=='detailedEvolutionPlot.png') | .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" - echo "PR_NUMBER=$PR_NUMBER" >> "$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=$(jq -r '.pull_requests[0].head.sha' \ - <<< "$WORKFLOW_RUN_EVENT_OBJ") - - echo "Head SHA: $HEAD_SHA" + HEAD_SHA=${{ github.event.workflow_run.head_sha }} echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV" - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: find-comment - with: - issue-number: ${{ env.PR_NUMBER }} - comment-author: 'github-actions[bot]' + + - 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/$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 }}" + uses: actions/github-script@v6 with: - issue-number: ${{ env.PR_NUMBER }} - comment-id: ${{ steps.find-comment.outputs.comment-id }} - edit-mode: replace - body: |- - ![badge] - - Build Successful! You can find a link to the downloadable artifact below. - - | Name | Link | - | -------- | ----------------------- | - | Commit | ${{ env.HEAD_SHA }} | - | 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== + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + 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, + 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== + ` + }) 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()