Skip to content

Commit e6715a7

Browse files
committed
[wfpm v0.7.11] initial commit for argo-somatic-variant-calling project
0 parents  commit e6715a7

11 files changed

Lines changed: 452 additions & 0 deletions

File tree

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- '*\@[0-9]+.[0-9]+.[0-9]+*' # package development branch
8+
9+
jobs:
10+
build:
11+
if: ${{ !contains(github.event.head_commit.message, '[no ci]') }}
12+
runs-on: ubuntu-latest
13+
outputs:
14+
branch: ${{ steps.get_pkg_info.outputs.branch }}
15+
pkg_name: ${{ steps.get_pkg_info.outputs.pkg_name }}
16+
pkg_ver: ${{ steps.get_pkg_info.outputs.pkg_ver }}
17+
docker_file: ${{ steps.get_pkg_info.outputs.docker_file }}
18+
repo_lowercase: ${{ steps.repo_lowercase.outputs.lowercase }}
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Set up Python 3.6
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: 3.6
26+
27+
- name: Extract package name and version from branch name
28+
id: get_pkg_info
29+
shell: bash
30+
run: |
31+
echo "::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})"
32+
PKG_NAME=$(echo ${GITHUB_REF#refs/heads/} | awk -F'@' '{print $1}')
33+
PKG_VER=$(echo ${GITHUB_REF#refs/heads/} | awk -F'@' '{print $2}')
34+
echo "::set-output name=pkg_name::$(echo $PKG_NAME)"
35+
echo "::set-output name=pkg_ver::$(echo $PKG_VER)"
36+
if [[ -f "./$PKG_NAME/Dockerfile" ]]; then
37+
echo "::set-output name=docker_file::$(echo ./$PKG_NAME/Dockerfile)"
38+
else
39+
echo "::set-output name=docker_file::"
40+
fi
41+
42+
- name: Login to GitHub Container Registry
43+
if: ${{ steps.get_pkg_info.outputs.branch != 'main' && steps.get_pkg_info.outputs.docker_file != ''}}
44+
uses: docker/login-action@v1
45+
with:
46+
registry: ghcr.io
47+
username: ${{ github.repository_owner }}
48+
password: ${{ secrets.CR_PAT }}
49+
50+
- id: repo_lowercase
51+
uses: ASzc/change-string-case-action@v1
52+
with:
53+
string: ${{ github.repository }}
54+
55+
- name: Build image
56+
if: ${{ steps.get_pkg_info.outputs.branch != 'main' && steps.get_pkg_info.outputs.docker_file != ''}}
57+
uses: docker/build-push-action@v2
58+
with:
59+
context: "./${{steps.get_pkg_info.outputs.pkg_name}}"
60+
file: "${{steps.get_pkg_info.outputs.docker_file}}"
61+
platforms: linux/amd64
62+
load: true
63+
tags: |
64+
ghcr.io/${{ steps.repo_lowercase.outputs.lowercase }}.${{ steps.get_pkg_info.outputs.pkg_name }}:${{ steps.get_pkg_info.outputs.pkg_ver }}
65+
66+
- name: Push image to ghcr.io
67+
id: push_to_ghcr
68+
if: ${{ steps.get_pkg_info.outputs.branch != 'main' && steps.get_pkg_info.outputs.docker_file != ''}}
69+
shell: bash
70+
run: |
71+
docker push ghcr.io/${{ steps.repo_lowercase.outputs.lowercase }}.${{ steps.get_pkg_info.outputs.pkg_name }}:${{ steps.get_pkg_info.outputs.pkg_ver }} | tee ./ghcr.io.stdout
72+
IMAGE_SHA=$(cat ./ghcr.io.stdout | tr ' ' '\n' | grep 'sha256:' | awk -F':' '{print $2}')
73+
echo "::set-output name=image_sha256::$(echo ${IMAGE_SHA})"
74+
echo "::set-output name=created_at::$(date -u +%FT%TZ)"
75+
76+
77+
test-and-release:
78+
runs-on: ubuntu-latest
79+
needs: [build]
80+
steps:
81+
- uses: actions/checkout@v2
82+
83+
- name: Set up Python 3.6
84+
uses: actions/setup-python@v2
85+
with:
86+
python-version: 3.6
87+
88+
- name: Install dependencies
89+
run: |
90+
python -m pip install --upgrade pip
91+
pip install wfpm
92+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
93+
if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
94+
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
95+
96+
- name: Install Nextflow
97+
run: |
98+
wget --tries=10 -qO- https://get.nextflow.io | bash
99+
sudo chmod 755 nextflow
100+
sudo mv nextflow /usr/local/bin/
101+
102+
- name: "Login to GitHub Container Registry" # normally shouldn't need to login, but new image when just created is private
103+
uses: docker/login-action@v1
104+
with:
105+
registry: ghcr.io
106+
username: ${{ github.repository_owner }}
107+
password: ${{ secrets.CR_PAT }}
108+
109+
- name: Run tests for all packages
110+
if: ${{ needs.build.outputs.branch == 'main' }}
111+
run: |
112+
wfpm test
113+
114+
- name: Run tests for the current package only
115+
if: ${{ needs.build.outputs.branch != 'main' }}
116+
run: |
117+
cd ./${{needs.build.outputs.pkg_name}}
118+
wfpm test
119+
120+
- name: Check whether to proceed with release
121+
id: to_release
122+
run: |
123+
if [[ \
124+
"${{ github.event.head_commit.message }}" = "Merge"[[:space:]]"pull"[[:space:]]"request"* && \
125+
"${{ github.event.head_commit.message }}" = *"@"* && \
126+
"${{ github.event.head_commit.message }}" = *"[release]"* && \
127+
"${{ needs.build.outputs.branch }}" = 'main'
128+
]]; then
129+
echo "::set-output name=release::$(echo Y)"
130+
else
131+
echo "::set-output name=release::$(echo N)"
132+
fi
133+
134+
- name: Extract package name and version from commit message
135+
if: ${{ steps.to_release.outputs.release == 'Y' }}
136+
id: get_pkg_info
137+
shell: bash
138+
run: |
139+
MERGED_BR=$(echo -e '${{ github.event.head_commit.message }}' | \
140+
{ grep '^Merge pull request'||:; } | tr ' ' '\n' |{ grep '@'||:; } | awk -F'/' '{print $2}')
141+
PKG_NAME=$(echo $MERGED_BR | awk -F'@' '{print $1}')
142+
PKG_VER=$(echo $MERGED_BR | awk -F'@' '{print $2}')
143+
echo "::set-output name=pkg_name::$(echo ${PKG_NAME})"
144+
echo "::set-output name=pkg_ver::$(echo ${PKG_VER})"
145+
if [[ -f "./$PKG_NAME/Dockerfile" ]]; then
146+
echo "::set-output name=docker_file::$(echo ./$PKG_NAME/Dockerfile)"
147+
echo "::set-output name=docker_image::$(echo ghcr.io/${{ needs.build.outputs.repo_lowercase }}.$PKG_NAME:$PKG_VER)"
148+
else
149+
echo "::set-output name=docker_file::"
150+
echo "::set-output name=docker_image::"
151+
fi
152+
153+
- name: Prepare package release tarball
154+
id: prep_assets
155+
if: ${{ steps.to_release.outputs.release == 'Y' }}
156+
shell: bash
157+
run: |
158+
./scripts/cleanup_temp_files.sh # just in case
159+
PKG_TAR=${{ steps.get_pkg_info.outputs.pkg_name }}.v${{ steps.get_pkg_info.outputs.pkg_ver }}.tar.gz
160+
pushd ${{ steps.get_pkg_info.outputs.pkg_name }}
161+
tar --exclude=wfpr_modules --dereference -czvf ../$PKG_TAR .
162+
popd
163+
echo "::set-output name=pkg_tar::$(echo ${PKG_TAR})"
164+
echo "::set-output name=pkg_tar_sha::$(sha256sum ${PKG_TAR} |awk '{print $1}')"
165+
echo "::set-output name=pkg_tar_size::$(ls -l ${PKG_TAR} |awk '{print $5}')"
166+
echo "::set-output name=created_at::$(date -u +%FT%TZ)"
167+
168+
- name: Create release
169+
id: create_release
170+
if: ${{ steps.to_release.outputs.release == 'Y' }}
171+
uses: actions/create-release@v1
172+
env:
173+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
174+
with:
175+
tag_name: ${{ steps.get_pkg_info.outputs.pkg_name }}.v${{ steps.get_pkg_info.outputs.pkg_ver }}
176+
release_name: ${{ steps.get_pkg_info.outputs.pkg_name }}.v${{ steps.get_pkg_info.outputs.pkg_ver }}
177+
body: |
178+
* Release `${{ steps.get_pkg_info.outputs.pkg_name }}.v${{ steps.get_pkg_info.outputs.pkg_ver }}` (${{ github.sha }})
179+
* Package `${{ steps.prep_assets.outputs.pkg_tar }}` (sha256: `${{ steps.prep_assets.outputs.pkg_tar_sha }}`)
180+
* Package URI `github.com/${{ needs.build.outputs.repo_lowercase }}/${{ steps.get_pkg_info.outputs.pkg_name }}@${{ steps.get_pkg_info.outputs.pkg_ver }}`
181+
* Run the package: `nextflow run ${{ needs.build.outputs.repo_lowercase }}/${{ steps.get_pkg_info.outputs.pkg_name }}/main.nf -r ${{ steps.get_pkg_info.outputs.pkg_name }}.v${{ steps.get_pkg_info.outputs.pkg_ver }} -params-file <params-json-file>`
182+
draft: false
183+
prerelease: false
184+
185+
- name: Prepare in pkg-release.json
186+
if: ${{ steps.to_release.outputs.release == 'Y' }}
187+
shell: bash
188+
run: |
189+
WFPM_VER=$(wfpm -v | cut -d ' ' -f 2)
190+
if [[ '${{ steps.get_pkg_info.outputs.docker_file }}' != '' ]]; then
191+
docker pull ${{ steps.get_pkg_info.outputs.docker_image }} | tee image.info
192+
IMAGE_SHA=$(cat ./image.info | tr ' ' '\n' | grep 'sha256:' | awk -F':' '{print $2}')
193+
else
194+
IMAGE_SHA=$(echo)
195+
fi
196+
197+
# temporary solution
198+
TAG="${{ steps.get_pkg_info.outputs.pkg_name }}.v${{ steps.get_pkg_info.outputs.pkg_ver }}"
199+
./scripts/prepare_package_release_json.py -p ${{ steps.get_pkg_info.outputs.pkg_name }}/pkg.json -d \
200+
"
201+
{
202+
\"_release\": {
203+
\"created\": \"${{ steps.prep_assets.outputs.created_at }}\",
204+
\"hash\": {
205+
\"checksum_type\": \"sha1\",
206+
\"checksume\": \"${{ github.sha }}\"
207+
},
208+
\"tag\": \"$TAG\",
209+
\"assets\": [
210+
{
211+
\"filename\": \"$TAG.tar.gz\",
212+
\"download_url\": \"https://github.com/${{ github.repository }}/releases/download/$TAG/$TAG.tar.gz\",
213+
\"checksum\": \"${{ steps.prep_assets.outputs.pkg_tar_sha }}\",
214+
\"checksum_type\": \"sha256\",
215+
\"size\": ${{ steps.prep_assets.outputs.pkg_tar_size }}
216+
},
217+
{
218+
\"_NOTE_\": \"this file\",
219+
\"filename\": \"pkg-release.json\",
220+
\"download_url\": \"https://github.com/${{ github.repository }}/releases/download/$TAG/pkg-release.json\",
221+
\"checksum\": null,
222+
\"checksum_type\": null,
223+
\"size\": null
224+
}
225+
]
226+
},
227+
\"_image_digest\": {
228+
\"checksum\": \"$IMAGE_SHA\",
229+
\"checksum_type\": \"sha256\"
230+
},
231+
\"_wfpm_ver\": \"$WFPM_VER\"
232+
}
233+
" > pkg-release.json
234+
235+
- name: Upload package release tarball
236+
if: ${{ steps.to_release.outputs.release == 'Y' }}
237+
uses: actions/upload-release-asset@v1
238+
env:
239+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
240+
with:
241+
upload_url: ${{ steps.create_release.outputs.upload_url }}
242+
asset_path: ./${{ steps.prep_assets.outputs.pkg_tar }}
243+
asset_name: ${{ steps.prep_assets.outputs.pkg_tar }}
244+
asset_content_type: application/zip
245+
246+
- name: Upload package release json
247+
if: ${{ steps.to_release.outputs.release == 'Y' }}
248+
uses: actions/upload-release-asset@v1
249+
env:
250+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
251+
with:
252+
upload_url: ${{ steps.create_release.outputs.upload_url }}
253+
asset_path: ./pkg-release.json
254+
asset_name: pkg-release.json
255+
asset_content_type: application/json

.gitignore

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
*.py[cod]
2+
3+
# C extensions
4+
*.so
5+
6+
# Packages
7+
*.egg
8+
*.egg-info
9+
dist
10+
build
11+
eggs
12+
.eggs
13+
parts
14+
bin
15+
var
16+
sdist
17+
develop-eggs
18+
.installed.cfg
19+
lib
20+
lib64
21+
venv*/
22+
pyvenv*/
23+
24+
# Installer logs
25+
pip-log.txt
26+
27+
# Unit test / coverage reports
28+
.coverage
29+
.tox
30+
.coverage.*
31+
nosetests.xml
32+
coverage.xml
33+
htmlcov
34+
35+
# Translations
36+
*.mo
37+
38+
# Mr Developer
39+
.mr.developer.cfg
40+
.project
41+
.pydevproject
42+
.idea
43+
*.iml
44+
*.komodoproject
45+
46+
# Complexity
47+
output/*.html
48+
output/*/index.html
49+
50+
# Sphinx
51+
docs/_build
52+
53+
.DS_Store
54+
*~
55+
.*.sw[po]
56+
.build
57+
.ve
58+
.env
59+
.cache
60+
.pytest
61+
.bootstrap
62+
.appveyor.token
63+
*.bak
64+
*.log
65+
.vscode
66+
.python-version
67+
.nextflow*
68+
work
69+
outdir
70+
wfpr_modules/github.com/*/*/*/tests
71+
72+
# singularity images
73+
**/*.img
74+
**/*.sif

.wfpm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
project_name: argo-somatic-variant-calling
2+
license: MIT
3+
repo_type: git
4+
repo_server: github.com
5+
repo_account: icgc-argo-workflows

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021, ICGC ARGO
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

LICENSE-short

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2021, ICGC ARGO
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# A collection of somatic variant callers
2+
3+
Update this to describe your awesome project.

nextflow.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
manifest {
2+
homePage = 'https://github.com/icgc-argo-workflows/argo-somatic-variant-calling'
3+
description = 'A collection of somatic variant callers'
4+
nextflowVersion = '>=20.10'
5+
}
6+
7+
docker {
8+
enabled = true
9+
runOptions = '-u \$(id -u):\$(id -g)'
10+
}

0 commit comments

Comments
 (0)