|
| 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:9.5 |
| 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.6 |
| 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 create -q --yes -n qiita python=3.6 pip libgfortran numpy nginx cython redis |
| 67 | + conda activate qiita |
| 68 | + pip install sphinx sphinx-bootstrap-theme nose-timer codecov Click |
| 69 | +
|
| 70 | + # Configuring SSH |
| 71 | + cp /etc/ssh/sshd_config sshd_config |
| 72 | + echo "RSAAuthentication yes" > sshd_config |
| 73 | + echo "PubkeyAuthentication yes" > sshd_config |
| 74 | + echo "StrictModes no" > sshd_config |
| 75 | + sudo mv sshd_config /etc/ssh/sshd_config |
| 76 | + sudo systemctl restart ssh |
| 77 | +
|
| 78 | + - name: Webdis install |
| 79 | + shell: bash -l {0} |
| 80 | + run: | |
| 81 | + sudo apt-get -y install libevent-dev |
| 82 | + git clone https://github.com/nicolasff/webdis |
| 83 | + cd webdis |
| 84 | + make |
| 85 | +
|
| 86 | + - name: Main install |
| 87 | + shell: bash -l {0} |
| 88 | + run: | |
| 89 | + conda activate qiita |
| 90 | + export QIITA_SERVER_CERT=`pwd`/qiita_core/support_files/server.crt |
| 91 | + export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test.cfg |
| 92 | + export REDBIOM_HOST="http://localhost:7379" |
| 93 | + pip install . --no-binary redbiom |
| 94 | + pwd |
| 95 | + mkdir ~/.qiita_plugins |
| 96 | +
|
| 97 | + - name: Install plugins |
| 98 | + shell: bash -l {0} |
| 99 | + run: | |
| 100 | + wget https://data.qiime2.org/distro/core/qiime2-2019.4-py36-linux-conda.yml |
| 101 | + conda env create -q -n qtp-biom --file qiime2-2019.4-py36-linux-conda.yml |
| 102 | + rm qiime2-2019.4-py36-linux-conda.yml |
| 103 | + export QIITA_SERVER_CERT=`pwd`/qiita_core/support_files/server.crt |
| 104 | + export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test.cfg |
| 105 | + export REDBIOM_HOST="http://localhost:7379" |
| 106 | + conda activate qtp-biom |
| 107 | + pip install -U pip |
| 108 | + pip install https://github.com/qiita-spots/qiita_client/archive/master.zip |
| 109 | + pip install https://github.com/qiita-spots/qtp-biom/archive/master.zip |
| 110 | + configure_biom --env-script "source /home/runner/.profile; conda activate qtp-biom" --server-cert $QIITA_SERVER_CERT |
| 111 | +
|
| 112 | + - name: Starting services |
| 113 | + shell: bash -l {0} |
| 114 | + run: | |
| 115 | + conda activate qiita |
| 116 | + export QIITA_SERVER_CERT=`pwd`/qiita_core/support_files/server.crt |
| 117 | + export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test.cfg |
| 118 | + export REDBIOM_HOST="http://localhost:7379" |
| 119 | +
|
| 120 | + echo "1. Setting up redis" |
| 121 | + redis-server --daemonize yes --port 7777 |
| 122 | + redis-server --daemonize yes --port 6379 |
| 123 | +
|
| 124 | + echo "2. Starting webdis" |
| 125 | + pushd webdis |
| 126 | + ./webdis & |
| 127 | + popd |
| 128 | +
|
| 129 | + echo "3. Starting redbiom: " $REDBIOM_HOST |
| 130 | + curl -s http://localhost:7379/FLUSHALL > /dev/null |
| 131 | + redbiom --version |
| 132 | + redbiom admin scripts-writable |
| 133 | + redbiom admin create-context --name "qiita-test" --description "qiita-test context" |
| 134 | + redbiom admin load-sample-metadata --metadata `pwd`/qiita_db/support_files/test_data/templates/1_19700101-000000.txt |
| 135 | + redbiom admin load-sample-metadata-search --metadata `pwd`/qiita_db/support_files/test_data/templates/1_19700101-000000.txt |
| 136 | + 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 |
| 137 | + 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 |
| 138 | +
|
| 139 | + echo "4. Setting up nginx" |
| 140 | + mkdir -p /usr/share/miniconda/envs/qiita/var/run/nginx/ |
| 141 | + nginx -c ${PWD}/qiita_pet/nginx_example.conf |
| 142 | +
|
| 143 | + echo "5. Setting up qiita" |
| 144 | + conda activate qiita |
| 145 | + qiita-env make --no-load-ontologies |
| 146 | + qiita-test-install |
| 147 | + qiita plugins update |
| 148 | +
|
| 149 | + echo "6. Starting supervisord => multiple qiita instances" |
| 150 | + supervisord -c ${PWD}/qiita_pet/supervisor_example.conf |
| 151 | + sleep 10 |
| 152 | + cat /tmp/supervisord.log |
| 153 | +
|
| 154 | + echo "7. Starting plugins" |
| 155 | + conda deactivate |
| 156 | + conda activate qtp-biom |
| 157 | + export QIITA_CLIENT_DEBUG_LEVEL=DEBUG |
| 158 | + start_biom https://localhost:8383 register ignored |
| 159 | + conda deactivate |
| 160 | +
|
| 161 | + echo "8. Setting up SSH" |
| 162 | + ssh-keygen -t rsa-sha2-256 -b 4096 -N '' -f $PWD/qiita_ware/test/test_data/test_key |
| 163 | + mkdir ~/.ssh/ |
| 164 | + cp $PWD/qiita_ware/test/test_data/test_key* ~/.ssh/ |
| 165 | + cat ~/.ssh/test_key.pub > ~/.ssh/authorized_keys |
| 166 | + chmod 600 $PWD/qiita_ware/test/test_data/test_key* |
| 167 | + chmod 600 ~/.ssh/* |
| 168 | + chmod 700 ~/.ssh/ |
| 169 | + scp -o StrictHostKeyChecking=no -i $PWD/qiita_ware/test/test_data/test_key $USER@localhost:$PWD/qiita_ware/test/test_data/random_key $PWD/qiita_ware/test/test_data/random_key_copy |
| 170 | +
|
| 171 | + - name: Main tests |
| 172 | + shell: bash -l {0} |
| 173 | + env: |
| 174 | + COVER_PACKAGE: ${{ matrix.cover_package }} |
| 175 | + run: | |
| 176 | + conda activate qiita |
| 177 | + export QIITA_SERVER_CERT=`pwd`/qiita_core/support_files/server.crt |
| 178 | + export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test.cfg |
| 179 | + export REDBIOM_HOST="http://localhost:7379" |
| 180 | + nosetests $COVER_PACKAGE --with-doctest --with-coverage --with-timer -v --cover-package=$COVER_PACKAGE -e 'test_submit_EBI_parse_EBI_reply_failure' -e 'test_full_submission' |
| 181 | +
|
| 182 | + # killing the qiita server to run the next commands |
| 183 | + QIITA_PID=`cat /tmp/supervisord.pid` |
| 184 | + kill $QIITA_PID |
| 185 | + sleep 10 |
| 186 | + if [[ "$COVER_PACKAGE" == *"qiita_db"* ]]; then test_data_studies/commands.sh; all-qiita-cron-job; fi |
| 187 | +
|
| 188 | + - uses: codecov/codecov-action@v1 |
| 189 | + with: |
| 190 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 191 | + file: codecov.yml |
| 192 | + |
| 193 | + lint: |
| 194 | + runs-on: ubuntu-latest |
| 195 | + steps: |
| 196 | + - name: flake8 |
| 197 | + uses: actions/setup-python@v2 |
| 198 | + with: |
| 199 | + python-version: 3.6 |
| 200 | + - name: install dependencies |
| 201 | + run: python -m pip install --upgrade pip |
| 202 | + - name: Check out repository code |
| 203 | + uses: actions/checkout@v2 |
| 204 | + - name: lint |
| 205 | + run: | |
| 206 | + pip install -q flake8 |
| 207 | + flake8 qiita_* setup.py scripts/qiita* |
0 commit comments