-
Notifications
You must be signed in to change notification settings - Fork 2
166 lines (153 loc) · 5.08 KB
/
build-warp-tools.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
name: Warp Tools CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "develop" and "master" branch
# Uncomment this block and add your branch name to test without creating a PR
#push:
#branches: [ "kp_github_actions_pd-2113" ]
#paths-ignore:
# - '**/README.md'
pull_request:
branches: [ "develop", "master" ]
paths:
- 'tools/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
image_tag:
description: 'Docker Image Tag (default: branch_name)'
env:
PROJECT_NAME: WARP Tools
# Github repo name
REPOSITORY_NAME: ${{ github.event.repository.name }}
# Region-specific Google Docker repository where GOOGLE_PROJECT/REPOSITORY_NAME can be found
GOOGLE_CONTAINER_REGISTRY: us.gcr.io
GCR_PATH: broad-gotc-prod/warp-tools
ACR_PATH: warp-tools
TAG: ${{ github.event.inputs.image_tag || github.head_ref || github.ref_name }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# The job that builds our container
build-for-gcr:
# The type of runner that the job will run on
runs-on: ubuntu-latest
defaults:
run:
working-directory: tools
# Map a step output to a job output
outputs:
imagePath: ${{ steps.saveImagePath.outputs.url }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Build the Docker image for GCR
run: docker build . --file Dockerfile --tag ${GOOGLE_CONTAINER_REGISTRY}/${GCR_PATH}:${TAG}
- name: Check working directory'
run: |
echo "Current directory: "
pwd
ls -lht
# Save the image path to an output
- id: 'saveImagePath'
run: echo "url=${GOOGLE_CONTAINER_REGISTRY}/${GCR_PATH}:${TAG}" >> $GITHUB_OUTPUT
# Log into the Google Container registry
- id: 'Auth'
name: Login to GCR
uses: docker/login-action@v2
with:
registry: ${{ env.GOOGLE_CONTAINER_REGISTRY }}
username: _json_key
password: ${{ secrets.GCR_CI_KEY }}
# Push the image to the Google Container registry
- name: Push image
run: "docker push ${GOOGLE_CONTAINER_REGISTRY}/${GCR_PATH}:${TAG}"
#Runs pytest on all python code in warp-tools/tools
test-python:
needs: build-for-gcr
runs-on: ubuntu-latest
defaults:
run:
working-directory: tools
strategy:
matrix:
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with ruff
run: |
# default set of ruff rules with GitHub Annotations
ruff --format=github --target-version=py37 .
continue-on-error: true
- name: Test with pytest
run: |
pytest
test-c:
runs-on: ubuntu-latest
needs: build-for-gcr
container:
image: ${{needs.build-for-gcr.outputs.imagePath}}
# volumes:
# - my_docker_volume:/volume_mount
# options: --cpus 1
options: "--entrypoint /bin/bash"
steps:
- name: Check for dockerenv file
run: |
(ls /.dockerenv && echo Found dockerenv && cat /.dockerenv) || (echo No dockerenv)
- name: Check directory
run: |
apt-get install tree
whoami
pwd
ls -lhta
tree /warptools
# if test is at the end of the file name in the the test dir -- it gets picked up
- name: Test TagSort
run: |
cd /warptools/TagSort
pwd
ls -lhta
./fetch_gtest.sh && make test
cd /warptools/TagSort/bin
ls -lht
for f in *test; do ./"$f"; done;
- name: Test FastqPreprocessing
run: |
cd /warptools/fastqpreprocessing
pwd
ls -lhta
./fetch_gtest.sh && make test
cd /warptools/fastqpreprocessing/bin
ls -lht
for f in *test; do ./"$f"; done;
build-for-acr:
runs-on: ubuntu-latest
defaults:
run:
working-directory: tools
steps:
# checkout the repo
- name: 'Checkout GitHub Action'
uses: actions/checkout@v3
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Build and push image'
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/${ACR_PATH}:${TAG}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/${ACR_PATH}:${TAG}