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.
192 lines
6.6 KiB
YAML
192 lines
6.6 KiB
YAML
name: CI-nightly
|
|
on:
|
|
schedule:
|
|
- cron: '0 22 * * *'
|
|
workflow_dispatch:
|
|
jobs:
|
|
check_updates:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
last_commit_time: ${{ steps.check_updates.outputs.last_commit_time }}
|
|
last_night_time: ${{ steps.check_updates.outputs.last_night_time }}
|
|
steps:
|
|
- id: check_updates
|
|
env:
|
|
REPO: ${{ github.repository }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
default_branch=$(gh api /repos/$REPO | jq -r '.default_branch')
|
|
|
|
last_commit_date=$(gh api /repos/${REPO}/branches/${default_branch} | jq -r '.commit.commit.author.date')
|
|
|
|
last_night_date=$(gh api /repos/${REPO}/actions/workflows/schedule.yml/runs | \
|
|
jq -r '.workflow_runs[]? | select((.status == "completed")) | .updated_at' \
|
|
| sort | tail -1)
|
|
|
|
last_night_time=$(date +%s -d $last_night_date)
|
|
last_commit_time=$(date +%s -d $last_commit_date)
|
|
|
|
echo Last CI-nightly workflow run time: $last_night_date
|
|
echo Last commit time in develop branch: $last_commit_date
|
|
|
|
echo ::set-output name=last_commit_time::${last_commit_time}
|
|
echo ::set-output name=last_night_time::${last_night_time}
|
|
|
|
cache:
|
|
needs: check_updates
|
|
if:
|
|
needs.check_updates.outputs.last_commit_time > needs.check_updates.outputs.last_night_time
|
|
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
|
|
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 | \
|
|
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
|
|
|
|
run_tests:
|
|
needs: cache
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '16.x'
|
|
|
|
- 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@v2
|
|
|
|
- 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 REST API tests
|
|
run: |
|
|
pip3 install --user -r tests/rest_api/requirements.txt
|
|
pytest tests/rest_api/
|
|
pytest tests/rest_api/ --stop-services
|
|
|
|
- name: Run CVAT
|
|
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
|
|
|
|
- name: Waiting for server
|
|
env:
|
|
API_ABOUT_PAGE: "localhost:8080/api/server/about"
|
|
run: |
|
|
max_tries=60
|
|
status_code=$(curl -s -o /tmp/server_response -w "%{http_code}" ${API_ABOUT_PAGE})
|
|
while [[ $status_code != "401" && max_tries -gt 0 ]]
|
|
do
|
|
echo Number of attempts left: $max_tries
|
|
echo Status code of response: $status_code
|
|
|
|
sleep 5
|
|
status_code=$(curl -s -o /tmp/server_response -w "%{http_code}" ${API_ABOUT_PAGE})
|
|
(( max_tries-- ))
|
|
done
|
|
|
|
if [[ $status_code != "401" ]]; then
|
|
echo Response from server is incorrect, output:
|
|
cat /tmp/server_response
|
|
fi
|
|
|
|
- name: Add user for tests
|
|
env:
|
|
DJANGO_SU_NAME: "admin"
|
|
DJANGO_SU_EMAIL: "admin@localhost.company"
|
|
DJANGO_SU_PASSWORD: "12qwaszx"
|
|
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"
|
|
|
|
- name: End-to-end testing
|
|
run: |
|
|
cd ./tests
|
|
npm ci
|
|
npm run cypress:run:firefox
|
|
|
|
- name: Unit tests
|
|
run: |
|
|
python manage.py test cvat/apps utils/cli
|
|
|
|
npm ci
|
|
cd cvat-core
|
|
npm run test
|
|
|
|
- name: Uploading cypress screenshots as an artifact
|
|
if: failure()
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: cypress_screenshots
|
|
path: ${{ github.workspace }}/tests/cypress/screenshots
|