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 use public repos #7

Merged
merged 1 commit into from
Apr 3, 2024
Merged
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
101 changes: 55 additions & 46 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 Author') {
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,15 +93,27 @@ 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('Lint and Test'){

stage('vdev Check'){
when {
changeRequest() // Only do this during PRs. It's about a 15-min wait.
}
steps {
sh """
make check ENVIRONMENT=true
make check-fmt ENVIRONMENT=true
"""
}
}

stage('Code'){
parallel {
stage('Lint'){
steps {
Expand All @@ -115,7 +123,10 @@ pipeline {
"""
}
}
stage('Deny'){
stage('Check Deny'){
when {
changeRequest() // PRs only to speed up dev flows. These can be fixed then if they're actionable.
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh """
Expand All @@ -142,12 +153,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 +169,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 +189,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
)
}
Comment on lines +202 to +211
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this step appears to be missing the bits to publish the MTP (what ./release-tool publish was doing). is that something we're going to add back? or maybe I'm just missing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that might have been missed. Checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is actually 2 things:

  1. use buildx and docker.io for images
  2. Changes to support primary development off of this repo (ie use the resulting image in our SaaS)

I think we can go ahead and merge this to accomplish the first thing. It will fix a few nasty errors as it relates to keeping this repo in sync with the private one. At a later time, there still has to be work to cut over the k8s manifest to using the new image, so at that time, we can add these missing MTP publishing bits. Just don't wanna be blocked here now because of that. Adding those steps might require tooling changes since everything has used release-tool in the recent past. If that's the case, then we won't switch to this repo as our primary any time soon, but at least it'll be easy to merge with our private 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
Loading