Skip to content

Commit 77fd5be

Browse files
committed
update ingestion to use github
1 parent b3122ec commit 77fd5be

5 files changed

Lines changed: 291 additions & 235 deletions

File tree

.github/workflows/external_trigger.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ jobs:
2929
echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY
3030
echo "> External trigger running off of master branch. To disable this trigger, add \`scummvm_master\` into the Github organizational variable \`SKIP_EXTERNAL_TRIGGER\`." >> $GITHUB_STEP_SUMMARY
3131
printf "\n## Retrieving external version\n\n" >> $GITHUB_STEP_SUMMARY
32-
EXT_RELEASE=$(curl -s https://downloads.scummvm.org/frs/scummvm/ | awk -F'(<a href="|/">)' '{print $2}'| grep -B 1 'daily' |head -n1)
33-
echo "Type is \`custom_version_command\`" >> $GITHUB_STEP_SUMMARY
32+
EXT_RELEASE=$(curl -u "${{ secrets.CR_USER }}:${{ secrets.CR_PAT }}" -sX GET "https://api.github.com/repos/scummvm/scummvm/releases/latest" | jq -r '. | .tag_name')
33+
echo "Type is \`github_stable\`" >> $GITHUB_STEP_SUMMARY
3434
if grep -q "^scummvm_master_${EXT_RELEASE}" <<< "${SKIP_EXTERNAL_TRIGGER}"; then
3535
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
3636
echo "> Github organizational variable \`SKIP_EXTERNAL_TRIGGER\` matches current external release; skipping trigger." >> $GITHUB_STEP_SUMMARY
@@ -110,7 +110,7 @@ jobs:
110110
echo "New version \`${EXT_RELEASE}\` found; but there already seems to be an active build on Jenkins; exiting" >> $GITHUB_STEP_SUMMARY
111111
exit 0
112112
else
113-
if curl -IfSsL "https://downloads.scummvm.org/frs/scummvm/${EXT_RELEASE}/scummvm_${EXT_RELEASE}-1_ubuntu24_04_amd64.deb" > /dev/null 2>&1; then
113+
if curl -IfSsL "https://downloads.scummvm.org/frs/scummvm/$(echo ${EXT_RELEASE}| sed 's/^v//g')/scummvm_$(echo ${EXT_RELEASE}| sed 's/^v//g')-1_ubuntu24_04_amd64.deb" > /dev/null 2>&1; then
114114
artifacts_found="true"
115115
else
116116
artifacts_found="false"

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ RUN \
1818
https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/scummvm-logo.png && \
1919
echo "**** install packages ****" && \
2020
if [ -z "${SCUMMVM_VERSION+x}" ]; then \
21-
SCUMMVM_VERSION=$(curl -s https://downloads.scummvm.org/frs/scummvm/ \
22-
| awk -F'(<a href="|/">)' '{print $2}'| grep -B 1 'daily' |head -n1); \
21+
SCUMMVM_VERSION=$(curl -sX GET "https://api.github.com/repos/scummvm/scummvm/releases/latest" \
22+
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
2323
fi && \
2424
curl -o \
2525
/tmp/scummvm.deb -L \
26-
"https://downloads.scummvm.org/frs/scummvm/${SCUMMVM_VERSION}/scummvm_${SCUMMVM_VERSION}-1_ubuntu24_04_amd64.deb" && \
26+
"https://downloads.scummvm.org/frs/scummvm/$(echo ${SCUMMVM_VERSION} | sed 's/^v//g')/scummvm_$(echo ${SCUMMVM_VERSION} | sed 's/^v//g')-1_ubuntu24_04_amd64.deb" && \
2727
apt-get update && \
2828
apt-get install -y \
2929
/tmp/scummvm.deb && \

Jenkinsfile

Lines changed: 106 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ pipeline {
1919
DOCKERHUB_TOKEN=credentials('docker-hub-ci-pat')
2020
QUAYIO_API_TOKEN=credentials('quayio-repo-api-token')
2121
GIT_SIGNING_KEY=credentials('484fbca6-9a4f-455e-b9e3-97ac98785f5f')
22+
EXT_USER = 'scummvm'
23+
EXT_REPO = 'scummvm'
2224
BUILD_VERSION_ARG = 'SCUMMVM_VERSION'
2325
LS_USER = 'linuxserver'
2426
LS_REPO = 'docker-scummvm'
@@ -75,6 +77,7 @@ pipeline {
7577
'''
7678
script{
7779
env.EXIT_STATUS = ''
80+
env.CI_TEST_ATTEMPTED = ''
7881
env.LS_RELEASE = sh(
7982
script: '''docker run --rm quay.io/skopeo/stable:v1 inspect docker://ghcr.io/${LS_USER}/${CONTAINER_NAME}:latest 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
8083
returnStdout: true).trim()
@@ -142,16 +145,23 @@ pipeline {
142145
/* ########################
143146
External Release Tagging
144147
######################## */
145-
// If this is a custom command to determine version use that command
146-
stage("Set tag custom bash"){
147-
steps{
148-
script{
149-
env.EXT_RELEASE = sh(
150-
script: ''' curl -s https://downloads.scummvm.org/frs/scummvm/ | awk -F'(<a href="|/">)' '{print $2}'| grep -B 1 'daily' |head -n1 ''',
151-
returnStdout: true).trim()
152-
env.RELEASE_LINK = 'custom_command'
153-
}
154-
}
148+
// If this is a stable github release use the latest endpoint from github to determine the ext tag
149+
stage("Set ENV github_stable"){
150+
steps{
151+
script{
152+
env.EXT_RELEASE = sh(
153+
script: '''curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .tag_name' ''',
154+
returnStdout: true).trim()
155+
}
156+
}
157+
}
158+
// If this is a stable or devel github release generate the link for the build message
159+
stage("Set ENV github_link"){
160+
steps{
161+
script{
162+
env.RELEASE_LINK = 'https://github.com/' + env.EXT_USER + '/' + env.EXT_REPO + '/releases/tag/' + env.EXT_RELEASE
163+
}
164+
}
155165
}
156166
// Sanitize the release tag and strip illegal docker or github characters
157167
stage("Sanitize tag"){
@@ -283,7 +293,7 @@ pipeline {
283293
-v ${WORKSPACE}:/mnt \
284294
-e AWS_ACCESS_KEY_ID=\"${S3_KEY}\" \
285295
-e AWS_SECRET_ACCESS_KEY=\"${S3_SECRET}\" \
286-
ghcr.io/linuxserver/baseimage-alpine:3 s6-envdir -fn -- /var/run/s6/container_environment /bin/bash -c "\
296+
ghcr.io/linuxserver/baseimage-alpine:3.23 s6-envdir -fn -- /var/run/s6/container_environment /bin/bash -c "\
287297
apk add --no-cache python3 && \
288298
python3 -m venv /lsiopy && \
289299
pip install --no-cache-dir -U pip && \
@@ -871,6 +881,7 @@ pipeline {
871881
script{
872882
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
873883
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
884+
env.CI_TEST_ATTEMPTED = 'true'
874885
}
875886
sh '''#! /bin/bash
876887
set -e
@@ -1020,7 +1031,7 @@ pipeline {
10201031
"type": "commit",\
10211032
"tagger": {"name": "LinuxServer-CI","email": "[email protected]","date": "'${GITHUB_DATE}'"}}'
10221033
echo "Pushing New release for Tag"
1023-
echo "Updating to ${EXT_RELEASE_CLEAN}" > releasebody.json
1034+
curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. |.body' > releasebody.json
10241035
jq -n \
10251036
--arg tag_name "$META_TAG" \
10261037
--arg target_commitish "master" \
@@ -1073,98 +1084,13 @@ EOF
10731084
) '''
10741085
}
10751086
}
1076-
// If this is a Pull request send the CI link as a comment on it
1077-
stage('Pull Request Comment') {
1078-
when {
1079-
not {environment name: 'CHANGE_ID', value: ''}
1080-
environment name: 'EXIT_STATUS', value: ''
1081-
}
1082-
steps {
1083-
sh '''#! /bin/bash
1084-
# Function to retrieve JSON data from URL
1085-
get_json() {
1086-
local url="$1"
1087-
local response=$(curl -s "$url")
1088-
if [ $? -ne 0 ]; then
1089-
echo "Failed to retrieve JSON data from $url"
1090-
return 1
1091-
fi
1092-
local json=$(echo "$response" | jq .)
1093-
if [ $? -ne 0 ]; then
1094-
echo "Failed to parse JSON data from $url"
1095-
return 1
1096-
fi
1097-
echo "$json"
1098-
}
1099-
1100-
build_table() {
1101-
local data="$1"
1102-
1103-
# Get the keys in the JSON data
1104-
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1105-
1106-
# Check if keys are empty
1107-
if [ -z "$keys" ]; then
1108-
echo "JSON report data does not contain any keys or the report does not exist."
1109-
return 1
1110-
fi
1111-
1112-
# Build table header
1113-
local header="| Tag | Passed |\\n| --- | --- |\\n"
1114-
1115-
# Loop through the JSON data to build the table rows
1116-
local rows=""
1117-
for build in $keys; do
1118-
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1119-
if [ "$status" = "true" ]; then
1120-
status="✅"
1121-
else
1122-
status="❌"
1123-
fi
1124-
local row="| "$build" | "$status" |\\n"
1125-
rows="${rows}${row}"
1126-
done
1127-
1128-
local table="${header}${rows}"
1129-
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1130-
echo "$escaped_table"
1131-
}
1132-
1133-
if [[ "${CI}" = "true" ]]; then
1134-
# Retrieve JSON data from URL
1135-
data=$(get_json "$CI_JSON_URL")
1136-
# Create table from JSON data
1137-
table=$(build_table "$data")
1138-
echo -e "$table"
1139-
1140-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1141-
-H "Accept: application/vnd.github.v3+json" \
1142-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1143-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1144-
else
1145-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1146-
-H "Accept: application/vnd.github.v3+json" \
1147-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1148-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1149-
fi
1150-
'''
1151-
1152-
}
1153-
}
11541087
}
11551088
/* ######################
1156-
Send status to Discord
1089+
Comment on PR and Send status to Discord
11571090
###################### */
11581091
post {
11591092
always {
1160-
sh '''#!/bin/bash
1161-
rm -rf /config/.ssh/id_sign
1162-
rm -rf /config/.ssh/id_sign.pub
1163-
git config --global --unset gpg.format
1164-
git config --global --unset user.signingkey
1165-
git config --global --unset commit.gpgsign
1166-
'''
1167-
script{
1093+
script {
11681094
env.JOB_DATE = sh(
11691095
script: '''date '+%Y-%m-%dT%H:%M:%S%:z' ''',
11701096
returnStdout: true).trim()
@@ -1207,6 +1133,87 @@ EOF
12071133
"username": "Jenkins"}' ${BUILDS_DISCORD} '''
12081134
}
12091135
}
1136+
script {
1137+
if (env.GITHUBIMAGE =~ /lspipepr/){
1138+
if (env.CI_TEST_ATTEMPTED == "true"){
1139+
sh '''#! /bin/bash
1140+
# Function to retrieve JSON data from URL
1141+
get_json() {
1142+
local url="$1"
1143+
local response=$(curl -s "$url")
1144+
if [ $? -ne 0 ]; then
1145+
echo "Failed to retrieve JSON data from $url"
1146+
return 1
1147+
fi
1148+
local json=$(echo "$response" | jq .)
1149+
if [ $? -ne 0 ]; then
1150+
echo "Failed to parse JSON data from $url"
1151+
return 1
1152+
fi
1153+
echo "$json"
1154+
}
1155+
1156+
build_table() {
1157+
local data="$1"
1158+
1159+
# Get the keys in the JSON data
1160+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1161+
1162+
# Check if keys are empty
1163+
if [ -z "$keys" ]; then
1164+
echo "JSON report data does not contain any keys or the report does not exist."
1165+
return 1
1166+
fi
1167+
1168+
# Build table header
1169+
local header="| Tag | Passed |\\n| --- | --- |\\n"
1170+
1171+
# Loop through the JSON data to build the table rows
1172+
local rows=""
1173+
for build in $keys; do
1174+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1175+
if [ "$status" = "true" ]; then
1176+
status="✅"
1177+
else
1178+
status="❌"
1179+
fi
1180+
local row="| "$build" | "$status" |\\n"
1181+
rows="${rows}${row}"
1182+
done
1183+
1184+
local table="${header}${rows}"
1185+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1186+
echo "$escaped_table"
1187+
}
1188+
1189+
if [[ "${CI}" = "true" ]]; then
1190+
# Retrieve JSON data from URL
1191+
data=$(get_json "$CI_JSON_URL")
1192+
# Create table from JSON data
1193+
table=$(build_table "$data")
1194+
echo -e "$table"
1195+
1196+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1197+
-H "Accept: application/vnd.github.v3+json" \
1198+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1199+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1200+
else
1201+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1202+
-H "Accept: application/vnd.github.v3+json" \
1203+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1204+
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1205+
fi
1206+
'''
1207+
}
1208+
}
1209+
}
1210+
sh '''#!/bin/bash
1211+
rm -rf /config/.ssh/id_sign
1212+
rm -rf /config/.ssh/id_sign.pub
1213+
git config --global --unset gpg.format
1214+
git config --global --unset user.signingkey
1215+
git config --global --unset commit.gpgsign
1216+
'''
12101217
}
12111218
cleanup {
12121219
sh '''#! /bin/bash

0 commit comments

Comments
 (0)