Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .github/workflows/filter_testsuite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Filter Testsuite

on:
issue_comment:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
id: check
with:
result-encoding: string
script: |
const userName = context.payload.comment.user.login
if(userName == 'maxGimeno') {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to adapt that logic! 😄

const body = context.payload.comment.body
if(body.includes("/testme")) {
return 'OK'
}
}
return 'stop'
- uses: actions/github-script@v3
if: steps.check.result != 'stop'
id: get_label
with:
result-encoding: string
script: |
//get branch name and username
const pr_url = context.payload.issue.pull_request.url
const pr_content = await github.request(pr_url)
const label = pr_content.data.head.label
console.log(label)
return label
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step cannot be skipped, because a comment even does not have access to the full PR payload, and we need to request it using github.request.

- uses: actions/github-script@v3
if: steps.check.result != 'stop'
id: get_base
with:
result-encoding: string
script: |
//get branch name and username
const pr_url = context.payload.issue.pull_request.url
const pr_content = await github.request(pr_url)
const base = pr_content.data.base.ref
console.log(base)
return base
- uses: actions/github-script@v3
if: steps.get_round.outputs.result != 'stop'
id: get_pr_number
with:
result-encoding: string
script: |
//get pullrequest url
const pr_number = context.payload.issue.number
return pr_number
- name: Run Testsuite
if: steps.check.outputs.result != 'stop'
run: |
mkdir -p ~/.ssh
#ssh key
(
cat <<EOF
${{ secrets.ssh_key }}
EOF
)>> ~/.ssh/id_rsa
chmod 600 /home/runner/.ssh/id_rsa
#ssh public key
(
cat <<EOF
${{ secrets.ssh_key_pub }}
EOF
)>> ~/.ssh/id_rsa.pub
chmod 644 /home/runner/.ssh/id_rsa.pub
#known hosts
wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_known_hosts -O ~/.ssh/known_hosts
#config file
wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_config -O ~/.ssh/config
#list of hosts
wget --no-check-certificate https://cgal.geometryfactory.com/CGAL/ssh_host_list -O ~/ssh_host_list
#ssh command
LABEL="${{ steps.get_label.outputs.result }}"
USER_NAME=$(echo $LABEL | cut -d':' -f 1)
BRANCH_NAME=$(echo $LABEL | cut -d':' -f 2)
PR_NUMBER=${{ steps.get_pr_number.outputs.result }}
BASE="${{ steps.get_base.outputs.result }}"
mapfile -t HOSTS < ~/ssh_host_list;
for i in ${!HOSTS[@]}; do
HOST=$(echo ${HOSTS[$i]}|cut -d' ' -f 1 )
PATH_TO_SCRIPT=$(echo ${HOSTS[$i]}|cut -d' ' -f 2 )
echo "ssh ${HOST} ${PATH_TO_SCRIPT}/run_testsuite_from_branch_name.sh $USER_NAME $BRANCH_NAME $BASE $PR_NUMBER"
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
if: steps.check.outputs.result != 'stop'
with:
script: |
const address = "The testsuite is lauched. results will be found, after it is done, here : https://cgal.geometryfactory.com/~mgimeno/test_suite/TESTRESULTS/index.shtml "
github.issues.createComment({
owner: "maxGimeno",
repo: "cgal",
issue_number: ${{ github.event.issue.number }},
body: address
});
Loading