CI: refactor cache, add coverage for CI-nightly (#79)

main
Kirill Sizov 4 years ago committed by GitHub
parent e33d97ec9d
commit 2db5bcf7b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,23 +6,60 @@ on:
jobs: jobs:
Caching_CVAT: Caching_CVAT:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/cache@v2
- name: Getting SHA with cache from the default branch
id: get-sha
run: |
DEFAULT_BRANCH=$(gh api /repos/$REPO | jq -r '.default_branch')
for sha in $(gh api "/repos/$REPO/commits?per_page=100&sha=${DEFAULT_BRANCH}" | jq -r '.[].sha');
do
RUN_status=$(gh api /repos/${REPO}/actions/workflows/cache.yml/runs | \
jq -r ".workflow_runs[]? | select((.head_sha == \"${sha}\") and (.conclusion == \"success\")) | .status")
if [[ ${RUN_status} == "completed" ]]; then
SHA=$sha
break
fi
done
echo Default branch is ${DEFAULT_BRANCH}
echo Workflow will try to get cache from commit: ${SHA}
echo ::set-output name=default_branch::${DEFAULT_BRANCH}
echo ::set-output name=sha::${SHA}
- uses: actions/cache@v3
id: server-cache-action
with: with:
path: /tmp/cvat_cache_server path: /tmp/cvat_cache_server
key: ${{ runner.os }}-build-server-${{ github.sha }} key: ${{ runner.os }}-build-server-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-build-server-${{ steps.get-sha.outputs.sha }}
${{ runner.os }}-build-server- ${{ runner.os }}-build-server-
- uses: actions/cache@v2 - uses: actions/cache@v3
id: ui-cache-action
with: with:
path: /tmp/cvat_cache_ui path: /tmp/cvat_cache_ui
key: ${{ runner.os }}-build-ui-${{ github.sha }} key: ${{ runner.os }}-build-ui-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-build-ui-${{ steps.get-sha.outputs.sha }}
${{ runner.os }}-build-ui- ${{ runner.os }}-build-ui-
- name: Check cache hit
if: steps.server-cache-action.outputs.cache-hit != 'false' ||
steps.ui-cache-action.outputs.cache-hit != 'false'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Caching failed due to a cache hit occurred')
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2

@ -12,7 +12,7 @@ on:
- '**/*.md' - '**/*.md'
jobs: jobs:
cache: search_cache:
if: | if: |
github.event.pull_request.draft == false && github.event.pull_request.draft == false &&
!startsWith(github.event.pull_request.title, '[WIP]') && !startsWith(github.event.pull_request.title, '[WIP]') &&
@ -24,47 +24,29 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
steps: steps:
- name: Getting SHA from the default branch - name: Getting SHA with cache from the default branch
id: get-sha id: get-sha
run: | run: |
DEFAULT_BRANCH=$(gh api /repos/$REPO | jq -r '.default_branch') DEFAULT_BRANCH=$(gh api /repos/$REPO | jq -r '.default_branch')
SHA=$(gh api /repos/$REPO/git/ref/heads/$DEFAULT_BRANCH | jq -r '.object.sha') for sha in $(gh api "/repos/$REPO/commits?per_page=100&sha=$DEFAULT_BRANCH" | jq -r '.[].sha');
do
echo ::set-output name=default_branch::${DEFAULT_BRANCH}
echo ::set-output name=sha::${SHA}
- name: Waiting a cache creation in the default branch
env:
DEFAULT_BRANCH: ${{ steps.get-sha.outputs.default_branch }}
SHA: ${{ steps.get-sha.outputs.sha }}
run: |
SLEEP=45
NUMBER_ATTEMPTS=10
while [[ ${NUMBER_ATTEMPTS} -gt 0 ]]; do
RUN_status=$(gh api /repos/${REPO}/actions/workflows/cache.yml/runs | \ RUN_status=$(gh api /repos/${REPO}/actions/workflows/cache.yml/runs | \
jq -r ".workflow_runs[]? | jq -r ".workflow_runs[]? | select((.head_sha == \"${sha}\") and (.conclusion == \"success\")) | .status")
select((.head_sha == \"${SHA}\")) | .status")
if [[ ${RUN_status} == "completed" ]]; then if [[ ${RUN_status} == "completed" ]]; then
echo "The cache creation on the ${DEFAULT_BRANCH} branch has finished. Status: ${RUN_status}" SHA=$sha
break break
else
echo "The creation of the cache is not yet complete."
echo "There are still attempts to check the cache: ${NUMBER_ATTEMPTS}"
echo "Status of caching in the ${DEFAULT_BRANCH} branch: ${RUN_status}"
echo "sleep ${SLEEP}"
sleep ${SLEEP}
((NUMBER_ATTEMPTS--))
fi fi
done done
if [[ ${NUMBER_ATTEMPTS} -eq 0 ]]; then
echo "Number of attempts expired!" echo Default branch is ${DEFAULT_BRANCH}
echo "Probably the creation of the cache is not yet complete. Will continue working without the cache." echo Workflow will try to get cache from commit: ${SHA}
fi
echo ::set-output name=default_branch::${DEFAULT_BRANCH}
echo ::set-output name=sha::${SHA}
Unit_testing: Unit_testing:
needs: cache needs: search_cache
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -74,16 +56,16 @@ jobs:
python-version: '3.8' python-version: '3.8'
- name: Getting CVAT server cache from the default branch - name: Getting CVAT server cache from the default branch
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: /tmp/cvat_cache_server path: /tmp/cvat_cache_server
key: ${{ runner.os }}-build-server-${{ needs.cache.outputs.sha }} key: ${{ runner.os }}-build-server-${{ needs.search_cache.outputs.sha }}
- name: Getting CVAT UI cache from the default branch - name: Getting CVAT UI cache from the default branch
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: /tmp/cvat_cache_ui path: /tmp/cvat_cache_ui
key: ${{ runner.os }}-build-ui-${{ needs.cache.outputs.sha }} key: ${{ runner.os }}-build-ui-${{ needs.search_cache.outputs.sha }}
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@master uses: docker/setup-buildx-action@master
@ -123,23 +105,37 @@ jobs:
HOST_COVERAGE_DATA_DIR: ${{ github.workspace }} HOST_COVERAGE_DATA_DIR: ${{ github.workspace }}
CONTAINER_COVERAGE_DATA_DIR: "/coverage_data" CONTAINER_COVERAGE_DATA_DIR: "/coverage_data"
run: | run: |
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d cvat_opa
max_tries=12
while [[ $(curl -s -o /dev/null -w "%{http_code}" localhost:8181/health) != "200" && max_tries -gt 0 ]]; do (( max_tries-- )); sleep 5; done
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.ci.yml run cvat_ci /bin/bash \ 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 cvat-cli -k 'tasks_id' -k 'lambda' -k 'share' && mv .coverage ${CONTAINER_COVERAGE_DATA_DIR}' -c 'python manage.py test cvat/apps cvat-cli -k tasks_id -k lambda -k share -v 2'
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.ci.yml run cvat_ci /bin/bash \ 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 --ignore-scripts && cd ../cvat-core && npm ci --ignore-scripts && npm run test && mv ./reports/coverage/lcov.info ${CONTAINER_COVERAGE_DATA_DIR} && chmod a+rwx ${CONTAINER_COVERAGE_DATA_DIR}/lcov.info' -c 'cd cvat-data && npm ci --ignore-scripts && cd ../cvat-core && npm ci --ignore-scripts && npm run test'
- name: Creating a log file from "cvat_opa" container logs
if: failure()
env:
LOGS_DIR: "${{ github.workspace }}/unit_testing"
run: |
mkdir $LOGS_DIR
docker logs cvat > $LOGS_DIR/cvat.log
docker logs cvat_opa 2> $LOGS_DIR/cvat_opa.log
- name: Uploading code coverage results as an artifact - name: Uploading "cvat" container logs as an artifact
if: github.ref == 'refs/heads/develop' if: failure()
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
env:
LOGS_DIR: "${{ github.workspace }}/unit_testing"
with: with:
name: coverage_results name: cvat_container_logs
path: | path: $LOGS_DIR
${{ github.workspace }}/.coverage
${{ github.workspace }}/lcov.info
E2E_testing: E2E_testing:
needs: cache needs: search_cache
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false fail-fast: false
@ -149,16 +145,16 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Getting CVAT server cache from the default branch - name: Getting CVAT server cache from the default branch
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: /tmp/cvat_cache_server path: /tmp/cvat_cache_server
key: ${{ runner.os }}-build-server-${{ needs.cache.outputs.sha }} key: ${{ runner.os }}-build-server-${{ needs.search_cache.outputs.sha }}
- name: Getting CVAT UI cache from the default branch - name: Getting CVAT UI cache from the default branch
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: /tmp/cvat_cache_ui path: /tmp/cvat_cache_ui
key: ${{ runner.os }}-build-ui-${{ needs.cache.outputs.sha }} key: ${{ runner.os }}-build-ui-${{ needs.search_cache.outputs.sha }}
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
@ -185,14 +181,7 @@ jobs:
tags: openvino/cvat_ui:latest tags: openvino/cvat_ui:latest
load: true load: true
- name: Instrumentation of the code then rebuilding the CVAT UI - name: Run CVAT instance
if: github.ref == 'refs/heads/develop'
run: |
npm ci
npm run coverage
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f components/serverless/docker-compose.serverless.yml build cvat_ui
- name: Run CVAT instance for E2E testing
run: | run: |
docker-compose \ docker-compose \
-f docker-compose.yml \ -f docker-compose.yml \
@ -238,13 +227,6 @@ jobs:
run: | run: |
docker logs cvat > ${{ github.workspace }}/tests/cvat_${{ matrix.specs }}.log docker logs cvat > ${{ github.workspace }}/tests/cvat_${{ matrix.specs }}.log
- name: Uploading cypress screenshots as an artifact
if: failure()
uses: actions/upload-artifact@v2
with:
name: cypress_screenshots_${{ matrix.specs }}
path: ${{ github.workspace }}/tests/cypress/screenshots
- name: Uploading "cvat" container logs as an artifact - name: Uploading "cvat" container logs as an artifact
if: failure() if: failure()
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
@ -252,70 +234,9 @@ jobs:
name: cvat_container_logs name: cvat_container_logs
path: ${{ github.workspace }}/tests/cvat_${{ matrix.specs }}.log path: ${{ github.workspace }}/tests/cvat_${{ matrix.specs }}.log
- name: Uploading code coverage results as an artifact - name: Uploading cypress screenshots as an artifact
if: github.ref == 'refs/heads/develop' if: failure()
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: coverage_results name: cypress_screenshots_${{ matrix.specs }}
path: ${{ github.workspace }}/tests/.nyc_output path: ${{ github.workspace }}/tests/cypress/screenshots
Coveralls:
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
needs: [Unit_testing, E2E_testing]
steps:
- uses: actions/checkout@v2
- name: Getting SHA from the default branch
id: get-sha
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
DEFAULT_BRANCH=$(gh api /repos/$REPO | jq -r '.default_branch')
SHA=$(gh api /repos/$REPO/git/ref/heads/$DEFAULT_BRANCH | jq -r '.object.sha')
echo ::set-output name=default_branch::${DEFAULT_BRANCH}
echo ::set-output name=sha::${SHA}
- name: Getting CVAT server cache from the default branch
uses: actions/cache@v2
with:
path: /tmp/cvat_cache_server
key: ${{ runner.os }}-build-server-${{ steps.get-sha.outputs.sha }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1.1.2
- name: Building CVAT server image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
cache-from: type=local,src=/tmp/cvat_cache_server
tags: openvino/cvat_server:latest
load: true
- name: Downloading coverage results
uses: actions/download-artifact@v2
with:
name: coverage_results
- name: Combining coverage results
run: |
mkdir -p ./nyc_output_tmp
mv ./out_*.json ./nyc_output_tmp
mkdir -p ./.nyc_output
npm ci
npx nyc merge ./nyc_output_tmp ./.nyc_output/out.json
- name: Sending results to Coveralls
env:
HOST_COVERAGE_DATA_DIR: ${{ github.workspace }}
CONTAINER_COVERAGE_DATA_DIR: "/coverage_data"
COVERALLS_SERVICE_NAME: github
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx nyc report --reporter=text-lcov >> ${HOST_COVERAGE_DATA_DIR}/lcov.info
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'
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'

@ -6,14 +6,14 @@ on:
jobs: jobs:
check_updates: check_updates:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs: outputs:
last_commit_time: ${{ steps.check_updates.outputs.last_commit_time }} last_commit_time: ${{ steps.check_updates.outputs.last_commit_time }}
last_night_time: ${{ steps.check_updates.outputs.last_night_time }} last_night_time: ${{ steps.check_updates.outputs.last_night_time }}
steps: steps:
- id: check_updates - id: check_updates
env:
REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
default_branch=$(gh api /repos/$REPO | jq -r '.default_branch') default_branch=$(gh api /repos/$REPO | jq -r '.default_branch')
@ -32,7 +32,7 @@ jobs:
echo ::set-output name=last_commit_time::${last_commit_time} echo ::set-output name=last_commit_time::${last_commit_time}
echo ::set-output name=last_night_time::${last_night_time} echo ::set-output name=last_night_time::${last_night_time}
cache: search_cache:
needs: check_updates needs: check_updates
if: if:
needs.check_updates.outputs.last_commit_time > needs.check_updates.outputs.last_night_time needs.check_updates.outputs.last_commit_time > needs.check_updates.outputs.last_night_time
@ -43,48 +43,29 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
steps: steps:
- name: Getting SHA from the default branch - name: Getting SHA with cache from the default branch
id: get-sha id: get-sha
run: | run: |
DEFAULT_BRANCH=$(gh api /repos/$REPO | jq -r '.default_branch') DEFAULT_BRANCH=$(gh api /repos/$REPO | jq -r '.default_branch')
SHA=$(gh api /repos/$REPO/git/ref/heads/$DEFAULT_BRANCH | jq -r '.object.sha') for sha in $(gh api "/repos/$REPO/commits?per_page=100&sha=$DEFAULT_BRANCH" | jq -r '.[].sha');
do
echo ::set-output name=default_branch::${DEFAULT_BRANCH}
echo ::set-output name=sha::${SHA}
- name: Waiting a cache creation in the default branch
if: ${{ github.ref_name != 'develop' }}
env:
DEFAULT_BRANCH: ${{ steps.get-sha.outputs.default_branch }}
SHA: ${{ steps.get-sha.outputs.sha }}
run: |
SLEEP=45
NUMBER_ATTEMPTS=10
while [[ ${NUMBER_ATTEMPTS} -gt 0 ]]; do
RUN_status=$(gh api /repos/${REPO}/actions/workflows/cache.yml/runs | \ RUN_status=$(gh api /repos/${REPO}/actions/workflows/cache.yml/runs | \
jq -r ".workflow_runs[]? | jq -r ".workflow_runs[]? | select((.head_sha == \"${sha}\") and (.conclusion == \"success\")) | .status")
select((.head_sha == \"${SHA}\")) | .status")
if [[ ${RUN_status} == "completed" ]]; then if [[ ${RUN_status} == "completed" ]]; then
echo "The cache creation on the ${DEFAULT_BRANCH} branch has finished. Status: ${RUN_status}" SHA=$sha
break break
else
echo "The creation of the cache is not yet complete."
echo "There are still attempts to check the cache: ${NUMBER_ATTEMPTS}"
echo "Status of caching in the ${DEFAULT_BRANCH} branch: ${RUN_status}"
echo "sleep ${SLEEP}"
sleep ${SLEEP}
((NUMBER_ATTEMPTS--))
fi fi
done done
if [[ ${NUMBER_ATTEMPTS} -eq 0 ]]; then
echo "Number of attempts expired!" echo Default branch is ${DEFAULT_BRANCH}
echo "Probably the creation of the cache is not yet complete. Will continue working without the cache." echo Workflow will try to get cache from commit: ${SHA}
fi
echo ::set-output name=default_branch::${DEFAULT_BRANCH}
echo ::set-output name=sha::${SHA}
run_tests: run_tests:
needs: cache needs: search_cache
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -98,16 +79,16 @@ jobs:
python-version: '3.8' python-version: '3.8'
- name: Getting CVAT server cache from the default branch - name: Getting CVAT server cache from the default branch
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: /tmp/cvat_cache_server path: /tmp/cvat_cache_server
key: ${{ runner.os }}-build-server-${{ needs.cache.outputs.sha }} key: ${{ runner.os }}-build-server-${{ needs.search_cache.outputs.sha }}
- name: Getting CVAT UI cache from the default branch - name: Getting CVAT UI cache from the default branch
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: /tmp/cvat_cache_ui path: /tmp/cvat_cache_ui
key: ${{ runner.os }}-build-ui-${{ needs.cache.outputs.sha }} key: ${{ runner.os }}-build-ui-${{ needs.search_cache.outputs.sha }}
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
@ -130,17 +111,43 @@ jobs:
tags: openvino/cvat_ui:latest tags: openvino/cvat_ui:latest
load: true load: true
- name: Running REST API tests - name: OPA tests
run: |
curl -L -o opa https://openpolicyagent.org/downloads/v0.34.2/opa_linux_amd64_static
chmod +x ./opa
./opa test cvat/apps/iam/rules
- name: REST API tests
run: | run: |
pip3 install --user -r tests/rest_api/requirements.txt pip3 install --user -r tests/rest_api/requirements.txt
pytest tests/rest_api/ pytest tests/rest_api/
pytest tests/rest_api/ --stop-services pytest tests/rest_api/ --stop-services
- name: Run CVAT - name: Unit tests
env:
HOST_COVERAGE_DATA_DIR: ${{ github.workspace }}
CONTAINER_COVERAGE_DATA_DIR: "/coverage_data"
run: |
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 cvat-cli && mv .coverage ${CONTAINER_COVERAGE_DATA_DIR}'
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 --ignore-scripts && cd ../cvat-core && npm ci --ignore-scripts && npm run test && mv ./reports/coverage/lcov.info ${CONTAINER_COVERAGE_DATA_DIR} && chmod a+rwx ${CONTAINER_COVERAGE_DATA_DIR}/lcov.info'
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f docker-compose.ci.yml down -v
- name: Instrumentation of the code then rebuilding the CVAT UI
run: |
npm ci
npm run coverage
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f components/serverless/docker-compose.serverless.yml build cvat_ui
- name: End-to-end. Run CVAT instance
run: | run: |
docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f ./tests/docker-compose.email.yml -f tests/docker-compose.file_share.yml -f components/serverless/docker-compose.serverless.yml up -d --build docker-compose -f docker-compose.yml -f docker-compose.dev.yml -f ./tests/docker-compose.email.yml -f tests/docker-compose.file_share.yml -f components/serverless/docker-compose.serverless.yml up -d
- name: Waiting for server - name: End-to-end. Waiting for server
id: wait-server
env: env:
API_ABOUT_PAGE: "localhost:8080/api/server/about" API_ABOUT_PAGE: "localhost:8080/api/server/about"
run: | run: |
@ -160,8 +167,16 @@ jobs:
echo Response from server is incorrect, output: echo Response from server is incorrect, output:
cat /tmp/server_response cat /tmp/server_response
fi fi
echo ::set-output name=status_code::${status_code}
- name: Add user for tests - name: Fail on bad response from server
if: steps.wait-server.outputs.status_code != '401'
uses: actions/github-script@v3
with:
script: |
core.setFailed('Workflow failed: incorrect response from server. See logs artifact to get more info')
- name: End-to-end. Add user for tests
env: env:
DJANGO_SU_NAME: "admin" DJANGO_SU_NAME: "admin"
DJANGO_SU_EMAIL: "admin@localhost.company" DJANGO_SU_EMAIL: "admin@localhost.company"
@ -169,19 +184,19 @@ jobs:
run: | run: |
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"
- name: End-to-end testing - name: End-to-end. Run tests
run: | run: |
cd ./tests cd ./tests
npm ci npm ci
npm run cypress:run:firefox npm run cypress:run:chrome
mv ./.nyc_output/out.json ./.nyc_output/out_2d.json
npm run cypress:run:chrome:canvas3d
mv ./.nyc_output/out.json ./.nyc_output/out_3d.json
- name: Unit tests - name: Creating a log file from "cvat" container logs
if: failure()
run: | run: |
python manage.py test cvat/apps utils/cli docker logs cvat > ${{ github.workspace }}/tests/cvat.log
npm ci
cd cvat-core
npm run test
- name: Uploading cypress screenshots as an artifact - name: Uploading cypress screenshots as an artifact
if: failure() if: failure()
@ -189,3 +204,81 @@ jobs:
with: with:
name: cypress_screenshots name: cypress_screenshots
path: ${{ github.workspace }}/tests/cypress/screenshots path: ${{ github.workspace }}/tests/cypress/screenshots
- name: Uploading "cvat" container logs as an artifact
if: failure()
uses: actions/upload-artifact@v2
with:
name: cvat_container_logs
path: ${{ github.workspace }}/tests/cvat.log
- name: Uploading code coverage results as an artifact
uses: actions/upload-artifact@v2
with:
name: coverage_results
path: |
${{ github.workspace }}/tests/.nyc_output
${{ github.workspace }}/.coverage
${{ github.workspace }}/lcov.info
coveralls:
runs-on: ubuntu-latest
needs: run_tests
steps:
- uses: actions/checkout@v2
- name: Getting CVAT server cache from the default branch
uses: actions/cache@v3
with:
path: /tmp/cvat_cache_server
key: ${{ runner.os }}-build-server-${{ needs.search_cache.outputs.sha }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1.1.2
- name: Building CVAT server image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
cache-from: type=local,src=/tmp/cvat_cache_server
tags: openvino/cvat_server:latest
load: true
- name: Downloading coverage results
uses: actions/download-artifact@v2
with:
name: coverage_results
- name: Combining coverage results
run: |
mkdir -p ./nyc_output_tmp
mv ./out_*.json ./nyc_output_tmp
mkdir -p ./.nyc_output
npm ci
npx nyc merge ./nyc_output_tmp ./.nyc_output/out.json
- name: Sending results to Coveralls
env:
HOST_COVERAGE_DATA_DIR: ${{ github.workspace }}
CONTAINER_COVERAGE_DATA_DIR: "/coverage_data"
COVERALLS_SERVICE_NAME: github
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx nyc report --reporter=text-lcov >> ${HOST_COVERAGE_DATA_DIR}/lcov.info
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'
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'

@ -3,4 +3,4 @@ version: '3.3'
services: services:
cvat: cvat:
environment: environment:
DJANGO_SETTINGS_MODULE: tests.email_settings DJANGO_SETTINGS_MODULE: cvat.settings.email_settings

@ -1,8 +1,8 @@
{ {
"scripts": { "scripts": {
"cypress:run:chrome": "cypress run --env coverage=false --browser chrome", "cypress:run:chrome": "cypress run --browser chrome",
"cypress:run:firefox": "cypress run --env coverage=false --browser firefox --config-file cypress_cron_type.json", "cypress:run:firefox": "cypress run --browser firefox --config-file nightly_cypress.json",
"cypress:run:chrome:canvas3d": "cypress run --headed --browser chrome --env coverage=false --config-file cypress_canvas3d.json" "cypress:run:chrome:canvas3d": "cypress run --headed --browser chrome --config-file cypress_canvas3d.json"
}, },
"dependencies": { "dependencies": {
"@cypress/code-coverage": "^3.9.10", "@cypress/code-coverage": "^3.9.10",

Loading…
Cancel
Save