Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): Publish to docker.io and other Jenkinsfile fixes #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/integration-test-mezmo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ env:
VERBOSE: true
CI: true
PROFILE: debug
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
CARGO_NET_GIT_FETCH_WITH_CLI: true

jobs:
test-integration:
Expand Down Expand Up @@ -73,7 +71,6 @@ jobs:
# - test: 'sumo-logic'
steps:
- uses: actions/checkout@v3
- run: git config --global url."https://${GITHUB_TOKEN}@github.com".insteadOf ssh://git@github.com
- run: make test-integration-${{ matrix.test }}
env:
SPLUNK_VERSION: ${{ matrix.env.SPLUNK_VERSION }}
Expand Down
91 changes: 47 additions & 44 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,20 @@ library 'magic-butler-catalogue'
def WORKSPACE_PATH = "/tmp/workspace/${env.BUILD_TAG.replace('%2F', '/')}"
def DEFAULT_BRANCH = "master"
def PROJECT_NAME = "vector"
def CURRENT_BRANCH = [env.CHANGE_BRANCH, env.BRANCH_NAME]?.find{branch -> branch != null}

def slugify(str) {
def s = str.toLowerCase()
s = s.replaceAll(/[^a-z0-9\s-\/]/, "").replaceAll(/\s+/, " ").trim()
s = s.replaceAll(/[\/\s]/, '-').replaceAll(/-{2,}/, '-')
s
}
def CURRENT_BRANCH = currentBranch()
def DOCKER_REPO = "docker.io/mezmohq"

def CREDS = [
string(
credentialsId: 'github-api-token',
variable: 'GITHUB_TOKEN'
),
aws(credentialsId: 'aws',
aws(
credentialsId: 'aws',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'),
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
),
]

def NPMRC = [
configFile(fileId: 'npmrc', variable: 'NPM_CONFIG_USERCONFIG')
]
Expand Down Expand Up @@ -71,22 +66,23 @@ pipeline {
}
}
stages {
stage('Setup') {
steps {
sh 'make release-tool'
stage('Validate PR Source') {
when {
expression { env.CHANGE_FORK }
not {
triggeredBy 'issueCommentCause'
}
}
}
stage('Check'){
steps {
sh """
make check ENVIRONMENT=true
make check-fmt ENVIRONMENT=true
"""
error("A maintainer needs to approve this PR for CI by commenting")
}
}



stage('Lint and test release'){
tools {
nodejs 'NodeJS 16'
nodejs 'NodeJS 20'
}
environment {
GIT_BRANCH = "${CURRENT_BRANCH}"
Expand All @@ -97,14 +93,23 @@ pipeline {
steps {
script {
configFileProvider(NPMRC) {
sh 'npm ci'
sh 'npm ci --ignore-scripts'
sh 'npm run commitlint'
sh 'npm run release:dry'
}
}
sh './release-tool lint'
sh './release-tool test'
}
}

stage('Check'){
steps {
sh """
make check ENVIRONMENT=true
make check-fmt ENVIRONMENT=true
"""
}
}

stage('Lint and Test'){
parallel {
stage('Lint'){
Expand Down Expand Up @@ -142,12 +147,14 @@ pipeline {
, push: false
, tags: [slugify("${CURRENT_BRANCH}-${BUILD_NUMBER}")]
, dockerfile: "distribution/docker/mezmo/Dockerfile"
, docker_repo: DOCKER_REPO
)
}
}
}
}
}

stage('Feature build and publish') {
when {
expression {
Expand All @@ -156,19 +163,18 @@ pipeline {
}
steps {
script {
def tag = slugify("${CURRENT_BRANCH}-${BUILD_NUMBER}")
def feature_tag = slugify("${CURRENT_BRANCH}-${BUILD_NUMBER}")
buildx.build(
project: PROJECT_NAME
, push: true
, tags: [tag]
, tags: [feature_tag]
, dockerfile: "distribution/docker/mezmo/Dockerfile"
, docker_repo: DOCKER_REPO
)
}
sh './release-tool clean'
sh './release-tool build'
sh './release-tool publish'
}
}

stage('Release and publish') {
when {
branch DEFAULT_BRANCH
Expand All @@ -177,30 +183,27 @@ pipeline {
}
}
tools {
nodejs 'NodeJS 16'
nodejs 'NodeJS 20'
}
steps {
script {
def version_before = npm.semver().version
configFileProvider(NPMRC) {
sh 'npm ci'
sh 'npm run release'
}

def tag = sh (
script: "./release-tool debug-RELEASE_VERSION",
returnStdout: true
).split(' = ')[1].trim()

buildx.build(
project: PROJECT_NAME
, push: true
, tags: [tag]
, dockerfile: "distribution/docker/mezmo/Dockerfile"
)
def semver = npm.semver()
if (version_before != semver.version) {
buildx.build(
project: PROJECT_NAME
, push: true
, tags: [semver.version]
, dockerfile: "distribution/docker/mezmo/Dockerfile"
, docker_repo: DOCKER_REPO
)
}
}
sh './release-tool clean'
sh './release-tool build'
sh './release-tool publish'
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,11 @@ define ENVIRONMENT_EXEC
--init \
--interactive \
--env INSIDE_ENVIRONMENT=true \
--env GITHUB_TOKEN=$(GITHUB_TOKEN) \
--env CI=$(CI) \
$(if $(ENVIRONMENT_NETWORK),--network $(ENVIRONMENT_NETWORK),) \
--mount type=bind,source=${CURRENT_DIR},target=/git/vectordotdev/vector \
--mount type=bind,source=${CURRENT_DIR}/scripts/environment/entrypoint.sh,target=/entrypoint.sh \
$(if $(findstring docker,$(CONTAINER_TOOL)),--mount type=bind$(COMMA)source=/var/run/docker.sock$(COMMA)target=/var/run/docker.sock,) \
--mount type=volume,source=vector-target,target=/git/vectordotdev/vector/target \
--mount type=volume,source=vector-cargo-cache,target=/root/.cargo \
--mount type=volume,source=vector-rustup-cache,target=/root/.rustup \
$(foreach publish,$(ENVIRONMENT_PUBLISH),--publish $(publish)) \
$(ENVIRONMENT_UPSTREAM)
endef
Expand Down
2 changes: 0 additions & 2 deletions distribution/docker/mezmo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# use a source that has multi-arch support (amd64+arm64)
FROM rust:1-slim-bullseye as release-builder
ARG GITHUB_TOKEN

# deps for compiler
RUN DEPS='gcc g++ make cmake xz-utils locales python libexpat1-dev gettext libz-dev libssl-dev autoconf pkg-config bzip2 protobuf-compiler libsasl2-dev git libclang-dev' \
Expand All @@ -14,7 +13,6 @@ RUN DEPS='gcc g++ make cmake xz-utils locales python libexpat1-dev gettext libz-
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc

RUN git config --global url."https://${GITHUB_TOKEN}@github.com".insteadOf ssh://git@github.com

WORKDIR /build
COPY . .
Expand Down
Loading