-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathconfig.yml
More file actions
162 lines (159 loc) · 5.88 KB
/
Copy pathconfig.yml
File metadata and controls
162 lines (159 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
version: 2.1
commands:
check-for-built-images:
steps:
- run:
name: "Checking for locally built images"
command: |
if [[ ! -f cpac-docker-image.tar.gz || ! -f cpac-singularity-image.simg ]]
then
circleci step halt
fi
set-python-version:
steps:
- run:
name: "Setting Python Version"
command: |
pyenv install 3.6.3
pyenv global 3.6.3
install-singularity-requirements:
steps:
- run:
name: "Installing Singularity requirements"
command: |
sudo apt-get update && sudo apt-get install flawfinder squashfs-tools uuid-dev libuuid1 libffi-dev libssl-dev libssl1.0.0 libarchive-dev libgpgme11-dev libseccomp-dev -y
set-up-singularity:
steps:
- run:
name: "Setting up Singularity"
command: |
cd singularity
./autogen.sh
./configure --prefix=/usr/local --sysconfdir=/etc
make
sudo make install
cd ..
build-images:
steps:
- run:
name: "Building Docker image"
command: |
docker build -t fcpindi/c-pac:${CIRCLE_BRANCH//\//_} .
docker save fcpindi/c-pac:${CIRCLE_BRANCH//\//_} | gzip > cpac-docker-image.tar.gz
no_output_timeout: 5h
# Persist the specified paths (workspace/echo-output) into the workspace for use in downstream job.
- run:
name: "Starting local registry"
command: docker run -d -p 5000:5000 --restart=always --name registry registry:2
- install-singularity-requirements
- run:
name: "Cloning Singularity 2.5.2"
command: git clone -b 2.5.2 https://github.com/sylabs/singularity
- set-up-singularity
- run:
name: "Building Singularity image from Docker image"
command: |
docker load < cpac-docker-image.tar.gz
docker tag fcpindi/c-pac:${CIRCLE_BRANCH//\//_} localhost:5000/fcpindi/c-pac:${CIRCLE_BRANCH//\//_}
docker push localhost:5000/fcpindi/c-pac:${CIRCLE_BRANCH//\//_}
SINGULARITY_NOHTTPS=1 singularity build C-PAC-CI.simg docker://localhost:5000/fcpindi/c-pac:${CIRCLE_BRANCH//\//_}
no_output_timeout: 5h
- store_artifacts:
path: cpac-docker-image.tar.gz
- store_artifacts:
path: C-PAC-CI.simg
destination: cpac-singularity-image.simg
- persist_to_workspace:
# Must be an absolute path, or relative path from working_directory. This is a directory on the container which is
# taken to be the root directory of the workspace.
root: /home/circleci/
# Must be relative path from root
paths: project
configure-git-user:
steps:
- add_ssh_keys:
fingerprints:
- "12:bc:f2:e4:31:cc:72:54:54:bc:f5:5b:89:e6:d8:ee"
- run:
name: "Configuring git user"
command: |
git config --global user.email "${CIRCLE_USERNAME}@users.noreply.github.com"
git config --global user.name "${CIRCLE_USERNAME} @ CircleCI"
jobs:
pytest-docker:
machine: true
steps:
- attach_workspace:
# Must be absolute path or relative path from working_directory
at: /home/circleci/
- check-for-built-images
- set-python-version
- run:
name: Getting Sample BIDS Data
command: git clone https://github.com/bids-standard/bids-examples.git
- run:
name: Running pytest on Docker image
command: |
docker load < cpac-docker-image.tar.gz
docker run -dit -P -v /home/circleci/project/test-results:/code/test-results -v /home/circleci/project/htmlcov:/code/htmlcov --entrypoint=/bin/bash --name docker_test fcpindi/c-pac:${CIRCLE_BRANCH//\//_}
docker exec docker_test /bin/bash ./code/dev/circleci_data/test_in_image.sh
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
- store_artifacts:
path: htmlcov
no_output_timeout: 5h
pytest-singularity:
machine: true
steps:
- attach_workspace:
# Must be absolute path or relative path from working_directory
at: /home/circleci/
- check-for-built-images
- set-python-version
- install-singularity-requirements
- set-up-singularity
- run:
name: Testing Singularity installation
command: |
pip install -r dev/circleci_data/requirements.txt
coverage run -m pytest --junitxml=test-results/junit.xml --continue-on-collection-errors dev/circleci_data/test_install.py
build:
machine: true
steps:
- checkout
- set-python-version
- configure-git-user
- run:
name: "Checking if version needs updated"
# update version if version needs updated, otherwise just move on
command: |
if [[ ! $(git log -1 --pretty=%B) == *"Update version to"* ]]
then
cd $HOME/project/CPAC
VERSION=$(python -c "from info import __version__; print(__version__)")
cd ..
echo "v${VERSION}" > version
find ./CPAC/resources/configs -name "*.yml" -exec sed -i -r "s/^(# [Vv]ersion ).*$/# Version ${VERSION}/g" {} \;
git add version CPAC/resources/configs
if [[ ! -z $(git diff origin/${CIRCLE_BRANCH}) ]]
then
git commit -m ":bookmark: Update version to ${VERSION}"
git push origin HEAD:${CIRCLE_BRANCH} || true
circleci step halt
fi
cd ..
fi
- build-images
workflows:
version: 2
build-and-test:
jobs:
- build
- pytest-docker:
requires:
- build
- pytest-singularity:
requires:
- build