|
a |
|
b/.github/workflows/qiita-ci.yml |
|
|
1 |
# name: Qiita CI |
|
|
2 |
|
|
|
3 |
on: |
|
|
4 |
push: |
|
|
5 |
branches: [ dev ] |
|
|
6 |
pull_request: |
|
|
7 |
|
|
|
8 |
jobs: |
|
|
9 |
# derived from https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml |
|
|
10 |
main: |
|
|
11 |
runs-on: ubuntu-latest |
|
|
12 |
|
|
|
13 |
strategy: |
|
|
14 |
matrix: |
|
|
15 |
include: |
|
|
16 |
- cover_package: "qiita_db" |
|
|
17 |
- cover_package: "qiita_pet qiita_core qiita_ware" |
|
|
18 |
|
|
|
19 |
services: |
|
|
20 |
postgres: |
|
|
21 |
# Docker Hub image |
|
|
22 |
image: postgres:13.4 |
|
|
23 |
env: |
|
|
24 |
POSTGRES_DB: postgres |
|
|
25 |
POSTGRES_USER: postgres |
|
|
26 |
POSTGRES_PASSWORD: postgres |
|
|
27 |
COVER_PACKAGE: ${{ matrix.cover_package }} |
|
|
28 |
|
|
|
29 |
# Set health checks to wait until postgres has started |
|
|
30 |
options: >- |
|
|
31 |
--health-cmd pg_isready |
|
|
32 |
--health-interval 10s |
|
|
33 |
--health-timeout 5s |
|
|
34 |
--health-retries 5 |
|
|
35 |
ports: |
|
|
36 |
# based on https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml#L44-L72 |
|
|
37 |
- 5432/tcp |
|
|
38 |
|
|
|
39 |
steps: |
|
|
40 |
# Downloads a copy of the code in your repository before running CI tests |
|
|
41 |
- name: Check out repository code |
|
|
42 |
uses: actions/checkout@v2 |
|
|
43 |
|
|
|
44 |
- name: Setup for conda |
|
|
45 |
uses: conda-incubator/setup-miniconda@v2 |
|
|
46 |
with: |
|
|
47 |
auto-update-conda: true |
|
|
48 |
python-version: '3.9' |
|
|
49 |
|
|
|
50 |
- name: Basic dependencies install |
|
|
51 |
env: |
|
|
52 |
COVER_PACKAGE: ${{ matrix.cover_package }} |
|
|
53 |
shell: bash -l {0} |
|
|
54 |
run: | |
|
|
55 |
echo "Testing: " $COVER_PACKAGE |
|
|
56 |
|
|
|
57 |
# pull out the port so we can modify the configuration file easily |
|
|
58 |
pgport=${{ job.services.postgres.ports[5432] }} |
|
|
59 |
sed -i "s/PORT = 5432/PORT = $pgport/" qiita_core/support_files/config_test.cfg |
|
|
60 |
|
|
|
61 |
# PGPASSWORD is read by pg_restore, which is called by the build_db process. |
|
|
62 |
export PGPASSWORD=postgres |
|
|
63 |
|
|
|
64 |
# Setting up main qiita conda environment |
|
|
65 |
conda config --add channels conda-forge |
|
|
66 |
conda deactivate |
|
|
67 |
conda create --quiet --yes -n qiita python=3.9 pip libgfortran numpy nginx cython redis |
|
|
68 |
conda env list |
|
|
69 |
conda activate qiita |
|
|
70 |
pip install -U pip |
|
|
71 |
pip install sphinx sphinx-bootstrap-theme nose-timer Click coverage |
|
|
72 |
|
|
|
73 |
# Configuring SSH |
|
|
74 |
cp /etc/ssh/sshd_config sshd_config |
|
|
75 |
echo "RSAAuthentication yes" > sshd_config |
|
|
76 |
echo "PubkeyAuthentication yes" > sshd_config |
|
|
77 |
echo "StrictModes no" > sshd_config |
|
|
78 |
sudo mv sshd_config /etc/ssh/sshd_config |
|
|
79 |
sudo systemctl restart ssh |
|
|
80 |
|
|
|
81 |
- name: Webdis install |
|
|
82 |
shell: bash -l {0} |
|
|
83 |
run: | |
|
|
84 |
sudo apt-get -y install libevent-dev |
|
|
85 |
git clone https://github.com/nicolasff/webdis |
|
|
86 |
cd webdis |
|
|
87 |
make |
|
|
88 |
|
|
|
89 |
- name: Main install |
|
|
90 |
shell: bash -l {0} |
|
|
91 |
run: | |
|
|
92 |
conda activate qiita |
|
|
93 |
export QIITA_ROOTCA_CERT=`pwd`/qiita_core/support_files/ci_rootca.crt |
|
|
94 |
export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test.cfg |
|
|
95 |
export REDBIOM_HOST="http://localhost:7379" |
|
|
96 |
|
|
|
97 |
pip install . --no-binary redbiom |
|
|
98 |
# 10.2022 |
|
|
99 |
# this is for redbiom / biom-format (so fine to delete in the future) |
|
|
100 |
pip install future |
|
|
101 |
pwd |
|
|
102 |
mkdir ~/.qiita_plugins |
|
|
103 |
|
|
|
104 |
- name: Install plugins |
|
|
105 |
shell: bash -l {0} |
|
|
106 |
run: | |
|
|
107 |
conda env create -n qtp-biom --file https://data.qiime2.org/distro/amplicon/qiime2-amplicon-2024.5-py39-linux-conda.yml |
|
|
108 |
export QIITA_ROOTCA_CERT=`pwd`/qiita_core/support_files/ci_rootca.crt |
|
|
109 |
export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test.cfg |
|
|
110 |
export REDBIOM_HOST="http://localhost:7379" |
|
|
111 |
conda activate qtp-biom |
|
|
112 |
pip install -U pip |
|
|
113 |
pip install https://github.com/qiita-spots/qiita_client/archive/master.zip |
|
|
114 |
pip install https://github.com/qiita-spots/qtp-biom/archive/master.zip |
|
|
115 |
|
|
|
116 |
# if QIITA_ROOTCA_CERT is appended to certifi's cacert.pem file, |
|
|
117 |
# then --server-cert does not need to be specified to any plugin, |
|
|
118 |
# including configure_biom. |
|
|
119 |
# echo `python -c "import certifi;print(certifi.where())"` |
|
|
120 |
configure_biom --env-script "source /home/runner/.profile; conda activate qtp-biom" --server-cert $QIITA_ROOTCA_CERT |
|
|
121 |
|
|
|
122 |
- name: Starting services |
|
|
123 |
shell: bash -l {0} |
|
|
124 |
run: | |
|
|
125 |
conda activate qiita |
|
|
126 |
export QIITA_ROOTCA_CERT=`pwd`/qiita_core/support_files/ci_rootca.crt |
|
|
127 |
export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test.cfg |
|
|
128 |
export REDBIOM_HOST="http://localhost:7379" |
|
|
129 |
|
|
|
130 |
echo "1. Setting up redis" |
|
|
131 |
redis-server --daemonize yes --port 7777 |
|
|
132 |
redis-server --daemonize yes --port 6379 |
|
|
133 |
|
|
|
134 |
echo "2. Starting webdis" |
|
|
135 |
pushd webdis |
|
|
136 |
./webdis & |
|
|
137 |
popd |
|
|
138 |
|
|
|
139 |
echo "3. Starting redbiom: " $REDBIOM_HOST |
|
|
140 |
curl -s http://localhost:7379/FLUSHALL > /dev/null |
|
|
141 |
redbiom --version |
|
|
142 |
redbiom admin scripts-writable |
|
|
143 |
redbiom admin create-context --name "qiita-test" --description "qiita-test context" |
|
|
144 |
redbiom admin load-sample-metadata --metadata `pwd`/qiita_db/support_files/test_data/templates/1_19700101-000000.txt |
|
|
145 |
redbiom admin load-sample-metadata-search --metadata `pwd`/qiita_db/support_files/test_data/templates/1_19700101-000000.txt |
|
|
146 |
redbiom admin load-sample-data --table `pwd`/qiita_db/support_files/test_data/processed_data/1_study_1001_closed_reference_otu_table.biom --context qiita-test --tag 4 |
|
|
147 |
redbiom admin load-sample-data --table `pwd`/qiita_db/support_files/test_data/processed_data/1_study_1001_closed_reference_otu_table-for_redbiom_tests.biom --context qiita-test --tag 5 |
|
|
148 |
|
|
|
149 |
echo "4. Setting up nginx" |
|
|
150 |
mkdir -p /usr/share/miniconda/envs/qiita/var/run/nginx/ |
|
|
151 |
nginx -c ${PWD}/qiita_pet/nginx_example.conf |
|
|
152 |
|
|
|
153 |
echo "5. Setting up qiita" |
|
|
154 |
conda activate qiita |
|
|
155 |
qiita-env make --no-load-ontologies |
|
|
156 |
qiita-test-install |
|
|
157 |
qiita plugins update |
|
|
158 |
|
|
|
159 |
echo "6. Starting supervisord => multiple qiita instances" |
|
|
160 |
supervisord -c ${PWD}/qiita_pet/supervisor_example.conf |
|
|
161 |
sleep 10 |
|
|
162 |
cat /tmp/supervisord.log |
|
|
163 |
|
|
|
164 |
echo "7. Starting plugins" |
|
|
165 |
conda deactivate |
|
|
166 |
conda activate qtp-biom |
|
|
167 |
export QIITA_CLIENT_DEBUG_LEVEL=DEBUG |
|
|
168 |
start_biom https://localhost:8383 register ignored |
|
|
169 |
conda deactivate |
|
|
170 |
|
|
|
171 |
echo "8. Setting up SSH" |
|
|
172 |
ssh-keygen -t rsa -b 4096 -N '' -f $PWD/qiita_ware/test/test_data/test_key |
|
|
173 |
mkdir ~/.ssh/ |
|
|
174 |
cp $PWD/qiita_ware/test/test_data/test_key* ~/.ssh/ |
|
|
175 |
cat ~/.ssh/test_key.pub > ~/.ssh/authorized_keys |
|
|
176 |
chmod 600 $PWD/qiita_ware/test/test_data/test_key* |
|
|
177 |
chmod 600 ~/.ssh/* |
|
|
178 |
chmod 700 ~/.ssh/ |
|
|
179 |
echo "Connecting as $USER@localhost" |
|
|
180 |
# this line (and the -o StrictHostKeyChecking=no) is so the server |
|
|
181 |
# is added to the list of known servers |
|
|
182 |
scp -O -o StrictHostKeyChecking=no -i $PWD/qiita_ware/test/test_data/test_key $USER@localhost:/home/runner/work/qiita/qiita/qiita_ware/test/test_data/random_key /home/runner/work/qiita/qiita/qiita_ware/test/test_data/random_key_copy_1 |
|
|
183 |
|
|
|
184 |
- name: Main tests |
|
|
185 |
shell: bash -l {0} |
|
|
186 |
env: |
|
|
187 |
COVER_PACKAGE: ${{ matrix.cover_package }} |
|
|
188 |
run: | |
|
|
189 |
conda activate qiita |
|
|
190 |
export QIITA_ROOTCA_CERT=`pwd`/qiita_core/support_files/ci_rootca.crt |
|
|
191 |
export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test.cfg |
|
|
192 |
# for testing we only need to have this set, not actually exist |
|
|
193 |
export QIITA_JOB_SCHEDULER_EPILOGUE=`/path/to/epilogue/file` |
|
|
194 |
export REDBIOM_HOST="http://localhost:7379" |
|
|
195 |
|
|
|
196 |
nosetests $COVER_PACKAGE --with-doctest --with-coverage --with-timer -v --cover-package=${COVER_PACKAGE// / --cover-package=} -e 'test_submit_EBI_parse_EBI_reply_failure' -e 'test_full_submission' |
|
|
197 |
|
|
|
198 |
# killing the qiita server to run the next commands |
|
|
199 |
QIITA_PID=`cat /tmp/supervisord.pid` |
|
|
200 |
kill $QIITA_PID |
|
|
201 |
sleep 10 |
|
|
202 |
# due to qiita_db tests being more complex and taking longer than |
|
|
203 |
# the other tests we will only add some extra tests to the run that is |
|
|
204 |
# not testing qiita_db |
|
|
205 |
if [[ "$COVER_PACKAGE" != *"qiita_db"* ]]; then |
|
|
206 |
# 1. testing that we can add some "dummy" studies to the db via |
|
|
207 |
# CLI |
|
|
208 |
test_data_studies/commands.sh; |
|
|
209 |
# 2. making sure that all qiita cron jobs complete as expected |
|
|
210 |
all-qiita-cron-job; |
|
|
211 |
# 3. making sure than a production system has the expected rows |
|
|
212 |
# in all our tables; steps: a. drop test db, b. change $QIITA_CONFIG_FP |
|
|
213 |
# c. create new production system, c. count rows in the db. |
|
|
214 |
qiita-env drop; |
|
|
215 |
cp $QIITA_CONFIG_FP ${QIITA_CONFIG_FP}.bk |
|
|
216 |
sed 's/TEST_ENVIRONMENT = TRUE/TEST_ENVIRONMENT = FALSE/g' ${QIITA_CONFIG_FP}.bk > $QIITA_CONFIG_FP; |
|
|
217 |
qiita-env make --no-load-ontologies; |
|
|
218 |
|
|
|
219 |
export PGPASSWORD=postgres |
|
|
220 |
pgport=${{ job.services.postgres.ports[5432] }} |
|
|
221 |
row_counts=`psql -h localhost -U postgres -d qiita_test -p $pgport -c "SELECT SUM(c.reltuples) FROM pg_class c JOIN pg_namespace n on n.oid = c.relnamespace WHERE n.nspname = 'qiita' AND c.relkind = 'r' AND n.nspname NOT IN ('information_schema', 'pg_catalog');"` |
|
|
222 |
if [[ `echo $row_counts` != *" 0 "* ]]; then |
|
|
223 |
echo "***********"; |
|
|
224 |
echo "The number of rows in a production system is not what's expected:"; |
|
|
225 |
echo $row_counts; |
|
|
226 |
echo "***********"; |
|
|
227 |
exit 1 |
|
|
228 |
fi |
|
|
229 |
fi |
|
|
230 |
|
|
|
231 |
- name: Submit coveralls |
|
|
232 |
uses: AndreMiras/coveralls-python-action@develop |
|
|
233 |
with: |
|
|
234 |
github-token: ${{ secrets.github_token }} |
|
|
235 |
flag-name: "${{ matrix.cover_package }}" |
|
|
236 |
parallel: true |
|
|
237 |
|
|
|
238 |
coveralls_finish: |
|
|
239 |
needs: main |
|
|
240 |
runs-on: ubuntu-latest |
|
|
241 |
steps: |
|
|
242 |
- name: Coveralls Finished |
|
|
243 |
uses: AndreMiras/coveralls-python-action@develop |
|
|
244 |
with: |
|
|
245 |
github-token: ${{ secrets.github_token }} |
|
|
246 |
parallel-finished: true |
|
|
247 |
|
|
|
248 |
lint: |
|
|
249 |
runs-on: ubuntu-latest |
|
|
250 |
steps: |
|
|
251 |
- name: flake8 |
|
|
252 |
uses: actions/setup-python@v2 |
|
|
253 |
with: |
|
|
254 |
python-version: '3.9' |
|
|
255 |
- name: install dependencies |
|
|
256 |
run: python -m pip install --upgrade pip |
|
|
257 |
- name: Check out repository code |
|
|
258 |
uses: actions/checkout@v2 |
|
|
259 |
- name: lint |
|
|
260 |
run: | |
|
|
261 |
pip install -q flake8 |
|
|
262 |
flake8 qiita_* setup.py scripts/qiita* notebooks/*/*.py |