diff --git a/.github/workflows/Remove_labels.yml b/.github/workflows/Remove_labels.yml new file mode 100644 index 00000000000..0624fe7a1df --- /dev/null +++ b/.github/workflows/Remove_labels.yml @@ -0,0 +1,33 @@ +name: remove_labels +on: + pull_request_target: + types: [synchronize] + workflow_dispatch: +jobs: + remove_label: + runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'Tested') + name: remove label + steps: + - name: removelabel + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: "Tested", + }); + - name: Post address + uses: actions/github-script@v6 + if: ${{ success() }} + with: + script: | + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: "This pull-request was previously marked with the label `Tested`, but has been modified with new commits. That label has been removed." + }) diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index 85eaa0e78cf..9e445535ac4 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -4,12 +4,19 @@ on: issue_comment: types: [created] +permissions: + contents: read # to fetch code (actions/checkout) + jobs: build: + permissions: + contents: read # to fetch code (actions/checkout) + pull-requests: write # to create comment + runs-on: ubuntu-latest steps: - - uses: actions/github-script@v3 + - uses: actions/github-script@v6 id: get_round with: result-encoding: string @@ -31,7 +38,7 @@ jobs: } } return 'stop' - - uses: actions/github-script@v3 + - uses: actions/github-script@v6 if: steps.get_round.outputs.result != 'stop' id: get_pr_number with: @@ -40,15 +47,26 @@ jobs: //get pullrequest url const pr_number = context.payload.issue.number return pr_number - - uses: actions/checkout@v2 + + - name: Emoji-comment + uses: actions/github-script@v6 + if: steps.get_round.outputs.result != 'stop' + with: + script: | + github.rest.reactions.createForIssueComment({ + comment_id: ${{ github.event.comment.id }}, + owner: context.repo.owner, + repo: context.repo.repo, + content: 'rocket' + }) + + - uses: actions/checkout@v3 name: "checkout branch" if: steps.get_round.outputs.result != 'stop' with: - repository: ${{ github.repository }} - ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge - token: ${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }} - fetch-depth: 2 - + repository: ${{ github.repository }} + ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge + fetch-depth: 2 - name: install dependencies if: steps.get_round.outputs.result != 'stop' @@ -56,7 +74,7 @@ jobs: set -x sudo apt-get update && sudo apt-get install -y graphviz ssh bibtex2html sudo pip install lxml - sudo pip install 'pyquery==1.4.1' # it seems to be the last py2 compatible version + sudo pip install pyquery wget --no-verbose -O doxygen_exe https://cgal.geometryfactory.com/~cgaltest/doxygen_1_8_13_patched/doxygen sudo mv doxygen_exe /usr/bin/doxygen sudo chmod +x /usr/bin/doxygen @@ -83,14 +101,17 @@ jobs: #list impacted packages LIST_OF_PKGS=$(git diff --name-only HEAD^1 HEAD |cut -s -d/ -f1 |sort -u | xargs -I {} echo {} && ls -d {}/package_info 2>/dev/null |cut -d/ -f1 |egrep -v Installation||true) if [ "$LIST_OF_PKGS" = "" ]; then - echo "::set-output name=DoxygenError::No package affected." + echo "DoxygenError=No package affected." >> $GITHUB_OUTPUT exit 1 fi cd build_doc && make -j2 doc make -j2 doc_with_postprocessing 2>tmp.log if [ -s tmp.log ]; then content=`cat ./tmp.log` - echo "::set-output name=DoxygenError::$(cat tmp.log)" + delimiter="$(openssl rand -hex 8)" + echo "DoxygenError<<${delimiter}" >> "${GITHUB_OUTPUT}" + cat tmp.log >> "${GITHUB_OUTPUT}" + echo "${delimiter}" >> "${GITHUB_OUTPUT}" exit 1 fi cd .. @@ -110,12 +131,12 @@ jobs: mv tmp.html index.html git add ${PR_NUMBER}/$ROUND index.html && git commit -q --amend -m "base commit" && git push -q -f -u origin master else - echo "::set-output name=DoxygenError::This round already exists. Overwrite it with /force-build." + echo "DoxygenError=This round already exists. Overwrite it with /force-build." >> $GITHUB_OUTPUT exit 1 fi - name: Post address - uses: actions/github-script@v3 + uses: actions/github-script@v6 if: ${{ success() && steps.get_round.outputs.result != 'stop' }} with: script: | @@ -123,7 +144,7 @@ jobs: const id = tmp_round.indexOf(":"); const round = tmp_round.substring(0,id); const address = "The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/${{ steps.get_pr_number.outputs.result }}/"+round+"/Manual/index.html" - github.issues.createComment({ + github.rest.issues.createComment({ owner: "CGAL", repo: "cgal", issue_number: ${{ github.event.issue.number }}, @@ -131,13 +152,16 @@ jobs: }); - name: Post error - uses: actions/github-script@v3 + env: + ERRORMSG: ${{steps.build_and_run.outputs.DoxygenError}} + uses: actions/github-script@v6 if: ${{ failure() && steps.get_round.outputs.result != 'stop' }} with: script: | - const error = "${{steps.build_and_run.outputs.DoxygenError}}" - const msg = "There was an error while building the doc: \n"+error - github.issues.createComment({ + const error = process.env.ERRORMSG + const job_url = `${context.serverUrl}/CGAL/cgal/actions/runs/${context.runId}` + const msg = "There was an error while building the doc: \n"+error + "\n" + job_url + github.rest.issues.createComment({ owner: "CGAL", repo: "cgal", issue_number: ${{ github.event.issue.number }}, diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b1eff295243..0af6e276e6e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,6 +1,9 @@ name: CMake Test Merge Branch -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] + +permissions: + contents: read jobs: build: @@ -8,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.0.0 + - uses: actions/checkout@v3 - name: install dependencies run: | .github/install.sh diff --git a/.github/workflows/cmake-all.yml b/.github/workflows/cmake-all.yml index a0bf2c2cd76..d0507b4d430 100644 --- a/.github/workflows/cmake-all.yml +++ b/.github/workflows/cmake-all.yml @@ -1,6 +1,9 @@ name: CMake Testsuite -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] + +permissions: + contents: read jobs: cmake-testsuite: @@ -8,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.0.0 + - uses: actions/checkout@v3 - name: install dependencies run: sudo apt-get install -y libboost-dev libboost-program-options-dev libmpfr-dev libeigen3-dev - name: configure all @@ -22,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.0.0 + - uses: actions/checkout@v3 - name: install dependencies run: sudo bash -e .github/install.sh - name: configure all diff --git a/.github/workflows/delete_doc.yml b/.github/workflows/delete_doc.yml index 618b1f47df7..38f5ab445ac 100644 --- a/.github/workflows/delete_doc.yml +++ b/.github/workflows/delete_doc.yml @@ -2,20 +2,25 @@ name: Documentation Removal on: pull_request_target: - types: [closed, removed] + types: [closed, removed, workflow_dispatch] +permissions: + contents: read + jobs: build: + permissions: + contents: write # for Git to git push runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.0.0 + - uses: actions/checkout@v3 - name: delete directory run: | set -x git config --global user.email "cgal@geometryfactory.com" git config --global user.name "cgaltest" - git clone https://maxGimeno:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git --depth=5 + git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git PR_NUMBER=$(python -c "import json; import os; y = json.load(open(os.environ['GITHUB_EVENT_PATH'])); print(y[\"number\"])") cd cgal.github.io/ egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 7d3a31bfd49..123458ebe04 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -1,12 +1,15 @@ name: Test Polyhedron Demo -on: [push, pull_request] +on: [push, pull_request,workflow_dispatch] + +permissions: + contents: read jobs: batch_1: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.0.0 + - uses: actions/checkout@v3 - name: install dependencies run: .github/install.sh - name: run1 @@ -14,7 +17,7 @@ jobs: batch_2: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.0.0 + - uses: actions/checkout@v3 - name: install dependencies run: .github/install.sh - name: run2 @@ -22,7 +25,7 @@ jobs: batch_3: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.0.0 + - uses: actions/checkout@v3 - name: install dependencies run: .github/install.sh - name: run3 @@ -30,7 +33,7 @@ jobs: batch_4: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.0.0 + - uses: actions/checkout@v3 - name: install dependencies run: .github/install.sh - name: run4 diff --git a/.github/workflows/filter_testsuite.yml b/.github/workflows/filter_testsuite.yml index e1d8ebf2221..48e4f39d65c 100644 --- a/.github/workflows/filter_testsuite.yml +++ b/.github/workflows/filter_testsuite.yml @@ -3,13 +3,18 @@ name: Filter Testsuite on: issue_comment: types: [created] + workflow_dispatch: +permissions: {} jobs: build: + permissions: + pull-requests: write # to create comment + if: (github.event.comment.user.login == 'sloriot' || github.event.comment.user.login == 'lrineau') && contains(github.event.comment.body, '/testme') runs-on: ubuntu-latest steps: - - uses: actions/github-script@v3 + - uses: actions/github-script@v6 id: get_label with: result-encoding: string @@ -58,7 +63,7 @@ jobs: ssh ${HOST} "${PATH_TO_SCRIPT}/run_testsuite_from_branch_name.sh $USER_NAME $BRANCH_NAME $BASE $PR_NUMBER" done - name: Post address - uses: actions/github-script@v3 + uses: actions/github-script@v6 with: script: | const address = "Testsuite launched. Results will appear on the following page: https://cgal.geometryfactory.com/~cgaltest/test_suite/TESTRESULTS/index.shtml " diff --git a/.github/workflows/list_workflow_last_run.css b/.github/workflows/list_workflow_last_run.css new file mode 100644 index 00000000000..a3955383311 --- /dev/null +++ b/.github/workflows/list_workflow_last_run.css @@ -0,0 +1,30 @@ +table { + margin-left: auto; + margin-right: auto; + margin-bottom: 24px; + border-spacing: 0; + border-bottom: 2px solid black; + border-top: 2px solid black; +} +table th { + padding: 3px 10px; + background-color: white; + border-top: none; + border-left: none; + border-right: none; + border-bottom: 1px solid black; +} +table td { + padding: 3px 10px; + border-top: none; + border-left: none; + border-bottom: none; + border-right: none; +} + +table tr.odd { + background-color: #f0f0f0; +} +table tr.even { + background-color: #e0e0e0; +} diff --git a/.github/workflows/list_workflow_last_run.yml b/.github/workflows/list_workflow_last_run.yml new file mode 100644 index 00000000000..79b1d2c0634 --- /dev/null +++ b/.github/workflows/list_workflow_last_run.yml @@ -0,0 +1,43 @@ + name: List workflow last run + on: + workflow_dispatch: + schedule: + - cron: "0 10 * * 1" + env: + GH_TOKEN: ${{ github.token }} + jobs: + list_workflow: + runs-on: ubuntu-latest + outputs: + messages: ${{ steps.cat_output.outputs.message }} + steps: + - name: checkout + uses: actions/checkout@v3 + - name: run script + run: | + chmod +x ./Scripts/developer_scripts/list_cgal_workflows_last_run.sh + ./Scripts/developer_scripts/list_cgal_workflows_last_run.sh > output.md + - name: convert markdown to html + run: | + sudo apt-get update && sudo apt-get install -y pandoc + pandoc -f markdown -t html --self-contained --css=.github/workflows/list_workflow_last_run.css -o output.html output.md + - name: set_output + id: cat_output + run: | + delimiter="$(openssl rand -hex 8)" + echo "message<<${delimiter}" >> "${GITHUB_OUTPUT}" + echo "Subject:List workflow run \nContent-Type: text/html; charset=\"UTF-8\"\n" >> "${GITHUB_OUTPUT}" + echo "" >> "${GITHUB_OUTPUT}" + cat output.html >> "${GITHUB_OUTPUT}" + echo "" >> "${GITHUB_OUTPUT}" + echo "${delimiter}" >> "${GITHUB_OUTPUT}" + call_send_email: + needs: list_workflow + uses: ./.github/workflows/send_email.yml + with: + message: ${{needs.list_workflow.outputs.messages}} + secrets: + email: ${{ secrets.CGAL_SEND_WORKFLOW_LIST_EMAIL_TO }} + private_key: ${{ secrets.CGAL_SEND_WORKFLOW_LIST_EMAIL_SSH_PRIVATE_KEY }} + user: ${{ secrets.CGAL_SEND_WORKFLOW_LIST_EMAIL_SSH_USER }} + host: ${{ secrets.CGAL_SEND_WORKFLOW_LIST_EMAIL_SSH_HOST }} diff --git a/.github/workflows/send_email.yml b/.github/workflows/send_email.yml new file mode 100644 index 00000000000..cb990eca146 --- /dev/null +++ b/.github/workflows/send_email.yml @@ -0,0 +1,31 @@ +name: Send Email using SSH + +on: + workflow_call: + inputs: + message: + description: 'Message to send' + required: true + type: string + secrets: + email: + required: true + private_key: + required: true + user: + required: true + host: + required: true + +jobs: + send_email: + runs-on: ubuntu-latest + steps: + - name: install ssh keys + run: | + install -m 600 -D /dev/null ~/.ssh/id_rsa + echo "${{ secrets.private_key }}" > ~/.ssh/id_rsa + ssh-keyscan -H ${{ secrets.host }} > ~/.ssh/known_hosts + - name: send email via ssh + run: | + echo -e '${{ inputs.message }}' | ssh ${{ secrets.user }}@${{ secrets.host }} "/sbin/sendmail -t ${{ secrets.email }}" diff --git a/.github/workflows/wiki_notification.yml b/.github/workflows/wiki_notification.yml new file mode 100644 index 00000000000..456fefa51e3 --- /dev/null +++ b/.github/workflows/wiki_notification.yml @@ -0,0 +1,38 @@ +name: Wiki Notification + +on: gollum + +jobs: + prepare_email: + runs-on: ubuntu-latest + outputs: + messages: ${{ steps.set-result.outputs.result }} + steps: + - name: get informations and prepare email + uses: actions/github-script@v6 + id: set-result + with: + result-encoding: string + script: | + const payload = context.payload; + const actor = payload.sender; + const pages = payload.pages; + let messages = "Subject:Updates to CGAL Wiki \nContent-Type: text/html\n"; + messages += ""; + messages += `

The following CGAL Wiki page were modified by "${actor.login}":

"; + console.log( messages ); + return messages; + call_send_email: + needs: prepare_email + uses: ./.github/workflows/send_email.yml + with: + message: ${{needs.prepare_email.outputs.messages}} + secrets: + email: ${{ secrets.CGAL_SEND_WIKI_EMAIL_TO }} + private_key: ${{ secrets.CGAL_SEND_WIKI_EMAIL_SSH_PRIVATE_KEY }} + user: ${{ secrets.CGAL_SEND_WIKI_EMAIL_SSH_USER }} + host: ${{ secrets.CGAL_SEND_WIKI_EMAIL_SSH_HOST }}