Skip to content

Commit

Permalink
Merge pull request #1013 from TeamCOMPAS/add_plot_in_pr_after_success…
Browse files Browse the repository at this point in the history
…ful_workflow

Add autogenerated detailed-evol plot to PR (if COMPAS-build workflow successful)
  • Loading branch information
ilyamandel authored Apr 9, 2024
2 parents 2263fda + 65b3f88 commit 1c1c42c
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 29 deletions.
59 changes: 30 additions & 29 deletions .github/workflows/compas-compile-ci.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,80 @@
name: COMPAS compile test

on:
workflow_dispatch: # allow manual triggering of this workflow
pull_request: # run workflow when PRs made to dev (if following files changed)
'on':
workflow_dispatch: null
pull_request:
branches:
- dev
paths: ['src/**', "compas_python_utils/**", "py_tests/**", ".github/workflows/**"]
push: # always run workflow on push to the following branch
paths:
- src/**
- compas_python_utils/**
- py_tests/**
- .github/workflows/**
push:
branches:
- dev

jobs:
compas:
env:
ARTIFACT_NAME: detailedEvolutionPlot.eps
ARTIFACT_PATH: py_tests/test_artifacts
name: Build COMPAS
runs-on: ${{ matrix.os}}
container: ${{matrix.container}}
runs-on: '${{ matrix.os}}'
container: '${{matrix.container}}'
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
os:
- ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies

cache: pip
- 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-20'')'
run: |
cd misc/cicd-scripts
chmod 755 linux-dependencies
./linux-dependencies
- name: Build Compas
run: |
cd src && make -j $(nproc) -f Makefile
./COMPAS -v
- name: Run example COMPAS job
run: |
- name: Install python utils
run: >
pip install --upgrade pip
pip install -e .[dev]
- name: Run example COMPAS job
run: |
export COMPAS_ROOT_DIR=${GITHUB_WORKSPACE}
cd ${GITHUB_WORKSPACE}/misc/examples/methods_paper_plots/detailed_evolution
chmod 755 run.sh
cat run.sh
./run.sh
- name: Run pytests
# Run tests and collect coverage data
run: |
cd ${GITHUB_WORKSPACE}
export COMPAS_ROOT_DIR=${GITHUB_WORKSPACE}
jupyter-kernelspec list
pytest --cov=compas_python_utils/ py_tests/ -m 'not webtest'
pytest --cov=compas_python_utils/ --cov-append py_tests/ -m webtest
pytest --cov=compas_python_utils/ --cov-append py_tests/ -m webtest
ls py_tests/test_artifacts
coverage html
coverage-badge -o coverage_badge.svg -f
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage
path: |
htmlcov/
coverage_badge.svg
- name: Archive COMPAS run data
uses: actions/upload-artifact@v3
- name: Archive COMPAS detailed-evolution plot
id: upload
uses: actions/upload-artifact@v3.1.2
with:
name: COMPAS-run-artifacts
path: |
py_tests/test_artifacts
name: '${{ env.ARTIFACT_NAME }}'
path: '${{ env.ARTIFACT_PATH }}/${{ env.ARTIFACT_NAME }}'
if-no-files-found: error
75 changes: 75 additions & 0 deletions .github/workflows/pr_artifact_url_commenter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Comment on Pull request

on:
workflow_run:
workflows: ['COMPAS compile test']
types:
- completed

jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: Get Artifact and Pull request info
env:
GITHUB_TOKEN: ${{ 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"
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"
HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Head SHA: $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: Update Comment
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
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==

0 comments on commit 1c1c42c

Please sign in to comment.