diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000000..d843e4cc7d72 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,51 @@ +name: CI +on: + push: + branches: + - 'master' + - 'develop' + pull_request: + branches: + - '*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12 + - name: Build CVAT + env: + HOST_COVERAGE_DATA_DIR: ${{ github.workspace }} + CONTAINER_COVERAGE_DATA_DIR: '/coverage_data' + DJANGO_SU_NAME: 'admin' + DJANGO_SU_EMAIL: 'admin@localhost.company' + DJANGO_SU_PASSWORD: '12qwaszx' + run: | + docker-compose -f docker-compose.yml -f docker-compose.ci.yml build + docker-compose -f docker-compose.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}' + docker-compose -f docker-compose.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' + docker-compose up -d + 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: Code instrumentation + run: | + npm ci + npm run coverage + docker-compose up -d --build + - name: End-to-end testing + run: | + cd ./tests + npm ci + npx cypress run --headless --browser chrome + - name: Collect coverage data + env: + HOST_COVERAGE_DATA_DIR: ${{ github.workspace }} + CONTAINER_COVERAGE_DATA_DIR: "/coverage_data" + COVERALLS_SERVICE_NAME: github + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + mv ./tests/.nyc_output ./ + npx nyc report --reporter=text-lcov >> ${HOST_COVERAGE_DATA_DIR}/lcov.info + 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' + 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' diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml new file mode 100644 index 000000000000..16b7e9aba8de --- /dev/null +++ b/.github/workflows/schedule.yml @@ -0,0 +1,28 @@ +name: CI-nightly +on: + schedule: + - cron: '0 22 * * *' + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12 + - name: Build CVAT + env: + DJANGO_SU_NAME: "admin" + DJANGO_SU_EMAIL: "admin@localhost.company" + DJANGO_SU_PASSWORD: "12qwaszx" + API_ABOUT_PAGE: "localhost:8080/api/v1/server/about" + run: | + docker-compose -f docker-compose.yml -f ./tests/docker-compose.email.yml up -d --build + /bin/bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' ${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" + - name: End-to-end testing + run: | + cd ./tests + npm ci + npm run cypress:run:firefox diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cc72db8c4ebe..000000000000 --- a/.travis.yml +++ /dev/null @@ -1,57 +0,0 @@ -language: generic -dist: focal - -cache: - npm: true - directories: - - ~/.cache - -addons: - firefox: 'latest' - chrome: stable - apt: - packages: - - libgconf-2-4 - -services: - - docker - -env: - - CONTAINER_COVERAGE_DATA_DIR="/coverage_data" - HOST_COVERAGE_DATA_DIR="${TRAVIS_BUILD_DIR}" - DJANGO_SU_NAME="admin" - DJANGO_SU_EMAIL="admin@localhost.company" - DJANGO_SU_PASSWORD="12qwaszx" - NODE_VERSION="12" - API_ABOUT_PAGE="localhost:8080/api/v1/server/about" - -before_install: - - nvm install ${NODE_VERSION} - -before_script: - - chmod a+rwx ${HOST_COVERAGE_DATA_DIR} - -script: - - if [[ $TRAVIS_EVENT_TYPE == "cron" && $TRAVIS_BRANCH == "develop" ]]; - then - docker-compose -f docker-compose.yml -f ./tests/docker-compose.email.yml up -d --build; - bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' ${API_ABOUT_PAGE})" != "401" ]]; do sleep 5; done'; - docker exec -it cvat bash -ic "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 install && npm run cypress:run:firefox; exit $?; - fi; - - docker-compose -f docker-compose.yml -f docker-compose.ci.yml build - - docker-compose -f docker-compose.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}' - - docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd cvat-data && npm install && cd ../cvat-core && npm install && npm run test && mv ./reports/coverage/lcov.info ${CONTAINER_COVERAGE_DATA_DIR} && chmod a+rwx ${CONTAINER_COVERAGE_DATA_DIR}/lcov.info' - - docker-compose up -d - - docker exec -it cvat bash -ic "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" - # End-to-end testing - - npm install && npm run coverage - - docker-compose up -d --build - - cd ./tests && npm install && npx cypress run --headless --browser chrome - - mv ./.nyc_output ../ && cd .. - - npx nyc report --reporter=text-lcov >> ${HOST_COVERAGE_DATA_DIR}/lcov.info - - 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' - -after_success: - # https://coveralls-python.readthedocs.io/en/latest/usage/multilang.html - - 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' diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index bd1ef2df5cd5..b46c960bea30 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -12,11 +12,13 @@ services: - cvat_ui - cvat_proxy environment: - COVERALLS_REPO_TOKEN: - TRAVIS: - TRAVIS_JOB_ID: - TRAVIS_BRANCH: - TRAVIS_PULL_REQUEST: + COVERALLS_SERVICE_NAME: CONTAINER_COVERAGE_DATA_DIR: + GITHUB_ACTIONS: + GITHUB_TOKEN: + GITHUB_WORKSPACE: + GITHUB_REF: + GITHUB_HEAD_REF: + GITHUB_RUN_ID: volumes: - ${HOST_COVERAGE_DATA_DIR}:${CONTAINER_COVERAGE_DATA_DIR}