Skip to content

Commit

Permalink
Mic-5211/cron-job (#227)
Browse files Browse the repository at this point in the history
Mic-5211/cron-job

Add cron job Jenkins pipeline
- *Category*: CI
- *JIRA issue*: https://jira.ihme.washington.edu/browse/MIC-5211

Changes and notes
-add cron job pipeline for Jenkins

### Testing
<!--
Details on how code was verified, any unit tests local for the
repo, regression testing, etc. At a minimum, this should include an
integration test for a framework change. Consider: plots, images,
(small) csv file.
-->
  • Loading branch information
albrja authored Aug 22, 2024
1 parent e417850 commit ca127b4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:
cat ../vivarium_build_utils/install_dependency_branch.sh
echo ""
echo "----------------------------------------"
sh ../vivarium_build_utils/install_dependency_branch.sh layered_config_tree ${branch_name}
sh ../vivarium_build_utils/install_dependency_branch.sh vivarium ${branch_name}
sh ../vivarium_build_utils/install_dependency_branch.sh layered_config_tree ${branch_name} github
sh ../vivarium_build_utils/install_dependency_branch.sh vivarium ${branch_name} github
- name: print environment values
run: |
cat $GITHUB_ENV
Expand Down
26 changes: 14 additions & 12 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pipeline {
)
string(
name: "SLACK_TO",
defaultValue: "simsci-ci-status-test",
defaultValue: "simsci-ci-status",
description: "The Slack channel to send messages to."
)
booleanParam(
Expand All @@ -52,9 +52,6 @@ pipeline {
script {
// Use the name of the branch in the build name
currentBuild.displayName = "#${BUILD_NUMBER} ${GIT_BRANCH}"

// Tell BitBucket that a build has started.
notifyBitbucket()
}
}
}
Expand Down Expand Up @@ -198,16 +195,21 @@ pipeline {
sh "rm -rf ${CONDA_ENV_PATH}"
// Delete the workspace directory.
deleteDir()
// Tell BitBucket whether the build succeeded or failed.
script {
notifyBitbucket()
}
}
failure {
slackSend channel: "#${params.SLACK_TO}",
message: ":x: JOB FAILURE: $JOB_NAME - $BUILD_ID\n\n${BUILD_URL}console\n\n<!channel>",
teamDomain: "ihme",
tokenCredentialId: "slack"
script {
if (env.BRANCH == "main") {
channelName = "simsci-ci-status"
} else {
channelName = "simsci-ci-status-test"
}
}
// TODO: DM the developer instead of the slack channel
echo "This build failed on ${GIT_BRANCH}. Sending a failure message to Slack."
slackSend channel: "#${channelName}",
message: ":x: JOB FAILURE: $JOB_NAME - $BUILD_ID\n\n${BUILD_URL}console\n\n<!channel>",
teamDomain: "ihme",
tokenCredentialId: "slack"
}
success {
script {
Expand Down
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHELL := /bin/bash
this_makefile := $(lastword $(MAKEFILE_LIST)) # Used to automatically list targets
.DEFAULT_GOAL := list # If someone runs "make", run "make list"

Expand Down Expand Up @@ -56,16 +57,21 @@ build-env: # Make a new conda environment
install: # Install setuptools, install this package in editable mode
pip install --upgrade pip setuptools
pip install -e .[DEV]
@echo "Checking if the vivarium repository has the branch $(GIT_BRANCH)..."
@$(eval BRANCH_EXISTS=$(shell curl -s https://api.github.com/repos/ihmeuw/vivarium/branches | grep -q '"name": "$(GIT_BRANCH)"' && echo "yes" || echo "no"))
@if [ "$(BRANCH_EXISTS)" = "yes" ]; then \
pip install git+https://github.com/ihmeuw/vivarium@${GIT_BRANCH}; \
fi
@echo "Checking if the vivarium_public_health repository has the branch $(GIT_BRANCH)..."
@$(eval BRANCH_EXISTS=$(shell curl -s https://api.github.com/repos/ihmeuw/vivarium_public_health/branches | grep -q '"name": "$(GIT_BRANCH)"' && echo "yes" || echo "no"))
@if [ "$(BRANCH_EXISTS)" = "yes" ]; then \
pip install git+https://github.com/ihmeuw/vivarium_public_health@${GIT_BRANCH}; \
@cd ..
@echo "----------------------------------------"
@if [ ! -d "vivarium_build_utils" ]; then \
# Clone the build utils repo if it doesn't exist. \
git clone https://github.com/ihmeuw/vivarium_build_utils.git; \
else \
echo "vivarium_build_utils already exists. Skipping clone."; \
fi
@echo "Contents of install_dependency_branch.sh"
@echo "----------------------------------------"
@cat vivarium_build_utils/install_dependency_branch.sh
@echo ""
@echo "----------------------------------------"
@sh vivarium_build_utils/install_dependency_branch.sh vivarium ${GIT_BRANCH} jenkins
@sh vivarium_build_utils/install_dependency_branch.sh layered_config_tree ${GIT_BRANCH} jenkins

format: setup.py pyproject.toml $(MAKE_SOURCES) # Run the code formatter and import sorter
black $(LOCATIONS)
Expand Down

0 comments on commit ca127b4

Please sign in to comment.