-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
193 lines (176 loc) · 8.6 KB
/
Taskfile.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
version: '3'
env:
DOCKER_COMPOSE_FILE: docker-compose.yml
API_DOCKER_NAME: api
MONGO_DOCKER_NAME: mongodb
SOURMASH_QUEUE_DOCKER_NAME: sourmash-queue
EMG_CONTAINER_RESULT_PATH: /opt/emgapi/results
EMG_CONTAINER_FIXTURES_PATH: /opt/emgapi/fixtures
EMG_CONFIG_DEFAULT: "config/local-lite.yml"
EMG_CONFIG_TESTS: "config/local-tests.yml"
tasks:
dc:
desc: "Run a docker compose subcommand, e.g. task dc -- down"
cmds:
- docker compose -f {{.DOCKER_COMPOSE_FILE}} {{.CLI_ARGS}}
docker-compose-up:
desc: "Start the docker compose services."
summary: |
Which services are started depends on the DOCKER_COMPOSE_PROFILE env var.
See the docker-compose file for details.
You can also override the EMV_CONFIG env var to tell the API container to use a different YAML.
cmds:
- docker compose -f {{.DOCKER_COMPOSE_FILE}} --profile {{.DOCKER_COMPOSE_PROFILE | default "''"}} {{.DOCKER_ARGS}} up -d {{.DOCKER_COMPOSE_UP_FLAGS}} --remove-orphans --force-recreate
env:
EMG_CONFIG: "{{.EMG_CONFIG | default .EMG_CONFIG_DEFAULT}}"
vars:
DOCKER_COMPOSE_PROFILE:
manage:
desc: "Run Django manage.py subcommand, e.g. task manage -- makemigrations"
cmds:
- docker compose exec -w /opt/emgapi {{.DOCKER_ARGS}} {{.API_DOCKER_NAME}} python3 emgcli/manage.py {{.ARGUMENTS}} {{.CLI_ARGS}}
env:
EMG_CONFIG: "{{.EMG_CONFIG | default .EMG_CONFIG_DEFAULT}}"
migrate:
desc: "Run Django migrate in the API container."
cmds:
- task: docker-compose-up
- task: manage
vars:
ARGUMENTS: "migrate -v 3"
restore-mongo-test-db:
desc: "Writes the contents of the emg-testdb.mongoarchive fixtures into the containerized Mongo DB."
cmds:
- task: docker-compose-up
- docker compose -f {{.DOCKER_COMPOSE_FILE}} exec -T {{.MONGO_DOCKER_NAME}} mongorestore --gzip --archive < ./ebi-metagenomics-client/ci/testdbs/emg-testdb.mongoarchive
env:
EMG_CONFIG: "{{.EMG_CONFIG | default .EMG_CONFIG_DEFAULT}}"
run-api:
desc: "Starts the API django app and necessary services in docker."
cmds:
- task: docker-compose-up
vars:
DOCKER_COMPOSE_PROFILE: "{{.PROFILE}}"
- task: manage
vars:
ARGUMENTS: "collectstatic --noinput"
- task: manage
vars:
ARGUMENTS: "runserver 0.0.0.0:8000 --nostatic"
DOCKER_ARGS: "-d"
run-api-with-sourmash:
desc: "Starts the API django app, necessary services, as well as the Sourmash microservice and its dependencies."
cmds:
- task: run-api
vars:
PROFILE: "sourmash"
install-client-deps:
desc: "Runs npm install for the web client's dependencies."
cmds:
- npm install
dir: ebi-metagenomics-client
sources:
- ebi-metagenomics-client/package.json
run-client:
desc: "Runs the web client (in watch mode) as well as the API and neccesary services."
deps:
- install-client-deps
- run-api
cmds:
- source ebi-metagenomics-client/env-config.sh
- npm --prefix ebi-metagenomics-client run start --watch
test-api:
desc: "Runs the API test suite using Pytest."
summary: "Add arguments like `task test-api -- -k \"test_import\"` to select only some tests by dir/file/class/method."
cmds:
- task: docker-compose-up
vars:
DOCKER_COMPOSE_PROFILE: "tests"
EMG_CONFIG: "{{.EMG_CONFIG_TESTS}}"
- docker compose -f {{.DOCKER_COMPOSE_FILE}} {{.DOCKER_ARGS}} exec -w /opt/emgapi {{.API_DOCKER_NAME}} pytest {{.CLI_ARGS}}
env:
EMG_CONFIG: "{{.EMG_CONFIG_TESTS}}"
test-client-run:
desc: "Runs the web client test suite using cypress."
preconditions:
- sh: test -n "$(lsof -i :9000)"
msg: 'You need to run the client first. Use `task run-client`'
dir: ebi-metagenomics-client
cmds:
- npx cypress run --env API_URL=http://localhost:8000/v1 {{.CLI_ARGS}}
test-client-open:
desc: "Opens the web client test suite using cypress, for interactive testing."
preconditions:
- sh: test -n "$(lsof -i :9000)"
msg: 'You need to run the client first. Use `task run-client`'
dir: ebi-metagenomics-client
cmds:
- npx cypress open --env API_URL=http://localhost:8000/v1 --e2e
create-sourmash-test-index:
desc: "Creates a minimal sourmash index for use in development."
cmds:
- task: docker-compose-up
- docker compose -f {{.DOCKER_COMPOSE_FILE}} exec -T -w /opt/app/ {{.SOURMASH_QUEUE_DOCKER_NAME}} sourmash sketch dna --from-file test-data/human-gut-v2-0/all_fasta.txt --outdir /opt/sourmash/signatures/human-gut-v2-0 --name-from-first
- docker compose -f {{.DOCKER_COMPOSE_FILE}} exec -T -w /opt/sourmash/signatures/human-gut-v2-0 {{.SOURMASH_QUEUE_DOCKER_NAME}} sh -c "sourmash index -k 31 --scaled 1000 --dna genomes_index *.sig"
- docker compose -f {{.DOCKER_COMPOSE_FILE}} exec -T -w /opt/sourmash/signatures/human-gut-v2-0 {{.SOURMASH_QUEUE_DOCKER_NAME}} unzip genomes_index.sbt.zip
create-test-dbs:
desc: "Creates minimal dev databases as sqlite/mongoarchive files."
cmds:
- docker compose -f {{.DOCKER_COMPOSE_FILE}} down
- rm ebi-metagenomics-client/ci/testdbs/emg-testdb.sqlite || echo
- rm ebi-metagenomics-client/ci/testdbs/emg-testdb.mongoarchive || echo
- rm ebi-metagenomics-client/ci/testdbs/ena-testdb.sqlite || echo
- task: docker-compose-up
- task: migrate
- task: manage
vars: { ARGUMENTS: 'create_ena_test_db' }
- task: manage
vars: { ARGUMENTS: 'import_kegg_modules {{.EMG_CONTAINER_FIXTURES_PATH}}/kegg_module_orthology.json' }
- task: manage
vars: { ARGUMENTS: 'import_kegg_classes {{.EMG_CONTAINER_FIXTURES_PATH}}/kegg_class_orthology.json' }
- task: manage
vars: { ARGUMENTS: 'import_cog_descriptions {{.EMG_CONTAINER_FIXTURES_PATH}}/cog.csv' }
- task: manage
vars: { ARGUMENTS: 'import_biomes {{.EMG_CONTAINER_FIXTURES_PATH}}/biome_hierarchy_tree.json'}
- task: manage
vars: { ARGUMENTS: 'import_variable_names {{.EMG_CONTAINER_FIXTURES_PATH}}/variable_names.json' }
- task: manage
vars: { ARGUMENTS: 'import_analysis_statuses {{.EMG_CONTAINER_FIXTURES_PATH}}/analysis_statuses.json' }
- task: manage
vars: { ARGUMENTS: 'import_genomes {{.EMG_CONTAINER_RESULT_PATH}} genomes/uhgg/2.0 Human\ Gut 2.0 root:Host-associated:Human:Digestive\ system:Large\ intestine v1.2.1' }
- task: manage
vars: { ARGUMENTS: 'import_genomes {{.EMG_CONTAINER_RESULT_PATH}} genomes/non-model-fish-gut/2.0 Non-Model\ Fish\ Gut 2.0 root:Host-associated:Fish:Digestive\ system v2.0.0' }
- task: manage # Set genome catalogue details usually set in admin panel
vars:
ARGUMENTS:
sh: echo "shell -c \"$(cat scripts/create_test_db_helpers/update_genome_catalogue_metadata.py)\""
- task: manage
vars:
ARGUMENTS: 'createsuperuser --noinput --username emgtest --email emgtest@example.com'
DOCKER_ARGS: '-e DJANGO_SUPERUSER_PASSWORD=emgemgtesttest'
- task: manage
vars: { ARGUMENTS: 'import_analysis ERZ8153470 root:Host-associated:Human:Digestive\ system ASSEMBLY --rootpath /opt/emgapi/results --pipeline 5.0 --result_status full'}
- task: manage
vars: { ARGUMENTS: 'import_extra_assembly_annotations /opt/emgapi/results sanntis sanntis' }
- task: manage
vars: { ARGUMENTS: 'import_extra_assembly_annotations /opt/emgapi/results crates/assembly-annotations rocrate' }
- task: manage
vars: { ARGUMENTS: 'import_extra_run_annotations /opt/emgapi/results crates/run-annotations rocrate' }
- task: manage # Make a super study – usually done in admin panel
vars:
ARGUMENTS:
sh: echo "shell -c \"$(cat scripts/create_test_db_helpers/create_test_super_study.py)\""
- docker compose -f {{.DOCKER_COMPOSE_FILE}} exec -T {{.MONGO_DOCKER_NAME}} mongodump --db emg --gzip --archive > ./ebi-metagenomics-client/ci/testdbs/emg-testdb.mongoarchive
bump-client-version:
desc: "Increments the version of web client. E.g. task bump-client-version -- patch"
summary: "The version part can be patch, minor, major"
cmds:
- npm version {{.CLI_ARGS | default "patch"}} --force --no-git-tag-version
dir: ebi-metagenomics-client
bump-api-version:
desc: "Increments the version of API. E.g. task bump-api-version -- patch"
summary: "The version part can be patch, minor, major"
deps:
- run-api
cmds:
- docker compose -f {{.DOCKER_COMPOSE_FILE}} exec -w /opt/emgapi -T {{.API_DOCKER_NAME}} bumpversion bump -- {{.CLI_ARGS | default "patch"}}