Skip to content

Commit d08f447

Browse files
Merge conflicts
2 parents 261a1a2 + 9156d2c commit d08f447

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+7563
-3306
lines changed

.coverage

-80 KB
Binary file not shown.

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ VariantValidator/testing/outputs*
1212

1313
# backedup files after 2to3 conversion
1414
*.bak
15-
1615
.eggs
1716
Users
1817
*.sql
1918
*.pyc
2019
temp.py
20+
21+
#ignore databases
22+
seqrepo/*
23+
.eggs/*
24+
tests/*/*.pyc
25+
/VariantValidator.egg-info/*
26+
validator_2021-07-21.sql
27+
VVTA_2021_2_noseq.psql.gz
28+

.travis.yml

Lines changed: 0 additions & 95 deletions
This file was deleted.

Dockerfile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
FROM python:3.6
1+
# Declare the base image
2+
FROM python:3.11
23

4+
# Create the WorkDir
35
WORKDIR /app
46

7+
# Copy the current directory contents into the container's /app directory
58
COPY . /app
69

10+
# Create logging directory
11+
RUN mkdir /usr/local/share/logs
12+
713
# Update apt-get
8-
RUN apt-get update
14+
RUN apt update
915

10-
# Install git
11-
RUN apt-get -y install git
16+
# Install apt managed sofware
17+
RUN apt -y install git \
18+
postgresql-client \
19+
sqlite3
1220

13-
# Updrade pip
21+
# Upgrade pip
1422
RUN pip install --upgrade pip
1523

16-
RUN pip install -r requirements_dev.txt
17-
24+
# Install the app
1825
RUN pip install -e .
1926

27+
# Copy the config file into the container home directory
2028
COPY configuration/docker.ini /root/.variantvalidator
2129

22-
CMD python3 bin/variant_validator.py
30+
# Set entrypoint
31+
ENTRYPOINT []
32+
33+
# Set command
34+
CMD ["tail", "-f", "/dev/null"]

Jenkinsfile

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
pipeline {
2+
agent {
3+
docker {
4+
image "docker:24.0.6-git" // Set the Docker image for the Jenkins agent
5+
}
6+
}
7+
environment {
8+
CODECOV_TOKEN = credentials('CODECOV_TOKEN') // Use the Codecov token from Jenkins secret
9+
CONTAINER_SUFFIX = "${BUILD_NUMBER}" // Use the build number as a container suffix for uniqueness
10+
DOCKER_NETWORK = "variantvalidator_docker_network-$CONTAINER_SUFFIX" // Create a unique Docker network for this build
11+
DATA_VOLUME = "docker-shared-space" // Define a data volume for shared data
12+
}
13+
stages {
14+
stage("Clone Repository Remove dangling docker components and Create Docker Network") {
15+
steps {
16+
checkout scm // Checkout the source code from the configured source code management system
17+
sh 'docker system prune --all --volumes --force' // Remove unused Docker resources
18+
sh 'docker network create $DOCKER_NETWORK' // Create a Docker network for containers
19+
}
20+
}
21+
stage("Switch to Git Branch") {
22+
steps {
23+
sh "git checkout ${BRANCH_NAME}"
24+
sh "git pull"
25+
}
26+
}
27+
stage("Build and Run VVTA PostgreSQL") {
28+
steps {
29+
script {
30+
def dockerfile = './db_dockerfiles/vvta/Dockerfile' // Define the Dockerfile path
31+
def vvtaContainer = docker.build("postgres-vvta-${CONTAINER_SUFFIX}", "--no-cache -f ${dockerfile} ./db_dockerfiles/vvta")
32+
// Build and run a PostgreSQL container for VVTA
33+
vvtaContainer.run("-p 5432:5432 -d --name vv-vvta --network $DOCKER_NETWORK --shm-size=2g")
34+
sh 'echo Building and running VVTA PostgreSQL' // Display a message
35+
}
36+
}
37+
}
38+
stage("Build and Run Validator MySQL") {
39+
steps {
40+
script {
41+
def dockerfile = './db_dockerfiles/vdb/Dockerfile' // Define the Dockerfile path
42+
def validatorContainer = docker.build("mysql-validator-${CONTAINER_SUFFIX}", "--no-cache -f ${dockerfile} ./db_dockerfiles/vdb")
43+
// Build and run a MySQL container for the Validator
44+
validatorContainer.run("-p 3306:3306 -d --name vv-vdb --network $DOCKER_NETWORK")
45+
sh 'echo Building and running Validator MySQL' // Display a message
46+
}
47+
}
48+
}
49+
stage("Build and Run SeqRepo") {
50+
steps {
51+
script {
52+
def dockerfile = './db_dockerfiles/vvsr/Dockerfile' // Define the Dockerfile path
53+
def seqRepoContainer = docker.build("sqlite-seqrepo-${CONTAINER_SUFFIX}", "--no-cache -f ${dockerfile} ./db_dockerfiles/vvsr")
54+
// Build and run a SQLite SeqRepo container
55+
seqRepoContainer.run("--network $DOCKER_NETWORK --name vv-seqrepo -v $DATA_VOLUME:/usr/local/share:rw")
56+
sh 'echo Building and running SeqRepo' // Display a message
57+
}
58+
}
59+
}
60+
stage("Build and Run VariantValidator") {
61+
steps {
62+
script {
63+
def dockerfile = './Dockerfile' // Define the Dockerfile path
64+
def variantValidatorContainer = docker.build("variantvalidator-${CONTAINER_SUFFIX}", "--no-cache -f ${dockerfile} .")
65+
66+
// Run variantValidatorContainer and Mount the DATA_VOLUME
67+
variantValidatorContainer.run("-v $DATA_VOLUME:/usr/local/share:rw -d --name variantvalidator --network $DOCKER_NETWORK")
68+
69+
// Display a message indicating that VariantValidator is being built and run
70+
sh 'echo Building and running VariantValidator'
71+
}
72+
}
73+
}
74+
stage("Run Pytest and Codecov") {
75+
steps {
76+
script {
77+
sh 'docker ps' // List running Docker containers
78+
def connectionSuccessful = false
79+
80+
for (int attempt = 1; attempt <= 5; attempt++) {
81+
echo "Attempt $attempt to connect to the database..."
82+
def exitCode = sh(script: '''
83+
docker exec -e PGPASSWORD=uta_admin variantvalidator psql -U uta_admin -d vvta -h vv-vvta -p 5432
84+
''', returnStatus: true)
85+
86+
if (exitCode == 0) {
87+
connectionSuccessful = true
88+
echo "Connected successfully! Running pytest..."
89+
90+
// Run pytest && Run Codecov with the provided token and branch name
91+
sh 'docker exec variantvalidator pytest -n 3 --cov=VariantValidator --cov=VariantFormatter --cov-report=term tests/'
92+
93+
// Send coverage report to Codecov
94+
sh 'docker exec variantvalidator codecov -t $CODECOV_TOKEN -b ${BRANCH_NAME}'
95+
96+
// Check for test failures in the captured output
97+
if (currentBuild.rawBuild.getLog(2000).join('\n').contains("test summary info") && currentBuild.rawBuild.getLog(2000).join('\n').contains("FAILED")) {
98+
failure(message:"Pytest completed with test failures")
99+
}
100+
101+
// Check the Jenkins console log for pytest exit code
102+
def pytestExitCode = currentBuild.rawBuild.getLog(2000).find { line -> line =~ /.*Pytest exit code: (\d+).*/ }
103+
if (pytestExitCode) {
104+
pytestExitCode = Integer.parseInt(pytestExitCode.replaceAll(/.*Pytest exit code: (\d+).*/, '$1'))
105+
if (pytestExitCode != 0) {
106+
failure(message:"Pytest failed with exit code $pytestExitCode")
107+
}
108+
}
109+
break
110+
}
111+
112+
echo "Connection failed. Waiting for 60 seconds before the next attempt..."
113+
sleep 60
114+
}
115+
116+
if (!connectionSuccessful) {
117+
failure(message:"All connection attempts failed. Exiting...")
118+
}
119+
}
120+
}
121+
}
122+
}
123+
post {
124+
always { // This ensures cleanup is executed regardless of build outcome
125+
script {
126+
// Cleanup Docker
127+
sh 'docker stop vv-vvta'
128+
sh 'docker rm vv-vvta'
129+
sh 'docker stop vv-vdb'
130+
sh 'docker rm vv-vdb'
131+
sh 'docker stop vv-seqrepo'
132+
sh 'docker rm vv-seqrepo'
133+
sh 'docker stop variantvalidator'
134+
sh 'docker rm variantvalidator'
135+
sh 'docker network rm $DOCKER_NETWORK'
136+
sh 'docker system prune --all --volumes --force'
137+
}
138+
}
139+
}
140+
}

0 commit comments

Comments
 (0)