-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v0.1.0' into main
- Loading branch information
Showing
50 changed files
with
3,130 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# ces-commons-lib Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [v0.1.0] - 2024-11-15 | ||
### Added | ||
- [#1] Add RemoteDoguDescriptorRepository interface and common errors |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!groovy | ||
|
||
@Library(['github.com/cloudogu/[email protected]']) | ||
import com.cloudogu.ces.cesbuildlib.* | ||
|
||
// Creating necessary git objects | ||
git = new Git(this, "cesmarvin") | ||
git.committerName = 'cesmarvin' | ||
git.committerEmail = '[email protected]' | ||
gitflow = new GitFlow(this, git) | ||
github = new GitHub(this, git) | ||
changelog = new Changelog(this) | ||
Docker docker = new Docker(this) | ||
gpg = new Gpg(this, docker) | ||
goVersion = "1.23" | ||
|
||
// Configuration of repository | ||
repositoryOwner = "cloudogu" | ||
repositoryName = "ces-commons-lib" | ||
project = "github.com/${repositoryOwner}/${repositoryName}" | ||
|
||
// Configuration of branches | ||
productionReleaseBranch = "main" | ||
developmentBranch = "develop" | ||
currentBranch = "${env.BRANCH_NAME}" | ||
|
||
node('docker') { | ||
timestamps { | ||
stage('Checkout') { | ||
checkout scm | ||
make 'clean' | ||
} | ||
|
||
stage('Check Markdown Links') { | ||
Markdown markdown = new Markdown(this, "3.11.0") | ||
markdown.check() | ||
} | ||
|
||
new Docker(this) | ||
.image("golang:${goVersion}") | ||
.mountJenkinsUser() | ||
.inside("--volume ${WORKSPACE}:/go/src/${project} -w /go/src/${project}") { | ||
stage('Unit test') { | ||
make 'unit-test' | ||
junit allowEmptyResults: true, testResults: 'target/unit-tests/*-tests.xml' | ||
} | ||
|
||
stage("Review dog analysis") { | ||
stageStaticAnalysisReviewDog() | ||
} | ||
} | ||
|
||
stage('SonarQube') { | ||
stageStaticAnalysisSonarQube() | ||
} | ||
|
||
|
||
stageAutomaticRelease() | ||
} | ||
} | ||
|
||
void gitWithCredentials(String command) { | ||
withCredentials([usernamePassword(credentialsId: 'cesmarvin', usernameVariable: 'GIT_AUTH_USR', passwordVariable: 'GIT_AUTH_PSW')]) { | ||
sh( | ||
script: "git -c credential.helper=\"!f() { echo username='\$GIT_AUTH_USR'; echo password='\$GIT_AUTH_PSW'; }; f\" " + command, | ||
returnStdout: true | ||
) | ||
} | ||
} | ||
|
||
void stageStaticAnalysisReviewDog() { | ||
def commitSha = sh(returnStdout: true, script: 'git rev-parse HEAD').trim() | ||
|
||
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'sonarqube-gh', usernameVariable: 'USERNAME', passwordVariable: 'REVIEWDOG_GITHUB_API_TOKEN']]) { | ||
withEnv(["CI_PULL_REQUEST=${env.CHANGE_ID}", "CI_COMMIT=${commitSha}", "CI_REPO_OWNER=${repositoryOwner}", "CI_REPO_NAME=${repositoryName}"]) { | ||
make 'static-analysis-ci' | ||
} | ||
} | ||
} | ||
|
||
void stageStaticAnalysisSonarQube() { | ||
def scannerHome = tool name: 'sonar-scanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation' | ||
withSonarQubeEnv { | ||
sh "git config 'remote.origin.fetch' '+refs/heads/*:refs/remotes/origin/*'" | ||
gitWithCredentials("fetch --all") | ||
|
||
if (currentBranch == productionReleaseBranch) { | ||
echo "This branch has been detected as the production branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME}" | ||
} else if (currentBranch == developmentBranch) { | ||
echo "This branch has been detected as the development branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME}" | ||
} else if (env.CHANGE_TARGET) { | ||
echo "This branch has been detected as a pull request." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.base=${developmentBranch}" | ||
} else if (currentBranch.startsWith("feature/")) { | ||
echo "This branch has been detected as a feature branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME}" | ||
} else { | ||
echo "This branch has been detected as a miscellaneous branch." | ||
sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${env.BRANCH_NAME} " | ||
} | ||
} | ||
timeout(time: 2, unit: 'MINUTES') { // Needed when there is no webhook for example | ||
def qGate = waitForQualityGate() | ||
if (qGate.status != 'OK') { | ||
unstable("Pipeline unstable due to SonarQube quality gate failure") | ||
} | ||
} | ||
} | ||
|
||
void stageAutomaticRelease() { | ||
if (gitflow.isReleaseBranch()) { | ||
String releaseVersion = git.getSimpleBranchName() | ||
|
||
stage('Finish Release') { | ||
gitflow.finishRelease(releaseVersion, productionReleaseBranch) | ||
} | ||
|
||
stage('Add Github-Release') { | ||
releaseId = github.createReleaseWithChangelog(releaseVersion, changelog, productionReleaseBranch) | ||
} | ||
} | ||
} | ||
|
||
void make(String makeArgs) { | ||
sh "make ${makeArgs}" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ARTIFACT_ID=ces-commons-lib | ||
VERSION=0.1.0 | ||
|
||
MAKEFILES_VERSION=9.3.2 | ||
.DEFAULT_GOAL:=help | ||
|
||
include build/make/variables.mk | ||
include build/make/self-update.mk | ||
include build/make/dependencies-gomod.mk | ||
include build/make/build.mk | ||
include build/make/test-common.mk | ||
include build/make/test-unit.mk | ||
include build/make/static-analysis.mk | ||
include build/make/clean.mk | ||
include build/make/release.mk |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
# ces-commons-lib | ||
# ces-commons-lib | ||
|
||
A Go library for interacting with the Cloudogu EcoSystem. | ||
|
||
## What is the Cloudogu EcoSystem? | ||
The Cloudogu EcoSystem is an open platform, which lets you choose how and where your team creates great software. Each service or tool is delivered as a Dogu, a Docker container. Each Dogu can easily be integrated in your environment just by pulling it from our registry. | ||
|
||
We have a growing number of ready-to-use Dogus, e.g. SCM-Manager, Jenkins, Nexus Repository, SonarQube, Redmine and many more. Every Dogu can be tailored to your specific needs. Take advantage of a central authentication service, a dynamic navigation, that lets you easily switch between the web UIs and a smart configuration magic, which automatically detects and responds to dependencies between Dogus. | ||
|
||
The Cloudogu EcoSystem is open source and it runs either on-premises or in the cloud. The Cloudogu EcoSystem is developed by Cloudogu GmbH under [AGPL-3.0-only](https://spdx.org/licenses/AGPL-3.0-only.html). | ||
|
||
## License | ||
Copyright © 2020 - present Cloudogu GmbH | ||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3. | ||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/. | ||
See [LICENSE](LICENSE) for details. | ||
|
||
|
||
--- | ||
MADE WITH :heart: FOR DEV ADDICTS. [Legal notice / Imprint](https://cloudogu.com/en/imprint/?mtm_campaign=ecosystem&mtm_kwd=imprint&mtm_source=github&mtm_medium=link) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[*.mk] | ||
indent_style = tab |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
deb | ||
tmp |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
WORKSPACE=/workspace | ||
BATS_LIBRARY_DIR=$(TARGET_DIR)/bats_libs | ||
TESTS_DIR=$(WORKDIR)/batsTests | ||
BASH_TEST_REPORT_DIR=$(TARGET_DIR)/shell_test_reports | ||
BASH_TEST_REPORTS=$(BASH_TEST_REPORT_DIR)/TestReport-*.xml | ||
BATS_ASSERT=$(BATS_LIBRARY_DIR)/bats-assert | ||
BATS_MOCK=$(BATS_LIBRARY_DIR)/bats-mock | ||
BATS_SUPPORT=$(BATS_LIBRARY_DIR)/bats-support | ||
BATS_FILE=$(BATS_LIBRARY_DIR)/bats-file | ||
BATS_BASE_IMAGE?=bats/bats | ||
BATS_CUSTOM_IMAGE?=cloudogu/bats | ||
BATS_TAG?=1.11.0 | ||
BATS_DIR=build/make/bats | ||
BATS_WORKDIR="${WORKDIR}"/"${BATS_DIR}" | ||
|
||
.PHONY unit-test-shell: | ||
unit-test-shell: unit-test-shell-$(ENVIRONMENT) | ||
|
||
$(BATS_ASSERT): | ||
@git clone --depth 1 https://github.com/bats-core/bats-assert $@ | ||
|
||
$(BATS_MOCK): | ||
@git clone --depth 1 https://github.com/grayhemp/bats-mock $@ | ||
|
||
$(BATS_SUPPORT): | ||
@git clone --depth 1 https://github.com/bats-core/bats-support $@ | ||
|
||
$(BATS_FILE): | ||
@git clone --depth 1 https://github.com/bats-core/bats-file $@ | ||
|
||
$(BASH_SRC): | ||
BASH_SRC:=$(shell find "${WORKDIR}" -type f -name "*.sh") | ||
|
||
${BASH_TEST_REPORT_DIR}: $(TARGET_DIR) | ||
@mkdir -p $(BASH_TEST_REPORT_DIR) | ||
|
||
unit-test-shell-ci: $(BASH_SRC) $(BASH_TEST_REPORT_DIR) $(BATS_ASSERT) $(BATS_MOCK) $(BATS_SUPPORT) $(BATS_FILE) | ||
@echo "Test shell units on CI server" | ||
@make unit-test-shell-generic | ||
|
||
unit-test-shell-local: $(BASH_SRC) $(PASSWD) $(ETCGROUP) $(HOME_DIR) buildTestImage $(BASH_TEST_REPORT_DIR) $(BATS_ASSERT) $(BATS_MOCK) $(BATS_SUPPORT) $(BATS_FILE) | ||
@echo "Test shell units locally (in Docker)" | ||
@docker run --rm \ | ||
-v $(HOME_DIR):/home/$(USER) \ | ||
-v $(WORKDIR):$(WORKSPACE) \ | ||
-w $(WORKSPACE) \ | ||
--entrypoint="" \ | ||
$(BATS_CUSTOM_IMAGE):$(BATS_TAG) \ | ||
"${BATS_DIR}"/customBatsEntrypoint.sh make unit-test-shell-generic-no-junit | ||
|
||
unit-test-shell-generic: | ||
@bats --formatter junit --output ${BASH_TEST_REPORT_DIR} ${TESTS_DIR} | ||
|
||
unit-test-shell-generic-no-junit: | ||
@bats ${TESTS_DIR} | ||
|
||
.PHONY buildTestImage: | ||
buildTestImage: | ||
@echo "Build shell test container" | ||
@cd $(BATS_WORKDIR) && docker build \ | ||
--build-arg=BATS_BASE_IMAGE=${BATS_BASE_IMAGE} \ | ||
--build-arg=BATS_TAG=${BATS_TAG} \ | ||
-t ${BATS_CUSTOM_IMAGE}:${BATS_TAG} \ | ||
. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ARG BATS_BASE_IMAGE | ||
ARG BATS_TAG | ||
|
||
FROM ${BATS_BASE_IMAGE:-bats/bats}:${BATS_TAG:-1.11.0} | ||
|
||
# Make bash more findable by scripts and tests | ||
RUN apk add make git bash | ||
# suppress git "detected dubious ownership" error/warning for repos which are checked out later | ||
RUN git config --global --add safe.directory /workspace |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
"$@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
##@ Bower dependency management | ||
|
||
BOWER_JSON=$(WORKDIR)/bower.json | ||
|
||
.PHONY: bower-install | ||
bower-install: $(BOWER_TARGET) ## Execute yarn run bower (in Docker) | ||
|
||
ifeq ($(ENVIRONMENT), ci) | ||
|
||
$(BOWER_TARGET): $(BOWER_JSON) $(YARN_TARGET) | ||
@echo "Yarn run bower on CI server" | ||
@yarn run bower | ||
|
||
else | ||
|
||
$(BOWER_TARGET): $(BOWER_JSON) $(PASSWD) $(YARN_TARGET) | ||
@echo "Executing bower..." | ||
@docker run --rm \ | ||
-e HOME=/tmp \ | ||
-u "$(UID_NR):$(GID_NR)" \ | ||
-v $(PASSWD):/etc/passwd:ro \ | ||
-v $(WORKDIR):$(WORKDIR) \ | ||
-w $(WORKDIR) \ | ||
node:$(NODE_VERSION) \ | ||
yarn run bower | ||
@touch $@ | ||
|
||
endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
##@ Compiling go software | ||
|
||
ADDITIONAL_LDFLAGS?=-extldflags -static | ||
LDFLAGS?=-ldflags "$(ADDITIONAL_LDFLAGS) -X main.Version=$(VERSION) -X main.CommitID=$(COMMIT_ID)" | ||
GOIMAGE?=golang | ||
GOTAG?=1.23 | ||
GOOS?=linux | ||
GOARCH?=amd64 | ||
PRE_COMPILE?= | ||
GO_ENV_VARS?= | ||
CUSTOM_GO_MOUNT?=-v /tmp:/tmp | ||
GO_BUILD_FLAGS?=-mod=vendor -a -tags netgo $(LDFLAGS) -installsuffix cgo -o $(BINARY) | ||
|
||
.PHONY: compile | ||
compile: $(BINARY) ## Compile the go program via Docker | ||
|
||
compile-ci: ## Compile the go program without Docker | ||
@echo "Compiling (CI)..." | ||
make compile-generic | ||
|
||
compile-generic: | ||
@echo "Compiling..." | ||
# here is go called without mod capabilities because of error "go: error loading module requirements" | ||
# see https://github.com/golang/go/issues/30868#issuecomment-474199640 | ||
@$(GO_ENV_VARS) go build $(GO_BUILD_FLAGS) | ||
|
||
|
||
ifeq ($(ENVIRONMENT), ci) | ||
|
||
$(BINARY): $(SRC) vendor $(PRE_COMPILE) | ||
@echo "Built on CI server" | ||
@make compile-generic | ||
|
||
else | ||
|
||
$(BINARY): $(SRC) vendor $(PASSWD) $(ETCGROUP) $(HOME_DIR) $(PRE_COMPILE) | ||
@echo "Building locally (in Docker)" | ||
@docker run --rm \ | ||
-e GOOS=$(GOOS) \ | ||
-e GOARCH=$(GOARCH) \ | ||
-u "$(UID_NR):$(GID_NR)" \ | ||
-v $(PASSWD):/etc/passwd:ro \ | ||
-v $(ETCGROUP):/etc/group:ro \ | ||
-v $(HOME_DIR):/home/$(USER) \ | ||
-v $(WORKDIR):/go/src/github.com/cloudogu/$(ARTIFACT_ID) \ | ||
$(CUSTOM_GO_MOUNT) \ | ||
-w /go/src/github.com/cloudogu/$(ARTIFACT_ID) \ | ||
$(GOIMAGE):$(GOTAG) \ | ||
make compile-generic | ||
|
||
endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
##@ Cleaning | ||
|
||
.PHONY: clean | ||
clean: $(ADDITIONAL_CLEAN) ## Remove target and tmp directories | ||
rm -rf ${TARGET_DIR} | ||
rm -rf ${TMP_DIR} | ||
rm -rf ${UTILITY_BIN_PATH} | ||
|
||
.PHONY: dist-clean | ||
dist-clean: clean ## Remove all generated directories | ||
rm -rf node_modules | ||
rm -rf public/vendor | ||
rm -rf vendor | ||
rm -rf npm-cache | ||
rm -rf bower |
Oops, something went wrong.