Skip to content

Commit

Permalink
fix(ci): Fix Jenkinsfile suitable for the public
Browse files Browse the repository at this point in the history
This repository is now public which forces CI changes to the Jenkinsfile
stages.

Ref: LOG-19546
  • Loading branch information
darinspivey committed Mar 25, 2024
1 parent 44c3af5 commit b3f6685
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 124 deletions.
136 changes: 54 additions & 82 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
library 'magic-butler-catalogue'

def DEFAULT_BRANCH = 'main'
def CURRENT_BRANCH = [env.CHANGE_BRANCH, env.BRANCH_NAME]?.find{branch -> branch != null}
def CURRENT_BRANCH = currentBranch()
def WORKSPACE_PATH = "/tmp/workspace/${env.BUILD_TAG.replace('%2F', '/')}"

def CREDS = [
string(
credentialsId: 'github-api-token',
variable: 'GITHUB_TOKEN'
),
]
def NPMRC = [
configFile(fileId: 'npmrc', variable: 'NPM_CONFIG_USERCONFIG')
]

pipeline {
agent {
node {
label 'ec2-fleet'
customWorkspace("/tmp/workspace/${env.BUILD_TAG}")
label 'rust-x86_64'
customWorkspace(WORKSPACE_PATH)
}
}

options {
timeout time: 1, unit: 'HOURS'
timestamps()
ansiColor 'xterm'
withCredentials(CREDS)
}
environment {
GITHUB_USER = 'jenkins'
GITHUB_TOKEN = credentials('github-api-token')
NPM_CONFIG_CACHE = '.npm'
SPAWN_WRAP_SHIM_ROOT = '.npm'
RUSTUP_HOME = '/opt/rust/rustup'
CARGO_HOME = '/opt/rust/cargo'
CARGO_REGISTRIES_CRATES_IO_PROTOCOL = 'sparse'
PATH = """${sh(
returnStdout: true,
script: 'echo /opt/rust/cargo/bin:\$PATH'
)}
"""
// for the semantic-release-rust executable, we must have this set even when not publishing the crate directly
CARGO_REGISTRY_TOKEN = "not-in-use"
LAST_COMMITTER = sh(script: 'git log -1 --format=%ae', returnStdout: true).trim()
}

tools {
nodejs 'NodeJS 14'
// """
}

post {
Expand All @@ -47,92 +47,64 @@ pipeline {
}

stages {
stage('Lint and Test') {
parallel {
stage('Lint') {
agent {
docker {
label 'ec2-fleet'
customWorkspace "/tmp/workspace/${BUILD_TAG}"
image 'us.gcr.io/logdna-k8s/rust:bullseye-1-stable-x86_64'
reuseNode true
}
}
steps {
sh 'make lint'
}
}
stage('Unit Tests') {
agent {
docker {
label 'ec2-fleet'
customWorkspace "/tmp/workspace/${BUILD_TAG}"
image 'us.gcr.io/logdna-k8s/rust:bullseye-1-stable-x86_64'
reuseNode true
}
}
steps {
sh 'make test'
}
stage('Validate PR Source') {
when {
expression { env.CHANGE_FORK }
not {
triggeredBy 'issueCommentCause'
}
}
steps {
error("A maintainer needs to approve this PR for CI by commenting")
}
}

stage('Release Lint and Test') {
stages {
stage('Validate') {
steps {
script {
sh "mkdir -p ${NPM_CONFIG_CACHE}"
configFileProvider(NPMRC) {
sh 'npm i && npm run lint'
}
}
stage('Commitlint and dry release test'){
tools {
nodejs 'NodeJS 20'
}
environment {
GIT_BRANCH = "${CURRENT_BRANCH}"
// This is not populated on PR builds and is needed for the release dry runs
BRANCH_NAME = "${CURRENT_BRANCH}"
CHANGE_ID = ""
}
steps {
script {
configFileProvider(NPMRC) {
sh 'npm install --ignore-scripts'
sh 'npm run commitlint'
sh 'npm run release:dry'
}
}
}
}

stage('Release Test') {
when {
not {
branch 'main'
}
}
environment {
GIT_BRANCH = "${CURRENT_BRANCH}"
BRANCH_NAME = "${CURRENT_BRANCH}"
RUSTUP_HOME = '/opt/rust/cargo'
CHANGE_ID = ""
}
steps {
script {
sh "mkdir -p ${NPM_CONFIG_CACHE}"
sh "unset CARGO_REGISTRIES_CRATES_IO_PROTOCOL; cargo install cargo-edit"
configFileProvider(NPMRC) {
sh 'npm i && npm run release:dry'
}
}
}
}
stage('Unit Tests') {
steps {
sh "make clean"
sh 'make test'
}
}
stage('Clippy') {
steps {
// `cargo-audit` is installed on `make test` stage
sh 'make lint'
}
}

stage('Release') {
when {
beforeAgent true
branch DEFAULT_BRANCH
not {
changelog '\\[skip ci\\]'
}
}
environment {
RUSTUP_HOME = '/opt/rust/cargo'
tools {
nodejs 'NodeJS 20'
}
steps {
script {
sh "mkdir -p ${NPM_CONFIG_CACHE}"
sh "unset CARGO_REGISTRIES_CRATES_IO_PROTOCOL; cargo install cargo-edit"
configFileProvider(NPMRC) {
sh 'npm i && npm run release'
sh 'npm install'
sh 'npm run release'
}
}
}
Expand Down
47 changes: 36 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
{
"name": "@answerbook/opentelemetry-rs",
"name": "@mezmo/opentelemetry-rs",
"description": "A library providing quick-protobuf bindings and RFC compliant validation for OpenTelemetry metrics and logs types",
"version": "0.0.0",
"private": true,
"license": "Mozilla Public License 2.0",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/mezmo/opentelemetry-rs.git"
},
"version": "1.2.1",
"files": [
"release.config.js",
"README.md"
],
"scripts": {
"lint": "commitlint-logdna",
"commitlint": "./node_modules/.bin/commitlint-logdna",
"release": "semantic-release",
"release:dry": "semantic-release --no-ci --dry-run --branches=${BRANCH_NAME:-main}"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/answerbook/opentelemetry-rs.git"
"release": {
"branches": [
"main"
],
"extends": [
"@answerbook/release-config-logdna"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog", {
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/github", {
"assets": "CHANGELOG.md"
}
],
[
"@semantic-release/git", {
"assets": "CHANGELOG.md"
}
]
]
},
"license": "SEE LICENSE IN LICENSE",
"devDependencies": {
"@answerbook/commitlint-config-logdna": "^2.1.0",
"@answerbook/release-config-logdna": "^1.3.0",
"semantic-release": "^18.0.1"
"@answerbook/release-config-logdna": "^2.0.1",
"semantic-release": "^19.0.5"
}
}
31 changes: 0 additions & 31 deletions release.config.js

This file was deleted.

0 comments on commit b3f6685

Please sign in to comment.