Merge pull request #7355 from lrineau/update_Github_workflows

Update Github workflows from CGAL `master` version
This commit is contained in:
Laurent Rineau 2023-03-30 18:03:00 +02:00
commit 8ec3949272
11 changed files with 251 additions and 33 deletions

33
.github/workflows/Remove_labels.yml vendored Normal file
View File

@ -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."
})

View File

@ -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 }},

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 "

View File

@ -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;
}

View File

@ -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 "<html><body>" >> "${GITHUB_OUTPUT}"
cat output.html >> "${GITHUB_OUTPUT}"
echo "</body></html>" >> "${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 }}

31
.github/workflows/send_email.yml vendored Normal file
View File

@ -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 }}"

38
.github/workflows/wiki_notification.yml vendored Normal file
View File

@ -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 += "<html><body>";
messages += `<p>The following CGAL Wiki page were modified by <a href="${actor.html_url}">"${actor.login}"</a>:</p><ul>\n`
for (const page of pages){
messages += `<li><a href="${page.html_url}">${page.title}</a> (link to <a href="${page.html_url}/_compare/${page.sha}%5E...${page.sha}">the diff</a>)</li>\n`;
}
messages += "</ul></body></html>";
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 }}