|
8 | 8 | branches:
|
9 | 9 | - '*'
|
10 | 10 | jobs:
|
11 |
| - build: |
12 |
| - runs-on: ubuntu-latest |
13 |
| - steps: |
| 11 | + Unit_testing: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
14 | 14 | - uses: actions/checkout@v2
|
15 |
| - - uses: actions/setup-node@v2 |
| 15 | + - name: Getting SHA from the default branch |
| 16 | + id: get-sha |
| 17 | + run: | |
| 18 | + URL_get_default_branch="https://api.github.com/repos/${{ github.repository }}" |
| 19 | + DEFAULT_BRANCH=$(curl -s -X GET -G ${URL_get_default_branch} | jq -r '.default_branch') |
| 20 | + URL_get_sha_default_branch="https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${DEFAULT_BRANCH}" |
| 21 | + SHA=$(curl -s -X GET -G ${URL_get_sha_default_branch} | jq .object.sha | tr -d '"') |
| 22 | + echo ::set-output name=default_branch::${DEFAULT_BRANCH} |
| 23 | + echo ::set-output name=sha::${SHA} |
| 24 | + - name: Waiting a cache creation in the default branch |
| 25 | + run: | |
| 26 | + URL_runs="https://api.github.com/repos/${{ github.repository }}/actions/workflows/cache.yml/runs" |
| 27 | + SLEEP=45 |
| 28 | + NUMBER_ATTEMPTS=10 |
| 29 | + while [[ ${NUMBER_ATTEMPTS} -gt 0 ]]; do |
| 30 | + RUN_status=$(curl -s -X GET -G ${URL_runs} | jq -r '.workflow_runs[]? | select((.head_sha == "${{ steps.get-sha.outputs.sha }}") and (.event == "push") and (.name == "Cache") and (.head_branch == "${{ steps.get-sha.outputs.default_branch }}")) | .status') |
| 31 | + if [[ ${RUN_status} == "completed" ]]; then |
| 32 | + echo "The cache creation on the '${{ steps.get-sha.outputs.default_branch }}' branch has finished. Status: ${RUN_status}" |
| 33 | + break |
| 34 | + else |
| 35 | + echo "The creation of the cache is not yet complete." |
| 36 | + echo "There are still attempts to check the cache: ${NUMBER_ATTEMPTS}" |
| 37 | + echo "Status of caching in the '${{ steps.get-sha.outputs.default_branch }}' branch: ${RUN_status}" |
| 38 | + echo "sleep ${SLEEP}" |
| 39 | + sleep ${SLEEP} |
| 40 | + ((NUMBER_ATTEMPTS--)) |
| 41 | + fi |
| 42 | + done |
| 43 | + if [[ ${NUMBER_ATTEMPTS} -eq 0 ]]; then |
| 44 | + echo "Number of attempts expired!" |
| 45 | + echo "Probably the creation of the cache is not yet complete. Will continue working without the cache." |
| 46 | + fi |
| 47 | + - name: Getting CVAT server cache from the default branch |
| 48 | + uses: actions/cache@v2 |
16 | 49 | with:
|
17 |
| - node-version: 12 |
18 |
| - - name: Build CVAT |
| 50 | + path: /tmp/cvat_cache_server |
| 51 | + key: ${{ runner.os }}-build-server-${{ steps.get-sha.outputs.sha }} |
| 52 | + - name: Set up Docker Buildx |
| 53 | + |
| 54 | + - name: Building CVAT server image |
| 55 | + uses: docker/build-push-action@v2 |
| 56 | + with: |
| 57 | + context: . |
| 58 | + file: ./Dockerfile |
| 59 | + cache-from: type=local,src=/tmp/cvat_cache_server |
| 60 | + tags: openvino/cvat_server:latest |
| 61 | + load: true |
| 62 | + - name: Runing unit tests |
19 | 63 | env:
|
20 | 64 | HOST_COVERAGE_DATA_DIR: ${{ github.workspace }}
|
21 |
| - CONTAINER_COVERAGE_DATA_DIR: '/coverage_data' |
22 |
| - DJANGO_SU_NAME: 'admin' |
23 |
| - DJANGO_SU_EMAIL: '[email protected]' |
24 |
| - DJANGO_SU_PASSWORD: '12qwaszx' |
| 65 | + CONTAINER_COVERAGE_DATA_DIR: "/coverage_data" |
25 | 66 | run: |
|
26 |
| - docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.ci.yml build |
27 | 67 | docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'coverage run -a manage.py test cvat/apps utils/cli && mv .coverage ${CONTAINER_COVERAGE_DATA_DIR}'
|
28 | 68 | docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd cvat-data && npm ci && cd ../cvat-core && npm ci && npm run test && mv ./reports/coverage/lcov.info ${CONTAINER_COVERAGE_DATA_DIR} && chmod a+rwx ${CONTAINER_COVERAGE_DATA_DIR}/lcov.info'
|
29 |
| - docker-compose up -d |
30 |
| - docker exec -i cvat /bin/bash -c "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell" |
31 |
| - - name: Code instrumentation |
| 69 | + - name: Uploading code coverage results as an artifact |
| 70 | + if: github.ref == 'refs/heads/develop' |
| 71 | + uses: actions/upload-artifact@v2 |
| 72 | + with: |
| 73 | + name: coverage_results |
| 74 | + path: | |
| 75 | + ${{ github.workspace }}/.coverage |
| 76 | + ${{ github.workspace }}/lcov.info |
| 77 | +
|
| 78 | + E2E_testing: |
| 79 | + runs-on: ubuntu-latest |
| 80 | + strategy: |
| 81 | + fail-fast: false |
| 82 | + matrix: |
| 83 | + specs: ['actions_tasks', 'actions_tasks2', 'actions_tasks3', 'actions_objects', 'actions_objects2', 'actions_users', 'actions_projects', 'canvas3d_functionality', 'issues_prs', 'issues_prs2'] |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v2 |
| 86 | + - name: Getting SHA from the default branch |
| 87 | + id: get-sha |
| 88 | + run: | |
| 89 | + URL_get_default_branch="https://api.github.com/repos/${{ github.repository }}" |
| 90 | + DEFAULT_BRANCH=$(curl -s -X GET -G ${URL_get_default_branch} | jq -r '.default_branch') |
| 91 | + URL_get_sha_default_branch="https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${DEFAULT_BRANCH}" |
| 92 | + SHA=$(curl -s -X GET -G ${URL_get_sha_default_branch} | jq .object.sha | tr -d '"') |
| 93 | + echo ::set-output name=default_branch::${DEFAULT_BRANCH} |
| 94 | + echo ::set-output name=sha::${SHA} |
| 95 | + - name: Waiting a cache creation in the default branch |
| 96 | + run: | |
| 97 | + URL_runs="https://api.github.com/repos/${{ github.repository }}/actions/workflows/cache.yml/runs" |
| 98 | + SLEEP=45 |
| 99 | + NUMBER_ATTEMPTS=10 |
| 100 | + while [[ ${NUMBER_ATTEMPTS} -gt 0 ]]; do |
| 101 | + RUN_status=$(curl -s -X GET -G ${URL_runs} | jq -r '.workflow_runs[]? | select((.head_sha == "${{ steps.get-sha.outputs.sha }}") and (.event == "push") and (.name == "Cache") and (.head_branch == "${{ steps.get-sha.outputs.default_branch }}")) | .status') |
| 102 | + if [[ ${RUN_status} == "completed" ]]; then |
| 103 | + echo "The cache creation on the '${{ steps.get-sha.outputs.default_branch }}' branch has finished. Status: ${RUN_status}" |
| 104 | + break |
| 105 | + else |
| 106 | + echo "The creation of the cache is not yet complete." |
| 107 | + echo "There are still attempts to check the cache: ${NUMBER_ATTEMPTS}" |
| 108 | + echo "Status of caching in the '${{ steps.get-sha.outputs.default_branch }}' branch: ${RUN_status}" |
| 109 | + echo "sleep ${SLEEP}" |
| 110 | + sleep ${SLEEP} |
| 111 | + ((NUMBER_ATTEMPTS--)) |
| 112 | + fi |
| 113 | + done |
| 114 | + if [[ ${NUMBER_ATTEMPTS} -eq 0 ]]; then |
| 115 | + echo "Number of attempts expired!" |
| 116 | + echo "Probably the creation of the cache is not yet complete. Will continue working without the cache." |
| 117 | + fi |
| 118 | + - name: Getting CVAT server cache from the default branch |
| 119 | + uses: actions/cache@v2 |
| 120 | + with: |
| 121 | + path: /tmp/cvat_cache_server |
| 122 | + key: ${{ runner.os }}-build-server-${{ steps.get-sha.outputs.sha }} |
| 123 | + - name: Getting cache CVAT UI from the default branch |
| 124 | + uses: actions/cache@v2 |
| 125 | + with: |
| 126 | + path: /tmp/cvat_cache_ui |
| 127 | + key: ${{ runner.os }}-build-ui-${{ steps.get-sha.outputs.sha }} |
| 128 | + - uses: actions/setup-node@v2 |
| 129 | + with: |
| 130 | + node-version: 12 |
| 131 | + - name: Set up Docker Buildx |
| 132 | + |
| 133 | + - name: Building CVAT server image |
| 134 | + uses: docker/build-push-action@v2 |
| 135 | + with: |
| 136 | + context: . |
| 137 | + file: ./Dockerfile |
| 138 | + cache-from: type=local,src=/tmp/cvat_cache_server |
| 139 | + tags: openvino/cvat_server:latest |
| 140 | + load: true |
| 141 | + - name: Building CVAT UI image |
| 142 | + uses: docker/build-push-action@v2 |
| 143 | + with: |
| 144 | + context: . |
| 145 | + file: ./Dockerfile.ui |
| 146 | + cache-from: type=local,src=/tmp/cvat_cache_ui |
| 147 | + tags: openvino/cvat_ui:latest |
| 148 | + load: true |
| 149 | + - name: Instrumentation of the code then rebuilding the CVAT UI |
| 150 | + if: github.ref == 'refs/heads/develop' |
32 | 151 | run: |
|
33 | 152 | npm ci
|
34 | 153 | npm run coverage
|
35 |
| - docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build |
36 |
| - - name: End-to-end testing |
| 154 | + docker-compose -f docker-compose.yml -f docker-compose.dev.yml build cvat_ui |
| 155 | + - name: Running e2e tests |
| 156 | + env: |
| 157 | + DJANGO_SU_NAME: 'admin' |
| 158 | + DJANGO_SU_EMAIL: '[email protected]' |
| 159 | + DJANGO_SU_PASSWORD: '12qwaszx' |
| 160 | + API_ABOUT_PAGE: "localhost:8080/api/v1/server/about" |
37 | 161 | run: |
|
| 162 | + docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d |
| 163 | + /bin/bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' ${API_ABOUT_PAGE})" != "401" ]]; do sleep 5; done' |
| 164 | + docker exec -i cvat /bin/bash -c "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell" docker exec -i cvat /bin/bash -c "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell" |
38 | 165 | cd ./tests
|
39 | 166 | npm ci
|
40 |
| - npx cypress run --headless --browser chrome |
| 167 | + if [[ ${{ github.ref }} == 'refs/heads/develop' ]]; then |
| 168 | + npx cypress run --headless --browser chrome --spec 'cypress/integration/${{ matrix.specs }}/**/*.js' |
| 169 | + mv ./.nyc_output/out.json ./.nyc_output/out_${{ matrix.specs }}.json |
| 170 | + else |
| 171 | + npx cypress run --headless --browser chrome --env coverage=false --spec 'cypress/integration/${{ matrix.specs }}/**/*.js' |
| 172 | + fi |
| 173 | + - name: Creating a log file from "cvat" container logs |
| 174 | + if: failure() |
| 175 | + run: | |
| 176 | + docker logs cvat > ${{ github.workspace }}/tests/cvat_${{ matrix.specs }}.log |
41 | 177 | - name: Uploading cypress screenshots as an artifact
|
42 | 178 | if: failure()
|
43 | 179 | uses: actions/upload-artifact@v2
|
44 | 180 | with:
|
45 |
| - name: cypress_screenshots |
| 181 | + name: cypress_screenshots_${{ matrix.specs }} |
46 | 182 | path: ${{ github.workspace }}/tests/cypress/screenshots
|
47 |
| - - name: Collect coverage data |
| 183 | + - name: Uploading "cvat" container logs as an artifact |
| 184 | + if: failure() |
| 185 | + uses: actions/upload-artifact@v2 |
| 186 | + with: |
| 187 | + name: cvat_container_logs |
| 188 | + path: ${{ github.workspace }}/tests/cvat_${{ matrix.specs }}.log |
| 189 | + - name: Uploading code coverage results as an artifact |
| 190 | + if: github.ref == 'refs/heads/develop' |
| 191 | + uses: actions/upload-artifact@v2 |
| 192 | + with: |
| 193 | + name: coverage_results |
| 194 | + path: ${{ github.workspace }}/tests/.nyc_output |
| 195 | + |
| 196 | + Coveralls: |
| 197 | + if: github.ref == 'refs/heads/develop' |
| 198 | + runs-on: ubuntu-latest |
| 199 | + needs: [Unit_testing, E2E_testing] |
| 200 | + steps: |
| 201 | + - uses: actions/checkout@v2 |
| 202 | + - name: Geting SHA from the default branch |
| 203 | + id: get-sha |
| 204 | + run: | |
| 205 | + URL_get_default_branch="https://api.github.com/repos/${{ github.repository }}" |
| 206 | + DEFAULT_BRANCH=$(curl -s -X GET -G ${URL_get_default_branch} | jq -r '.default_branch') |
| 207 | + URL_get_sha_default_branch="https://api.github.com/repos/${{ github.repository }}/git/ref/heads/${DEFAULT_BRANCH}" |
| 208 | + SHA=$(curl -s -X GET -G ${URL_get_sha_default_branch} | jq .object.sha | tr -d '"') |
| 209 | + echo ::set-output name=sha::${SHA} |
| 210 | + - name: Getting CVAT server cache from the default branch |
| 211 | + uses: actions/cache@v2 |
| 212 | + with: |
| 213 | + path: /tmp/cvat_cache_server |
| 214 | + key: ${{ runner.os }}-build-server-${{ steps.get-sha.outputs.sha }} |
| 215 | + - name: Set up Docker Buildx |
| 216 | + |
| 217 | + - name: Building CVAT server image |
| 218 | + uses: docker/build-push-action@v2 |
| 219 | + with: |
| 220 | + context: . |
| 221 | + file: ./Dockerfile |
| 222 | + cache-from: type=local,src=/tmp/cvat_cache_server |
| 223 | + tags: openvino/cvat_server:latest |
| 224 | + load: true |
| 225 | + - name: Downloading coverage results |
| 226 | + uses: actions/download-artifact@v2 |
| 227 | + with: |
| 228 | + name: coverage_results |
| 229 | + - name: Combining coverage results |
| 230 | + run: | |
| 231 | + mkdir -p ./nyc_output_tmp |
| 232 | + mv ./out_*.json ./nyc_output_tmp |
| 233 | + mkdir -p ./.nyc_output |
| 234 | + npm ci |
| 235 | + npx nyc merge ./nyc_output_tmp ./.nyc_output/out.json |
| 236 | + - name: Sending results to Coveralls |
48 | 237 | env:
|
49 | 238 | HOST_COVERAGE_DATA_DIR: ${{ github.workspace }}
|
50 | 239 | CONTAINER_COVERAGE_DATA_DIR: "/coverage_data"
|
51 | 240 | COVERALLS_SERVICE_NAME: github
|
52 | 241 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
53 | 242 | run: |
|
54 |
| - mv ./tests/.nyc_output ./ |
55 |
| - npx nyc report --reporter=text-lcov >> ${HOST_COVERAGE_DATA_DIR}/lcov.info |
56 |
| - docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd ${CONTAINER_COVERAGE_DATA_DIR} && coveralls-lcov -v -n lcov.info > ${CONTAINER_COVERAGE_DATA_DIR}/coverage.json' |
57 |
| - docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'ln -s ${CONTAINER_COVERAGE_DATA_DIR}/.git . && ln -s ${CONTAINER_COVERAGE_DATA_DIR}/.coverage . && ln -s ${CONTAINER_COVERAGE_DATA_DIR}/coverage.json . && coveralls --merge=coverage.json' |
| 243 | + npx nyc report --reporter=text-lcov >> ${HOST_COVERAGE_DATA_DIR}/lcov.info |
| 244 | + docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd ${CONTAINER_COVERAGE_DATA_DIR} && coveralls-lcov -v -n lcov.info > ${CONTAINER_COVERAGE_DATA_DIR}/coverage.json' |
| 245 | + docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'ln -s ${CONTAINER_COVERAGE_DATA_DIR}/.git . && ln -s ${CONTAINER_COVERAGE_DATA_DIR}/.coverage . && ln -s ${CONTAINER_COVERAGE_DATA_DIR}/coverage.json . && coveralls --merge=coverage.json' |
0 commit comments