From 4bc2d864ad1b09422647da724244c1c3960d5ec4 Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 6 Apr 2023 14:47:51 +0200 Subject: [PATCH] chore: add jenkins ci pipeline --- Jenkinsfile | 49 +++++++++++++++++++++++++++++++++++++++++ Makefile | 6 +++-- misc/jenkins/Dockerfile | 28 +++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 Jenkinsfile create mode 100644 misc/jenkins/Dockerfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..bbd67a0 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,49 @@ +@Library('cadoles') _ + +pipeline { + agent { + dockerfile { + label 'docker' + filename 'Dockerfile' + dir 'misc/jenkins' + } + } + + stages { + stage('Run unit tests') { + steps { + script { + sh 'make GOTEST_ARGS="-timeout 10m -count=1 -v" test' + } + } + } + + stage('Release') { + when { + anyOf { + branch 'master' + branch 'develop' + } + } + steps { + script { + withCredentials([ + usernamePassword([ + credentialsId: 'forge-jenkins', + usernameVariable: 'GITEA_RELEASE_USERNAME', + passwordVariable: 'GITEA_RELEASE_PASSWORD' + ]) + ]) { + sh 'make gitea-release' + } + } + } + } + } + + post { + always { + cleanWs() + } + } +} diff --git a/Makefile b/Makefile index 9d99839..ce877cf 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ GIT_VERSION := $(shell git describe --always) DATE_VERSION := $(shell date +%Y.%-m.%-d) FULL_VERSION := v$(DATE_VERSION)-$(GIT_VERSION)$(if $(shell git diff --stat),-dirty,) -build: build-edge-cli +build: build-edge-cli build-client-sdk-test-app watch: go run -mod=readonly github.com/cortesi/modd/cmd/modd@latest @@ -30,10 +30,12 @@ build-edge-cli: build-sdk -o ./bin/cli \ ./cmd/cli +build-client-sdk-test-app: + cd misc/client-sdk-testsuite && $(MAKE) dist + install-git-hooks: git config core.hooksPath .githooks - tools/esbuild/bin/esbuild: mkdir -p tools/esbuild/bin curl -fsSL https://esbuild.github.io/dl/$(ESBUILD_VERSION) | sh diff --git a/misc/jenkins/Dockerfile b/misc/jenkins/Dockerfile new file mode 100644 index 0000000..1826983 --- /dev/null +++ b/misc/jenkins/Dockerfile @@ -0,0 +1,28 @@ +FROM reg.cadoles.com/proxy_cache/library/ubuntu:22.04 + +ARG HTTP_PROXY= +ARG HTTPS_PROXY= +ARG http_proxy= +ARG https_proxy= +ARG GO_VERSION=1.19.2 + +# Install dev environment dependencies +RUN export DEBIAN_FRONTEND=noninteractive &&\ + apt-get update -y &&\ + apt-get install -y --no-install-recommends curl ca-certificates build-essential wget unzip tar git jq + +# Install Go +RUN mkdir -p /tmp \ + && wget -O /tmp/go${GO_VERSION}.linux-amd64.tar.gz https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz \ + && rm -rf /usr/local/go \ + && mkdir -p /usr/local \ + && tar -C /usr/local -xzf /tmp/go${GO_VERSION}.linux-amd64.tar.gz + +ENV PATH="${PATH}:/usr/local/go/bin" + +# Add LetsEncrypt certificates +RUN curl -k https://forge.cadoles.com/Cadoles/Jenkins/raw/branch/master/resources/com/cadoles/common/add-letsencrypt-ca.sh | bash + +# Install NodeJS +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ + && apt-get install -y nodejs \ No newline at end of file