Skip to content

Commit

Permalink
Merge pull request #439 from answerbook/darinspivey/LOG-19590
Browse files Browse the repository at this point in the history
fix(ci): Clean disk space after ci runs [ci skip]
  • Loading branch information
darinspivey committed Apr 3, 2024
2 parents 9163805 + 7963582 commit b658874
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
46 changes: 28 additions & 18 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def slugify(str) {
s
}

def BRANCH_BUILD = slugify("${CURRENT_BRANCH}-${BUILD_NUMBER}")

def CREDS = [
string(
credentialsId: 'github-api-token',
Expand Down Expand Up @@ -53,22 +55,7 @@ pipeline {
ENVIRONMENT_AUTOBUILD = 'false'
ENVIRONMENT_TTY = 'false'
CI = 'true'
}
post {
always {
script {
if (env.SANITY_BUILD == 'true') {
notifySlack(
currentBuild.currentResult,
[
channel: '#pipeline-bots',
tokenCredentialId: 'qa-slack-token'
],
"`${PROJECT_NAME}` sanity build took ${currentBuild.durationString.replaceFirst(' and counting', '')}."
)
}
}
}
VECTOR_TARGET = "${BRANCH_BUILD}"
}
stages {
stage('Setup') {
Expand All @@ -77,6 +64,8 @@ pipeline {
}
}
stage('Check'){
// Important: do this step serially since it'll be the one to prepare the testing container
// and install the rust toolchain in it. Volume mounts are created here, too.
steps {
sh """
make check ENVIRONMENT=true
Expand Down Expand Up @@ -105,7 +94,8 @@ pipeline {
sh './release-tool test'
}
}
stage('Lint and Test'){
stage('Lint and Test') {
// All `make ENVIRONMENT=true` steps should now use the existing container
parallel {
stage('Lint'){
steps {
Expand Down Expand Up @@ -140,7 +130,7 @@ pipeline {
buildx.build(
project: PROJECT_NAME
, push: false
, tags: [slugify("${CURRENT_BRANCH}-${BUILD_NUMBER}")]
, tags: [BRANCH_BUILD]
, dockerfile: "distribution/docker/mezmo/Dockerfile"
)
}
Expand Down Expand Up @@ -204,4 +194,24 @@ pipeline {
}
}
}
post {
always {
// Clear disk space by removing the `target` volume mount where the binaries are stored.
// The volume is unique to the current build, so there should be no "in use" errors.
sh 'make target-clean'

script {
if (env.SANITY_BUILD == 'true') {
notifySlack(
currentBuild.currentResult,
[
channel: '#pipeline-bots',
tokenCredentialId: 'qa-slack-token'
],
"`${PROJECT_NAME}` sanity build took ${currentBuild.durationString.replaceFirst(' and counting', '')}."
)
}
}
}
}
}
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export VERSION ?= $(shell command -v cargo >/dev/null && cargo vdev version || e
# Set if you are on the CI and actually want the things to happen. (Non-CI users should never set this.)
export CI ?= false

export VECTOR_TARGET ?= vector-target

export RUST_VERSION ?= $(shell grep channel rust-toolchain.toml | cut -d '"' -f 2)

FORMATTING_BEGIN_YELLOW = \033[0;33m
Expand Down Expand Up @@ -164,7 +166,7 @@ define ENVIRONMENT_EXEC
--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_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)) \
Expand Down Expand Up @@ -208,9 +210,14 @@ environment:
environment-prepare: ## Prepare the Vector dev shell using $CONTAINER_TOOL.
${ENVIRONMENT_PREPARE}

.PHONY: target-clean
target-clean: ## Clean just the target volume, and leave toolchain/cargo in tact
@echo "Removing vector target volume: ${VECTOR_TARGET}"
@$(CONTAINER_TOOL) volume rm -f ${VECTOR_TARGET}

.PHONY: environment-clean
environment-clean: ## Clean the Vector dev shell using $CONTAINER_TOOL.
@$(CONTAINER_TOOL) volume rm -f vector-target vector-cargo-cache vector-rustup-cache
@$(CONTAINER_TOOL) volume rm -f ${VECTOR_TARGET} vector-cargo-cache vector-rustup-cache
@$(CONTAINER_TOOL) rmi $(ENVIRONMENT_UPSTREAM) || true

.PHONY: environment-push
Expand Down

0 comments on commit b658874

Please sign in to comment.