-
Notifications
You must be signed in to change notification settings - Fork 0
224 lines (211 loc) · 11.1 KB
/
build.yml
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: "polyphonia CI"
on:
push:
pull_request:
branches:
- master
release:
types:
- created
schedule:
- cron: '0 18 * * 1' # weekly at 18:00 on Mondays
env:
HOME: "${{ github.workspace }}"
CACHE_DIR: "${{ github.workspace }}/misc_cache"
MINICONDA_DIR: "${{ github.workspace }}/miniconda"
PYTHONIOENCODING: UTF8
GITHUB_ACTIONS_COMMIT: ${{ github.sha }}
GITHUB_ACTIONS_BUILD_DIR: ${{ github.workspace }}
GITHUB_ACTIONS_BRANCH: ${{ github.ref }}
GITHUB_ACTIONS_PULL_REQUEST: ${{ github.event.number }}
GITHUB_ACTIONS_PULL_REQUEST_BRANCH: ${{ github.head_ref }}
GITHUB_ACTIONS_PULL_REQUEST_SHA : ${{ github.event.pull_request.head.sha }}
GITHUB_ACTIONS_BASE_REF: ${{ github.base_ref }}
DOCKER_REGISTRY: "quay.io"
DOCKER_REPO_PROD: "quay.io/broadinstitute/polyphonia"
DOCKER_REPO_DEV: "quay.io/broadinstitute/polyphonia"
DOCKER_POLYPHONIA_PATH: "/opt/polyphonia"
jobs:
test_build_docker:
runs-on: ubuntu-20.04
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: fetch tags
run: git fetch --prune --unshallow --tags
- name: Programmatic environment setup
run: |
set -e -x
# $GITHUB_ENV is available for subsequent steps
GITHUB_ACTIONS_TAG=$(git describe --tags --exact-match && sed 's/^v//g' || echo '')
echo "GITHUB_ACTIONS_TAG=$GITHUB_ACTIONS_TAG" >> $GITHUB_ENV
#
# Set GITHUB_ACTIONS_BRANCH
# TRAVIS_BRANCH: (via https://docs.travis-ci.com/user/environment-variables/ )
# for push builds, or builds not triggered by a pull request, this is the name of the branch.
# for builds triggered by a pull request this is the name of the branch targeted by the pull request.
# for builds triggered by a tag, this is the same as the name of the tag (TRAVIS_TAG).
GITHUB_ACTIONS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ -n "$GITHUB_ACTIONS_PULL_REQUEST_BRANCH" ]; then
GITHUB_ACTIONS_BRANCH=${GITHUB_ACTIONS_BASE_REF##*/}
elif [[ "${{ github.event_name }}" == "release" ]]; then
GITHUB_ACTIONS_BRANCH=$GITHUB_ACTIONS_TAG
fi
echo "GITHUB_ACTIONS_BRANCH=$GITHUB_ACTIONS_BRANCH" >> $GITHUB_ENV
echo "GITHUB_ACTIONS_SHORT_SHA=$(echo $GITHUB_SHA | head -c8)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and export
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: "polyphonia:${{ env.GITHUB_ACTIONS_BRANCH }}-${{ env.GITHUB_ACTIONS_SHORT_SHA }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Store build in cache (overwrite)
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
test_execution:
runs-on: ubuntu-20.04
needs: test_build_docker
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: fetch tags
run: git fetch --prune --unshallow --tags
- name: Programmatic environment setup
run: |
set -e -x
# $GITHUB_ENV is available for subsequent steps
GITHUB_ACTIONS_TAG=$(git describe --tags --exact-match && sed 's/^v//g' || echo '')
echo "GITHUB_ACTIONS_TAG=$GITHUB_ACTIONS_TAG" >> $GITHUB_ENV
#
# Set GITHUB_ACTIONS_BRANCH
# TRAVIS_BRANCH: (via https://docs.travis-ci.com/user/environment-variables/ )
# for push builds, or builds not triggered by a pull request, this is the name of the branch.
# for builds triggered by a pull request this is the name of the branch targeted by the pull request.
# for builds triggered by a tag, this is the same as the name of the tag (TRAVIS_TAG).
GITHUB_ACTIONS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ -n "$GITHUB_ACTIONS_PULL_REQUEST_BRANCH" ]; then
GITHUB_ACTIONS_BRANCH=${GITHUB_ACTIONS_BASE_REF##*/}
elif [[ "${{ github.event_name }}" == "release" ]]; then
GITHUB_ACTIONS_BRANCH=$GITHUB_ACTIONS_TAG
fi
echo "GITHUB_ACTIONS_BRANCH=$GITHUB_ACTIONS_BRANCH" >> $GITHUB_ENV
echo "GITHUB_ACTIONS_SHORT_SHA=$(echo $GITHUB_SHA | head -c8)" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# re-build image (from cache; this seems faster than exporting the image and passing as an Actions artifact)
- name: Build and export
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: false
load: true
tags: "polyphonia:${{ env.GITHUB_ACTIONS_BRANCH }}-${{ env.GITHUB_ACTIONS_SHORT_SHA }}"
cache-from: type=local,src=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Create local dir for test output
run: |
mkdir -p output
- name: Run polyphonia (basic execution test)
run: |
docker run -v $(pwd)/bin:${{ env.DOCKER_POLYPHONIA_PATH }} -v $(pwd)/test:${{ env.DOCKER_POLYPHONIA_PATH }}/test -v $(pwd)/output:/tmp/output --rm polyphonia:${{ env.GITHUB_ACTIONS_BRANCH }}-${{ env.GITHUB_ACTIONS_SHORT_SHA }} \
polyphonia cross_contamination
- name: Run polyphonia (cross_contamination test)
run: |
set -e -x
docker run -v $(pwd)/bin:${{ env.DOCKER_POLYPHONIA_PATH }} -v $(pwd)/test:${{ env.DOCKER_POLYPHONIA_PATH }}/test -v $(pwd)/output:/tmp/output --rm polyphonia:${{ env.GITHUB_ACTIONS_BRANCH }}-${{ env.GITHUB_ACTIONS_SHORT_SHA }} \
polyphonia cross_contamination \
--ref ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/NC_045512.2.fasta \
--vcf ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01315-2021.bam_LoFreq.vcf \
--vcf ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01323-2021.bam_LoFreq.vcf \
--consensus ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01315-2021.fasta \
--consensus ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01323-2021.fasta \
--plate-map ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01315_23-2021_plate_map.txt \
--min-depth 0 \
--output /tmp/output/potential_cross-contamination.txt \
--overwrite TRUE
DIFF=$(diff $(pwd)/output/potential_cross-contamination.txt $(pwd)/test/output/potential_cross-contamination.txt)
if [ "$DIFF" != "" ]; then
echo "Failure: cross_contamination test output does not match expected output"
echo " expected output:"
cat $(pwd)/output/potential_cross-contamination.txt
echo " test output:"
cat ${{ env.DOCKER_POLYPHONIA_PATH }}/test/output/potential_cross-contamination.txt
exit 1
else
echo "Success: cross_contamination test"
fi
- name: Run polyphonia (cross_contamination test with aligned consensus sequences)
run: |
set -e -x
docker run -v $(pwd)/bin:${{ env.DOCKER_POLYPHONIA_PATH }} -v $(pwd)/test:${{ env.DOCKER_POLYPHONIA_PATH }}/test -v $(pwd)/output:/tmp/output --rm polyphonia:${{ env.GITHUB_ACTIONS_BRANCH }}-${{ env.GITHUB_ACTIONS_SHORT_SHA }} \
polyphonia cross_contamination \
--ref ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/NC_045512.2.fasta \
--vcf ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01315-2021.bam_LoFreq.vcf \
--vcf ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01323-2021.bam_LoFreq.vcf \
--consensus-aligned ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01315_23-2021_MAFFT_aligned.fasta \
--plate-map ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01315_23-2021_plate_map.txt \
--min-depth 0 \
--output /tmp/output/potential_cross-contamination.txt \
--overwrite TRUE
DIFF=$(diff $(pwd)/output/potential_cross-contamination.txt $(pwd)/test/output/potential_cross-contamination.txt)
if [ "$DIFF" != "" ]; then
echo "Failure: cross_contamination test output does not match expected output"
echo " expected output:"
cat $(pwd)/output/potential_cross-contamination.txt
echo " test output:"
cat ${{ env.DOCKER_POLYPHONIA_PATH }}/test/output/potential_cross-contamination.txt
exit 1
else
echo "Success: cross_contamination test"
fi
- name: Run polyphonia (cross_contamination test with aligned consensus sequences with gap in reference)
run: |
set -e -x
docker run -v $(pwd)/bin:${{ env.DOCKER_POLYPHONIA_PATH }} -v $(pwd)/test:${{ env.DOCKER_POLYPHONIA_PATH }}/test -v $(pwd)/output:/tmp/output --rm polyphonia:${{ env.GITHUB_ACTIONS_BRANCH }}-${{ env.GITHUB_ACTIONS_SHORT_SHA }} \
polyphonia cross_contamination \
--ref ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/NC_045512.2.fasta \
--vcf ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01315-2021.bam_LoFreq.vcf \
--vcf ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01323-2021.bam_LoFreq.vcf \
--consensus-aligned ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01315_23-2021_MAFFT_aligned_gap_added.fasta \
--plate-map ${{ env.DOCKER_POLYPHONIA_PATH }}/test/input/USA-MA-Broad_CRSP-01315_23-2021_plate_map.txt \
--min-depth 0 \
--output /tmp/output/potential_cross-contamination.txt \
--overwrite TRUE
DIFF=$(diff $(pwd)/output/potential_cross-contamination.txt $(pwd)/test/output/potential_cross-contamination.txt)
if [ "$DIFF" != "" ]; then
echo "Failure: cross_contamination test output does not match expected output"
echo " expected output:"
cat $(pwd)/output/potential_cross-contamination.txt
echo " test output:"
cat ${{ env.DOCKER_POLYPHONIA_PATH }}/test/output/potential_cross-contamination.txt
exit 1
else
echo "Success: cross_contamination test"
fi