Skip to content

Commit

Permalink
ci: update CI to use shared jenkins pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed Jan 20, 2021
1 parent 73253fb commit 624fa27
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 79 deletions.
79 changes: 13 additions & 66 deletions .jenkins
@@ -1,68 +1,15 @@
#!/usr/bin/env groovy

pipeline {

agent {
label 'golang-alpha'
}

stages {
stage('Checkout') {
steps {
checkout scm
}
}

stage('Test') {
environment {
CODECOV_TOKEN = credentials('codecov-token')
}
steps {
container('golang'){
sh 'CGO_ENABLED=0 go test -coverprofile=coverage.txt -covermode=atomic ./sdk/...'
sh 'curl -s https://codecov.io/bash | bash -s - -t ${CODECOV_TOKEN}'
sh 'rm coverage.txt'
}
}
}

stage('Lint') {
steps {
container('golang'){
sh 'golint -set_exit_status ./sdk/... ./examples/...'
}
}
}

stage('Build') {
steps {
container('golang'){
// Build the SDK project
sh 'go build -v ./sdk'

// Build the SDK example plugins
sh 'for d in examples/*/; do cd $d; if [ "$d" != "examples/c_plugin/" ]; then go build -v -o plugin; fi ; cd ../.. ; done'

// Check that the example plugins dry-run successfully
sh 'for d in examples/*/; do if [ "$d" != "examples/c_plugin/" ]; then cd $d; if [ ! -f "plugin" ]; then echo "plugin binary not found"; fi; if ! ./plugin --dry-run; then exit 1; fi; cd ../.. ; fi ; done'
}
}
}

stage('Tagged Release') {
when {
buildingTag()
}
environment {
GITHUB_TOKEN = credentials('vio-bot-gh-token')
}
steps {
container('golang') {
withDockerRegistry(registry: [credentialsId: 'vio-docker-hub']) {
sh 'goreleaser release --rm-dist'
}
}
}
}
}
}
// Include this shared CI repository to load script helpers and libraries.
library identifier: 'vapor@1.0.3', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/vapor-ware/ci-shared.git',
credentialsId: 'vio-bot-gh',
])


golangPipeline([
'image': 'vaporio/emulator-plugin',
'skipSetup': true,
'publishLatest': false,
])
24 changes: 11 additions & 13 deletions Makefile
Expand Up @@ -16,22 +16,11 @@ cover: test ## Run tests and open the coverage report

.PHONY: check-examples
check-examples: ## Check that the example plugins run without failing
@for d in examples/*/ ; do \
echo "\n\033[32m$$d\033[0m" ; \
cd $$d ; \
if [ ! -f "plugin" ]; then echo "\033[31mplugin binary not found\033[0m"; fi; \
if ! ./plugin --dry-run; then exit 1; fi; \
cd ../.. ; \
done
@./scripts/run_examples.sh

.PHONY: examples
examples: ## Build the example plugins
@for d in examples/*/ ; do \
echo "\n\033[32m$$d\033[0m" ; \
cd $$d ; \
go build -v -o plugin ; \
cd ../.. ; \
done
@./scripts/build_examples.sh

.PHONY: fmt
fmt: ## Run goimports on all go files
Expand Down Expand Up @@ -65,3 +54,12 @@ help: ## Print usage information
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

.DEFAULT_GOAL := help


# Targets for Jenkins CI

.PHONY: unit-test integration-test

unit-test: test

integration-test: examples check-examples
17 changes: 17 additions & 0 deletions scripts/build_examples.sh
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

#
# Build the examples included in the repository.
#
# This script is used by CI as a means to easily test that all the example
# plugins can be successfully built.
#
# This should be run from the project root directory.
#

for d in examples/*/ ; do \
echo "\n\033[32m$d\033[0m" ; \
cd $d ; \
go build -v -o plugin ; \
cd ../.. ; \
done
18 changes: 18 additions & 0 deletions scripts/run_examples.sh
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

#
# Run the example plugins included in the repository.
#
# This script is used by CI as a means to easily test that all the example
# plugins (dry)run as expected. This requires the plugins to be built first.
#
# This should be run from the project root directory.
#

for d in examples/*/ ; do \
echo "\n\033[32m$d\033[0m" ; \
cd $d ; \
if [ ! -f "plugin" ]; then echo "\033[31mplugin binary not found\033[0m"; fi; \
if ! ./plugin --dry-run; then exit 1; fi; \
cd ../.. ; \
done

0 comments on commit 624fa27

Please sign in to comment.