Notifications #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Notifications" | |
on: | |
push: | |
tags: | |
- 'export/**' # exclude patchew/** tags and branches | |
- 'export-net/**' | |
issues: | |
types: [opened, reopened, closed, assigned, unassigned] | |
workflow_run: | |
workflows: ["MPTCP Upstream Build Validation", "Update TopGit tree"] | |
types: | |
- completed | |
check_suite: | |
types: | |
- completed | |
env: | |
CURL_OPT: "--no-progress-meter --connect-timeout 30 --retry 20 --retry-delay 10" | |
CURL_ACC: "Accept: application/vnd.github.v3+json" | |
URI: "https://api.github.com" | |
PW: "https://patchwork.kernel.org/api/1.2" | |
permissions: {} | |
jobs: | |
tag: | |
name: "Tag" | |
if: github.repository_owner == 'multipath-tcp' && github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- name: tag shortner | |
id: tag | |
run: | | |
echo "tag=${REF:10}" >> ${GITHUB_OUTPUT} | |
env: | |
REF: ${{ github.event.ref }} | |
- name: irc tag | |
uses: rectalogic/notify-irc@v2 | |
with: | |
server: irc.libera.chat | |
channel: "#mptcp-ci" | |
nickname: gh-tag-bot | |
verbose: true | |
message: "New tag available: ${{ steps.tag.outputs.tag }} (by ${{ github.actor }})" | |
issues: | |
name: "Issues" | |
if: github.repository_owner == 'multipath-tcp' && github.event_name == 'issues' | |
runs-on: ubuntu-latest | |
steps: | |
- name: issue info | |
id: info | |
if: github.event.action != 'opened' | |
run: | | |
echo "opener=, opened by ${OPENER}" >> ${GITHUB_OUTPUT} | |
echo "assignee=${ASSIGNEE:+ and assigned to ${ASSIGNEE}}" >> ${GITHUB_OUTPUT} | |
env: | |
OPENER: ${{ github.event.issue.user.login }} | |
ASSIGNEE: ${{ github.event.assignee.login }} | |
- name: irc issues | |
uses: rectalogic/notify-irc@v2 | |
with: | |
server: irc.libera.chat | |
channel: "#mptcp" | |
nickname: gh-issues-bot | |
verbose: true | |
message: |- | |
Issue #${{ github.event.issue.number }} ("${{ github.event.issue.title }}"${{ steps.info.outputs.opener }}${{ steps.info.outputs.assignee }}) has been ${{ github.event.action }} by ${{ github.actor }} | |
${{ github.event.issue.html_url }} | |
build: | |
name: "Build" | |
if: github.repository_owner == 'multipath-tcp' && github.event_name == 'workflow_run' && github.event.workflow_run.name == 'MPTCP Upstream Build Validation' | |
runs-on: ubuntu-latest | |
steps: | |
- name: get linked tag | |
id: tag | |
run: | | |
TAG=$(curl ${CURL_OPT} -H "${CURL_ACC}" -H "${CURL_AUTH}" "${URL}" | jq -r ".[] | select(.object.sha == \"${SHA}\").ref" | tail -n1) | |
echo "Found: ${TAG} (${SHA} - ${BRANCH})" | |
TAG="${TAG:10}" | |
echo "tag=${TAG:-${BRANCH}}" >> ${GITHUB_OUTPUT} | |
env: | |
CURL_AUTH: "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | |
URL: "${{ env.URI }}/repos/${{ github.repository }}/git/matching-refs/tags/" | |
SHA: "${{ github.event.workflow_run.head_sha }}" | |
BRANCH: "${{ github.event.workflow_run.head_branch }}" | |
- name: irc build | |
if: startsWith(steps.tag.outputs.tag, 'export/') || startsWith(steps.tag.outputs.tag, 'export-net/') | |
uses: rectalogic/notify-irc@v2 | |
with: | |
server: irc.libera.chat | |
channel: "#mptcp-ci" | |
nickname: gh-build-bot | |
verbose: true | |
message: |- | |
New build validating ${{ steps.tag.outputs.tag }} (by ${{ github.actor }}) ended with ${{ github.event.workflow_run.conclusion }}: ${{ github.event.workflow_run.html_url }} | |
build-error: | |
name: "Build Error" | |
if: github.repository_owner == 'multipath-tcp' && github.event_name == 'workflow_run' && github.event.workflow_run.name == 'MPTCP Upstream Build Validation' && github.event.workflow_run.conclusion != 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: get linked tag | |
id: tag | |
run: | | |
TAG=$(curl ${CURL_OPT} -H "${CURL_ACC}" -H "${CURL_AUTH}" "${URL}" | jq -r ".[] | select(.object.sha == \"${SHA}\").ref" | tail -n1) | |
echo "Found: ${TAG} (${SHA} - ${BRANCH})" | |
TAG="${TAG:10}" | |
echo "tag=${TAG:-${BRANCH}}" >> ${GITHUB_OUTPUT} | |
env: | |
CURL_AUTH: "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | |
URL: "${{ env.URI }}/repos/${{ github.repository }}/git/matching-refs/tags/" | |
SHA: "${{ github.event.workflow_run.head_sha }}" | |
BRANCH: "${{ github.event.workflow_run.head_branch }}" | |
- name: irc build | |
if: startsWith(steps.tag.outputs.tag, 'export/') || startsWith(steps.tag.outputs.tag, 'export-net/') | |
uses: rectalogic/notify-irc@v2 | |
with: | |
server: irc.libera.chat | |
channel: "#mptcp" | |
nickname: gh-build-bot | |
verbose: true | |
message: |- | |
New build validating ${{ steps.tag.outputs.tag }} (by ${{ github.actor }}) failed: ${{ github.event.workflow_run.conclusion }}: ${{ github.event.workflow_run.html_url }} | |
- name: get commit info | |
if: startsWith(steps.tag.outputs.tag, 'patchew/') | |
id: commit | |
run: | | |
curl ${CURL_OPT} -H "${CURL_ACC}" -H "${CURL_AUTH}" "${URL}" > commit.json | |
read -r TAG MID < <(jq -r '.message' commit.json | grep "^Message-Id: " | tail -n1) | |
echo "Found message ID: '${TAG}' '${MID}'" | |
echo "mid=${MID:1:-1}" >> ${GITHUB_OUTPUT} | |
SUBJECT=$(jq -r '.message' commit.json | head -n1) | |
echo "Found subject: '${SUBJECT}'" | |
echo "subject=${SUBJECT}" >> ${GITHUB_OUTPUT} | |
NAME=$(jq -r '.author.name' commit.json) | |
EMAIL=$(jq -r '.author.email' commit.json) | |
echo "Found author: '${NAME}' '${EMAIL}'" | |
echo "name=${NAME%% *}" >> ${GITHUB_OUTPUT} | |
echo "author=${NAME} <${EMAIL}>" >> ${GITHUB_OUTPUT} | |
SHA="${{ github.event.workflow_run.head_sha }}" | |
echo "sha=${SHA:0:12}" >> ${GITHUB_OUTPUT} | |
env: | |
CURL_AUTH: "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | |
URL: "${{ env.URI }}/repos/${{ github.repository }}/git/commits/${{ github.event.workflow_run.head_sha }}" | |
- name: send email | |
if: startsWith(steps.tag.outputs.tag, 'patchew/') | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: smtp.gmail.com | |
server_port: 465 | |
username: ${{ secrets.MAIL_USERNAME }} | |
password: ${{ secrets.MAIL_PASSWORD }} | |
to: ${{ steps.commit.outputs.author }} | |
cc: mptcp@lists.linux.dev | |
from: MPTCP CI | |
reply_to: mptcp@lists.linux.dev | |
in_reply_to: "<${{ steps.commit.outputs.mid }}>" | |
subject: "Re: ${{ steps.commit.outputs.subject }}: Build Failure" | |
body: | | |
Hi ${{ steps.commit.outputs.name }}, | |
Thank you for your modifications, that's great! | |
But sadly, our CI spotted some issues with it when trying to build it. | |
You can find more details there: | |
https://patchwork.kernel.org/project/mptcp/patch/${{ steps.commit.outputs.mid }}/ | |
${{ github.event.workflow_run.html_url }} | |
Status: ${{ github.event.workflow_run.conclusion }} | |
Initiator: ${{ github.actor }} | |
Commits: https://github.com/${{ github.repository }}/commits/${{ steps.commit.outputs.sha }} | |
Feel free to reply to this email if you cannot access logs, if you need | |
some support to fix the error, if this doesn't seem to be caused by your | |
modifications or if the error is a false positive one. | |
Cheers, | |
MPTCP GH Action bot | |
Bot operated by Matthieu Baerts (NGI0 Core) | |
topgit: | |
name: "TopGit" | |
if: github.repository_owner == 'multipath-tcp' && github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Update TopGit tree' && github.event.workflow_run.conclusion != 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: irc topgit | |
uses: rectalogic/notify-irc@v2 | |
with: | |
server: irc.libera.chat | |
channel: "#mptcp" | |
nickname: gh-topgit-bot | |
verbose: true | |
message: |- | |
New sync with latest net-next failed (initiated by ${{ github.actor }}): ${{ github.event.workflow_run.conclusion }}: ${{ github.event.workflow_run.html_url }} | |
tests: | |
name: "Tests" | |
if: github.repository_owner == 'multipath-tcp' && github.event_name == 'check_suite' && github.event.check_suite.app.name == 'Cirrus CI' && github.event.check_suite.conclusion != 'neutral' && github.event.check_suite.conclusion != 'skipped' | |
runs-on: ubuntu-latest | |
steps: | |
- name: get linked tag | |
id: tag | |
run: | | |
TAG=$(curl ${CURL_OPT} -H "${CURL_ACC}" -H "${CURL_AUTH}" "${URL}" | jq -r ".[] | select(.object.sha == \"${SHA}\").ref" | tail -n1) | |
echo "Found: ${TAG} (${SHA})" | |
echo "tag=${TAG:10}" >> ${GITHUB_OUTPUT} | |
env: | |
CURL_AUTH: "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | |
URL: "${{ env.URI }}/repos/${{ github.repository }}/git/matching-refs/tags/" | |
SHA: "${{ github.event.check_suite.head_sha }}" | |
# inspired by: https://cirrus-ci.org/guide/notifications/ | |
- name: get cirrus status | |
id: cirrus | |
run: | | |
curl ${CURL_OPT} -H "${CURL_ACC}" -H "${CURL_AUTH}" "${URL}" > check-runs.json | |
jq -r '.check_runs[] | select(.conclusion != "neutral")' check-runs.json > check-runs_strip.json | |
i=0 | |
for id in $(jq -r '.external_id' check-runs_strip.json); do | |
echo "${i}: Found ID: ${id}" | |
url_base="https://api.cirrus-ci.com/v1/artifact/task/${id}" | |
url_ccl="${url_base}/conclusion/conclusion.txt" | |
url_sum="${url_base}/summary/summary.txt" | |
ccl="$(curl ${CURL_OPT} "${url_ccl}" || echo "${i}: Unable to get the conclusion")" | |
echo "ccl_${i}=${ccl}" >> ${GITHUB_OUTPUT} | |
echo "ccl_title_${i}=$(echo "${ccl}" | cut -d: -f1-2)" >> ${GITHUB_OUTPUT} | |
echo "ccl_status_${i}=$(echo "${ccl}" | cut -d: -f3- | sed 's/^ //')" >> ${GITHUB_OUTPUT} | |
echo "sum_${i}=${url_sum}" >> ${GITHUB_OUTPUT} | |
i=$((i+1)) | |
done | |
i=0 | |
for url in $(jq -r '.details_url' check-runs_strip.json); do | |
echo "${i}: URL: ${url}" | |
echo "url_${i}=${url}" >> ${GITHUB_OUTPUT} | |
i=$((i+1)) | |
done | |
# extra debug if nothing was found | |
if [ ${i} -eq 0 ]; then | |
jq '.' check-runs.json | |
jq '.' check-runs_strip.json | |
fi | |
env: | |
CURL_AUTH: "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | |
URL: "${{ env.URI }}/repos/${{ github.repository }}/check-suites/${{ github.event.check_suite.id }}/check-runs?status=completed" | |
- name: irc tests | |
if: startsWith(steps.tag.outputs.tag, 'export/') || startsWith(steps.tag.outputs.tag, 'export-net/') | |
uses: rectalogic/notify-irc@v2 | |
with: | |
server: irc.libera.chat | |
channel: "#mptcp-ci" | |
nickname: gh-tests-bot | |
verbose: true | |
message: |- | |
New Cirrus CI Tests job validating ${{ steps.tag.outputs.tag }} (by ${{ github.actor }}) just ended: | |
- ${{ steps.cirrus.outputs.ccl_0 }}: ${{ steps.cirrus.outputs.url_0 }} | |
- ${{ steps.cirrus.outputs.ccl_1 }}: ${{ steps.cirrus.outputs.url_1 }} | |
- name: get commit info | |
if: startsWith(steps.tag.outputs.tag, 'patchew/') | |
id: commit | |
run: | | |
curl ${CURL_OPT} -H "${CURL_ACC}" -H "${CURL_AUTH}" "${URL}" > commit.json | |
read -r TAG MID < <(jq -r '.message' commit.json | grep "^Message-Id: " | tail -n1) | |
echo "Found message ID: '${TAG}' '${MID}'" | |
echo "mid=${MID:1:-1}" >> ${GITHUB_OUTPUT} | |
SUBJECT=$(jq -r '.message' commit.json | head -n1) | |
echo "Found subject: '${SUBJECT}'" | |
echo "subject=${SUBJECT}" >> ${GITHUB_OUTPUT} | |
NAME=$(jq -r '.author.name' commit.json) | |
EMAIL=$(jq -r '.author.email' commit.json) | |
echo "Found author: '${NAME}' '${EMAIL}'" | |
echo "name=${NAME%% *}" >> ${GITHUB_OUTPUT} | |
echo "author=${NAME} <${EMAIL}>" >> ${GITHUB_OUTPUT} | |
SHA="${{ github.event.check_suite.head_sha }}" | |
echo "sha=${SHA:0:12}" >> ${GITHUB_OUTPUT} | |
COMMITTER=$(jq -r '.committer.name' commit.json) | |
echo "Found committer: '${COMMITTER}'" | |
echo "committer=${COMMITTER}" >> ${GITHUB_OUTPUT} | |
env: | |
CURL_AUTH: "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | |
URL: "${{ env.URI }}/repos/${{ github.repository }}/git/commits/${{ github.event.check_suite.head_sha }}" | |
- name: send email | |
if: startsWith(steps.tag.outputs.tag, 'patchew/') | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: smtp.gmail.com | |
server_port: 465 | |
username: ${{ secrets.MAIL_USERNAME }} | |
password: ${{ secrets.MAIL_PASSWORD }} | |
to: ${{ steps.commit.outputs.author }} | |
cc: mptcp@lists.linux.dev | |
from: MPTCP CI | |
reply_to: mptcp@lists.linux.dev | |
in_reply_to: "<${{ steps.commit.outputs.mid }}>" | |
subject: "Re: ${{ steps.commit.outputs.subject }}: Tests Results" | |
body: | | |
Hi ${{ steps.commit.outputs.name }}, | |
Thank you for your modifications, that's great! | |
Our CI (Cirrus) did some validations with a debug kernel and here is its report: | |
- ${{ steps.cirrus.outputs.ccl_title_0 }}: | |
- ${{ steps.cirrus.outputs.ccl_status_0 }}: | |
- Task: ${{ steps.cirrus.outputs.url_0 }} | |
- Summary: ${{ steps.cirrus.outputs.sum_0 }} | |
- ${{ steps.cirrus.outputs.ccl_title_1 }}: | |
- ${{ steps.cirrus.outputs.ccl_status_1 }}: | |
- Task: ${{ steps.cirrus.outputs.url_1 }} | |
- Summary: ${{ steps.cirrus.outputs.sum_1 }} | |
Initiator: ${{ steps.commit.outputs.committer }} | |
Commits: https://github.com/${{ github.repository }}/commits/${{ steps.commit.outputs.sha }} | |
If there are some issues, you can reproduce them using the same environment as | |
the one used by the CI thanks to a docker image, e.g.: | |
$ cd [kernel source code] | |
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \ | |
--pull always mptcp/mptcp-upstream-virtme-docker:latest \ | |
auto-debug | |
For more details: | |
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker | |
Please note that despite all the efforts that have been already done to have a | |
stable tests suite when executed on a public CI like here, it is possible some | |
reported issues are not due to your modifications. Still, do not hesitate to | |
help us improve that ;-) | |
Cheers, | |
MPTCP GH Action bot | |
Bot operated by Matthieu Baerts (NGI0 Core) | |
- name: set patchwork check | |
if: startsWith(steps.tag.outputs.tag, 'patchew/') | |
run: | | |
CHECK_URLS=() | |
set_url() { local series_url | |
series_url=$(curl ${CURL_OPT} "${URL}" | jq -r 'last(last(.[].series)[].url)') | |
if [ -z "${series_url}" ] || [ "${series_url}" = "null" ]; then | |
echo "Series not found: '${series_url}' '${URL}'" | |
return 1 | |
fi | |
echo "Found Series: '${series_url}'" | |
readarray -t CHECK_URLS < <(curl ${CURL_OPT} "${series_url}" | jq -r '.patches[].url + "checks/"') | |
} | |
# $1: title, $2: status, $3: url | |
submit() { local check_url | |
if [[ "${2}" == "Success"* ]]; then | |
STATE="success" | |
elif [[ "${2}" == "Unstable"* ]]; then | |
STATE="warning" | |
else | |
STATE="fail" | |
fi | |
for check_url in "${CHECK_URLS[@]}"; do | |
curl ${CURL_OPT} \ | |
-X POST \ | |
-H "Authorization: Token ${{ secrets.PW_TOKEN }}" \ | |
-F "state=${STATE}" \ | |
-F "target_url=${3}" \ | |
-F "context=${1//[ :()]/_}" \ | |
-F "description=${2}" \ | |
"${check_url}" | jq '.' | |
done | |
} | |
for i in $(seq 30); do # patches can take a bit of time to appear | |
set_url && break | |
sleep 1m | |
done | |
if [ "${#CHECK_URLS[@]}" -eq 0 ]; then | |
echo "Error: didn't find any URLs after ${i} attempts" | |
exit 1 | |
fi | |
echo "Found: ${#CHECK_URLS[@]} urls after ${i} attempts: ${CHECK_URLS[@]}" | |
submit "${{ steps.cirrus.outputs.ccl_title_0 }}" "${{ steps.cirrus.outputs.ccl_status_0 }}" "${{ steps.cirrus.outputs.url_0 }}" | |
submit "${{ steps.cirrus.outputs.ccl_title_1 }}" "${{ steps.cirrus.outputs.ccl_status_1 }}" "${{ steps.cirrus.outputs.url_1 }}" | |
env: | |
URL: "${{ env.PW }}/patches/?project=mptcp&msgid=${{ steps.commit.outputs.mid }}" |