You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
308 lines
11 KiB
YAML
308 lines
11 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'master'
|
|
- 'develop'
|
|
pull_request:
|
|
types: [edited, ready_for_review, opened, synchronize, reopened]
|
|
|
|
env:
|
|
API_ABOUT_PAGE: "localhost:8080/api/server/about"
|
|
|
|
jobs:
|
|
cache:
|
|
if: |
|
|
github.event.pull_request.draft == false &&
|
|
!startsWith(github.event.pull_request.title, '[WIP]') &&
|
|
!startsWith(github.event.pull_request.title, '[Dependent]')
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
sha: ${{ steps.get-sha.outputs.sha}}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REPO: ${{ github.repository }}
|
|
steps:
|
|
- name: Getting SHA from the default branch
|
|
id: get-sha
|
|
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: 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 | \
|
|
jq -r ".workflow_runs[]? |
|
|
select((.head_sha == \"${SHA}\")) | .status")
|
|
|
|
if [[ ${RUN_status} == "completed" ]]; then
|
|
echo "The cache creation on the ${DEFAULT_BRANCH} branch has finished. Status: ${RUN_status}"
|
|
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
|
|
done
|
|
if [[ ${NUMBER_ATTEMPTS} -eq 0 ]]; then
|
|
echo "Number of attempts expired!"
|
|
echo "Probably the creation of the cache is not yet complete. Will continue working without the cache."
|
|
fi
|
|
|
|
Unit_testing:
|
|
needs: cache
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-python@v2
|
|
with:
|
|
python-version: '3.8'
|
|
|
|
- name: Getting CVAT server cache from the default branch
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/cvat_cache_server
|
|
key: ${{ runner.os }}-build-server-${{ needs.cache.outputs.sha }}
|
|
|
|
- name: Getting CVAT UI cache from the default branch
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/cvat_cache_ui
|
|
key: ${{ runner.os }}-build-ui-${{ needs.cache.outputs.sha }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@master
|
|
|
|
- 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: Building CVAT UI image
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.ui
|
|
cache-from: type=local,src=/tmp/cvat_cache_ui
|
|
tags: openvino/cvat_ui:latest
|
|
load: true
|
|
|
|
- name: Running 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: Running REST API tests
|
|
run: |
|
|
pip3 install --user -r tests/rest_api/requirements.txt
|
|
pytest tests/rest_api/ -k 'GET' -s
|
|
pytest tests/rest_api/ --stop-services
|
|
|
|
- name: Running 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 -k 'tasks_id' -k 'lambda' -k 'share' && 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'
|
|
|
|
- name: Uploading code coverage results as an artifact
|
|
if: github.ref == 'refs/heads/develop'
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: coverage_results
|
|
path: |
|
|
${{ github.workspace }}/.coverage
|
|
${{ github.workspace }}/lcov.info
|
|
|
|
E2E_testing:
|
|
needs: cache
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
specs: ['canvas3d_functionality', 'actions']
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Getting CVAT server cache from the default branch
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/cvat_cache_server
|
|
key: ${{ runner.os }}-build-server-${{ needs.cache.outputs.sha }}
|
|
|
|
- name: Getting CVAT UI cache from the default branch
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/cvat_cache_ui
|
|
key: ${{ runner.os }}-build-ui-${{ needs.cache.outputs.sha }}
|
|
|
|
- uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '16.x'
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@master
|
|
|
|
- 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: Building CVAT UI image
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.ui
|
|
cache-from: type=local,src=/tmp/cvat_cache_ui
|
|
tags: openvino/cvat_ui:latest
|
|
load: true
|
|
|
|
- name: Instrumentation of the code then rebuilding the CVAT UI
|
|
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: Running e2e tests
|
|
env:
|
|
DJANGO_SU_NAME: 'admin'
|
|
DJANGO_SU_EMAIL: 'admin@localhost.company'
|
|
DJANGO_SU_PASSWORD: '12qwaszx'
|
|
run: |
|
|
docker-compose \
|
|
-f docker-compose.yml \
|
|
-f docker-compose.dev.yml \
|
|
-f components/serverless/docker-compose.serverless.yml \
|
|
-f tests/docker-compose.file_share.yml up -d
|
|
|
|
/bin/bash -c \
|
|
'while [[ $(curl -s -o /dev/null -w "%{http_code}" ${{ env.API_ABOUT_PAGE }}) != "401" ]]; do sleep 5; done'
|
|
|
|
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"
|
|
|
|
cd ./tests
|
|
npm ci
|
|
|
|
if [ ${{ matrix.specs }} == 'canvas3d_functionality' ]; then
|
|
npx cypress run --headed --browser chrome --config-file pr_cypress_canvas3d.json
|
|
else
|
|
npx cypress run --browser chrome --config-file pr_cypress.json
|
|
fi
|
|
|
|
- name: Creating a log file from "cvat" container logs
|
|
if: failure()
|
|
run: |
|
|
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
|
|
if: failure()
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: cvat_container_logs
|
|
path: ${{ github.workspace }}/tests/cvat_${{ matrix.specs }}.log
|
|
|
|
- name: Uploading code coverage results as an artifact
|
|
if: github.ref == 'refs/heads/develop'
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: coverage_results
|
|
path: ${{ github.workspace }}/tests/.nyc_output
|
|
|
|
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'
|