aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Segundo2024-07-23 21:43:05 +0200
committerChristian Segundo2024-07-23 21:43:05 +0200
commit362af4e16d7cdfa1512a6f2f154f055907b4d900 (patch)
treef0e8817df1cad49bd466c60016cdd8b70913690c
parent076b6aefd5b17cccc34cc403b7b4f2ba4f093a57 (diff)
downloadtransmission-hacks-362af4e16d7cdfa1512a6f2f154f055907b4d900.tar.gz
add ci
-rw-r--r--.scripts.d/20-build.sh20
-rw-r--r--.scripts.d/30-test.sh28
-rw-r--r--.scripts.d/40-publish.sh45
-rw-r--r--Dockerfile2
-rw-r--r--Jenkinsfile24
-rwxr-xr-xsrc/ask-tracker-for-more-peers.py (renamed from scripts/ask-tracker-for-more-peers.py)0
-rw-r--r--src/cron.sh (renamed from scripts/cron.sh)0
-rwxr-xr-xsrc/delete-based-on-tag.py (renamed from scripts/delete-based-on-tag.py)0
-rw-r--r--src/delete-if-unlinked.py (renamed from scripts/delete-if-unlinked.py)0
-rw-r--r--src/entrypoint.sh (renamed from scripts/entrypoint.sh)1
-rw-r--r--src/requirements.txt (renamed from scripts/requirements.txt)0
-rwxr-xr-xsrc/tag-based-on-dir.py (renamed from scripts/tag-based-on-dir.py)0
12 files changed, 119 insertions, 1 deletions
diff --git a/.scripts.d/20-build.sh b/.scripts.d/20-build.sh
new file mode 100644
index 0000000..6f8beb9
--- /dev/null
+++ b/.scripts.d/20-build.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# vim: ai:ts=8:sw=8:noet
+set -EeufCo pipefail
+export SHELLOPTS # propagate set to children by default
+IFS=$'\t\n'
+
+# check required commands are in place
+command -v docker >/dev/null 2>&1 || {
+ echo 'please install docker-client'
+ exit 1
+}
+
+docker buildx build \
+ --no-cache \
+ --pull \
+ --load \
+ --tag "chn2guevara/transmission-hacks:${BUILD_ID}" \
+ .
+
+
diff --git a/.scripts.d/30-test.sh b/.scripts.d/30-test.sh
new file mode 100644
index 0000000..16c4fac
--- /dev/null
+++ b/.scripts.d/30-test.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# vim: ai:ts=8:sw=8:noet
+set -EeufCo pipefail
+export SHELLOPTS # propagate set to children by default
+IFS=$'\t\n'
+
+# check required commands are in place
+command -v docker >/dev/null 2>&1 || {
+ echo 'please install docker-client'
+ exit 1
+}
+
+# install goss
+curl -fsSL https://goss.rocks/install | sh
+
+export GOSS_SLEEP=${GOSS_SLEEP:-5}
+export GOSS_VARS=${GOSS_VARS:-}
+export GOSS_ADDITIONAL_COPY_PATH=${GOSS_ADDITIONAL_COPY_PATH:-}
+export GOSS_OPTS="--format junit --no-color"
+export CONTAINER_LOG_OUTPUT=${CONTAINER_LOG_OUTPUT:-}
+export GOSS_FILES_STRATEGY=cp
+
+goss --gossfile goss.yaml render >goss-full.yaml
+mv goss-full.yaml goss.yaml
+
+rm -rf build/reports/
+mkdir -p build/reports/
+dgoss run "chn2guevara/transmission-hacks:${BUILD_ID}" "/usr/bin/sleep" "infinity" >build/reports/goss.xml
diff --git a/.scripts.d/40-publish.sh b/.scripts.d/40-publish.sh
new file mode 100644
index 0000000..4f5f4d4
--- /dev/null
+++ b/.scripts.d/40-publish.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+# vim: ai:ts=8:sw=8:noet
+set -EeufCo pipefail
+export SHELLOPTS # propagate set to children by default
+IFS=$'\t\n'
+
+# check required commands are in place
+command -v docker >/dev/null 2>&1 || {
+ echo 'please install docker-client'
+ exit 1
+}
+
+docker login --username "chn2guevara" \
+ --password-stdin <<<"$DOCKERHUB_TOKEN"
+
+BUILDER_SUFFIX=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5 ; echo '')
+docker run --privileged --rm tonistiigi/binfmt --install arm64
+docker buildx create --use --name "multi-arch-builder-${BUILDER_SUFFIX}"
+trap "docker buildx rm 'multi-arch-builder-""${BUILDER_SUFFIX}""'" EXIT
+
+DOCKER_TAG="latest"
+if [ "$GIT_BRANCH" != "master" ]; then
+ DOCKER_TAG="${GIT_BRANCH//\//-}"
+fi
+
+if [ "$(git tag --contains)" = "" ]; then
+ docker buildx build \
+ --platform linux/amd64,linux/arm64 \
+ --builder "multi-arch-builder-${BUILDER_SUFFIX}" \
+ --no-cache \
+ --pull \
+ --push \
+ --tag "chn2guevara/transmission-hacks:${DOCKER_TAG}" \
+ .
+else
+ docker buildx build \
+ --platform linux/amd64,linux/arm64 \
+ --builder "multi-arch-builder-${BUILDER_SUFFIX}" \
+ --no-cache \
+ --pull \
+ --push \
+ --tag "chn2guevara/transmission-hacks:${DOCKER_TAG}" \
+ --tag "chn2guevara/transmission-hacks:$(git tag --contains | head -1)" \
+ .
+fi
diff --git a/Dockerfile b/Dockerfile
index a52c49b..35af27c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
FROM python:slim-bullseye
-COPY scripts /scripts
+COPY src /scripts
# hadolint ignore=DL3008
RUN \
apt-get update && \
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..1293357
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,24 @@
+String cron_string = BRANCH_NAME == "master" ? "@weekly" : ""
+
+pipeline {
+ agent any
+ triggers { cron(cron_string) }
+ options { ansiColor('xterm') }
+ stages {
+ stage('Build') { steps { sh 'bash .scripts.d/20-build.sh' } }
+ stage('Test') { steps { sh 'bash .scripts.d/30-test.sh' } }
+ stage('Publish') {
+ environment { DOCKERHUB_TOKEN = credentials('DOCKERHUB_TOKEN') }
+ steps { sh 'bash .scripts.d/40-publish.sh' }
+ }
+ }
+ post {
+ always {
+ junit 'build/reports/*.xml'
+ step([$class: 'Mailer',
+ notifyEveryUnstableBuild: true,
+ recipients: "christian+jenkins@segundo.io",
+ sendToIndividuals: true])
+ }
+ }
+}
diff --git a/scripts/ask-tracker-for-more-peers.py b/src/ask-tracker-for-more-peers.py
index 8b874f0..8b874f0 100755
--- a/scripts/ask-tracker-for-more-peers.py
+++ b/src/ask-tracker-for-more-peers.py
diff --git a/scripts/cron.sh b/src/cron.sh
index 1ce9e65..1ce9e65 100644
--- a/scripts/cron.sh
+++ b/src/cron.sh
diff --git a/scripts/delete-based-on-tag.py b/src/delete-based-on-tag.py
index 37442cb..37442cb 100755
--- a/scripts/delete-based-on-tag.py
+++ b/src/delete-based-on-tag.py
diff --git a/scripts/delete-if-unlinked.py b/src/delete-if-unlinked.py
index 54df8ff..54df8ff 100644
--- a/scripts/delete-if-unlinked.py
+++ b/src/delete-if-unlinked.py
diff --git a/scripts/entrypoint.sh b/src/entrypoint.sh
index 93c248d..925afa1 100644
--- a/scripts/entrypoint.sh
+++ b/src/entrypoint.sh
@@ -7,6 +7,7 @@ SCRIPT_PREFIX=/scripts
SCRIPT_TIMEOUT=${SCRIPT_TIMEOUT:-300}
TRANSMISSION_HOST=${TRANSMISSION_HOST:-localhost}
TRANSMISSION_PORT=${TRANSMISSION_PORT:-9091}
+TRANSMISSION_DOWNLOAD_ROOT=${TRANSMISSION_DOWNLOAD_ROOT:-/downloads/complete}
EOF
i=0
diff --git a/scripts/requirements.txt b/src/requirements.txt
index 482070c..482070c 100644
--- a/scripts/requirements.txt
+++ b/src/requirements.txt
diff --git a/scripts/tag-based-on-dir.py b/src/tag-based-on-dir.py
index 8cec41b..8cec41b 100755
--- a/scripts/tag-based-on-dir.py
+++ b/src/tag-based-on-dir.py