-
Notifications
You must be signed in to change notification settings - Fork 39
160 lines (140 loc) · 5.08 KB
/
ci-preprocessor.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
name: Preprocessor CI
on:
workflow_dispatch:
branches:
- '*'
push:
branches:
- '*'
paths:
- '.github/workflows/ci-preprocessor.yml'
- 'preprocessor/**'
# cancel current build on push from the same PR, branch or tag (https://stackoverflow.com/a/72408109/1063501)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
BCFTOOLS_VERSION: '1.20'
HTSLIB_VERSION: '1.20'
REFERENCE_FASTA_ZENODO_ID: 7288118
TOOLS_DIR: /home/runner/work/PharmCAT/PharmCAT/tools
jobs:
build:
name: Build project
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache bcftools
id: cache-bcftools
uses: actions/cache@v4
with:
path: ${{ env.TOOLS_DIR }}/bcftools
key: bcftools-${{ env.BCFTOOLS_VERSION }}
- name: Install bcftools
if: steps.cache-bcftools.outputs.cache-hit != 'true'
run: |
wget https://github.com/samtools/bcftools/releases/download/${BCFTOOLS_VERSION}/bcftools-${BCFTOOLS_VERSION}.tar.bz2
tar -xjf bcftools-${BCFTOOLS_VERSION}.tar.bz2
cd bcftools-${BCFTOOLS_VERSION}
./configure --prefix ${TOOLS_DIR}/bcftools
make
make install
- name: Cache htslib
id: cache-htslib
uses: actions/cache@v4
with:
path: ${{ env.TOOLS_DIR }}/htslib
key: htslib-${{ env.HTSLIB_VERSION }}
- name: Install htslib
if: steps.cache-htslib.outputs.cache-hit != 'true'
run: |
wget https://github.com/samtools/htslib/releases/download/${HTSLIB_VERSION}/htslib-${HTSLIB_VERSION}.tar.bz2
tar -xjf htslib-${HTSLIB_VERSION}.tar.bz2
cd htslib-${HTSLIB_VERSION}
./configure --prefix ${TOOLS_DIR}/htslib
make
make install
- name: Add tools to path
run: echo "${TOOLS_DIR}/bcftools/bin:${TOOLS_DIR}/htslib/bin" >> $GITHUB_PATH
# need JDK present for tests
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install python dependencies
run: pip3 install -r preprocessor/requirements.txt
- name: Install pytest
run: pip3 install pytest pytest-cov pytest-github-actions-annotate-failures
- name: Cache reference FASTA
id: cache-ref-fasta
uses: actions/cache@v4
with:
path: |
reference.fna.bgz
reference.fna.bgz.fai
reference.fna.bgz.gzi
key: ref-fasta-${{ env.REFERENCE_FASTA_ZENODO_ID }}
- name: Download reference FASTA
if: steps.cache-ref-fasta.outputs.cache-hit != 'true'
run: |
wget https://zenodo.org/record/${REFERENCE_FASTA_ZENODO_ID}/files/GRCh38_reference_fasta.tar
tar -xf GRCh38_reference_fasta.tar
rm -f GRCh38_reference_fasta.tar
# wait a bit on a release commit to give release action time to upload the resources necessary for test
- name: Sleep for 60 seconds
run: sleep 60s
shell: bash
if: ${{ startsWith(github.event.head_commit.message, 'chore(release)') }}
- name: Run preprocessor tests
run: python3 -m pytest --cov-config=../.coveragerc --cov-report=xml --cov=preprocessor
working-directory: preprocessor
- name: Codecov
uses: codecov/codecov-action@v3
with:
files: preprocessor/coverage-python.xml
flags: Preprocessor
- name: Send Slack notification on failure
if: failure()
uses: slackapi/slack-github-action@v1
with:
channel-id: 'dev'
payload: |
{
"attachments": [{
"color": "#ff0000",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":stop: <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|FAILED ${{ github.workflow }}!>"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Triggered by ${{ github.event_name }} on <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|${{ github.ref_name }}> by ${{ github.actor }}."
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Last commit:\n${{ github.event.head_commit.message }}"
}
]
}
]
}]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}