From cb83c327531e58a4e139326c1e9869a63b98ac52 Mon Sep 17 00:00:00 2001 From: Zahed-Riyaz Date: Thu, 19 Jun 2025 18:02:54 +0530 Subject: [PATCH 01/19] add ci-cd workflow through github --- .github/workflows/ci-cd.yml | 207 ++++++++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 .github/workflows/ci-cd.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000000..37fcd0837a --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,207 @@ +name: EvalAI CI/CD Pipeline + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +env: + COMPOSE_BAKE: true + COMPOSE_BAKE_ARGS: "--build-arg PIP_NO_CACHE_DIR=1" + +jobs: + lint: + name: Code Linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + + - name: Run code quality checks in Docker + run: | + docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev -e VERBOSE=1 django bash -c " + echo 'Installing black, flake8, pylint and isort...' && + pip install black==24.8.0 flake8==3.8.2 pylint==3.3.6 isort==5.12.0 && + echo 'Running black check...' && + black --check --diff ./ || { echo 'Black check failed!'; exit 1; } && + echo 'Running isort check...' && + isort --check-only --diff --profile=black ./ || { echo 'isort check failed!'; exit 1; } && + echo 'Running flake8 check...' && + flake8 --config=.flake8 ./ || { echo 'Flake8 check failed!'; exit 1; } && + echo 'Running pylint check...' && + pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ || { echo 'Pylint check failed!'; exit 1; } && + echo 'All code quality checks passed!'" + + migration-check: + name: Django Migration Check + runs-on: ubuntu-latest + needs: lint + if: github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + + - name: Django Migration Checker + run: | + docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev django python manage.py makemigrations --check --dry-run + + build: + name: Docker Build + runs-on: ubuntu-latest + needs: lint + steps: + - uses: actions/checkout@v3 + + - name: System configuration + run: | + sudo rm -f /etc/boto.cfg + mkdir -p $HOME/.config/pip + echo "[build_ext]" > $HOME/.config/pip/pip.conf + echo "parallel = 1" >> $HOME/.config/pip/pip.conf + ulimit -u 16384 # Increase process/thread limit + ulimit -n 4096 # Increase open file limit + + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + + - name: Docker login + if: github.event_name == 'push' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build Docker image + run: docker-compose --profile worker --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} + + - name: Cache Docker images + uses: actions/cache@v3 + with: + path: /var/lib/docker + key: ${{ runner.os }}-docker-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-docker- + + frontend-test: + name: Frontend Tests + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v3 + + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + + - name: Setup Chrome + run: | + export CHROME_BIN=chromium-browser + + - name: Setup display for browser tests + run: | + export DISPLAY=:99 + sudo apt-get install -y xvfb + Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + + - name: Run frontend tests + run: docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" + + backend-test: + name: Backend Tests + runs-on: ubuntu-latest + needs: build + services: + postgres: + image: postgres:14 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: evalai_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + - uses: actions/checkout@v3 + + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: 3.9.21 + + - name: Install dependencies + run: pip install awscli==1.18.66 coveralls + + - name: Run backend tests + run: | + docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput + docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + + - name: Coveralls + continue-on-error: true + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + run: | + echo "Attempting to submit coverage to Coveralls..." + coveralls --rcfile=.coveragerc || echo "Coveralls submission failed, but continuing workflow" + + deploy: + name: Package & Deploy + runs-on: ubuntu-latest + needs: [frontend-test, backend-test] + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: 3.9.21 + + - name: Install dependencies + run: pip install awscli==1.18.66 + + - name: Setup SSH key for deployment + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts + ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts + + - name: Run deployment scripts + run: | + export SSH_AUTH_SOCK=/tmp/ssh_agent.sock + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add ~/.ssh/deploy_key + ./scripts/deployment/push.sh + ./scripts/deployment/deploy.sh auto_deploy From 441057e681d95723f8dfed1a07bc86a243fd13ff Mon Sep 17 00:00:00 2001 From: Zahed-Riyaz Date: Tue, 22 Jul 2025 03:39:35 +0530 Subject: [PATCH 02/19] Omit .travis.yml --- .travis.yml | 84 ----------------------------------------------------- 1 file changed, 84 deletions(-) delete mode 100755 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100755 index c2c4959b18..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,84 +0,0 @@ -language: python -sudo: required -os: linux -dist: focal -virt: vm -services: - - docker - - xvfb -python: - - '3.9.21' -cache: - directories: - - $HOME/.cache/pip - -env: - global: - - COMPOSE_BAKE=true - - COMPOSE_BAKE_ARGS="--build-arg PIP_NO_CACHE_DIR=1" - -before_install: - - sudo rm -f /etc/boto.cfg - - export CHROME_BIN=chromium-browser - - export DISPLAY=:99.0 - - pip install --upgrade pip - - mkdir -p $HOME/.config/pip - - echo "[build_ext]" > $HOME/.config/pip/pip.conf - - echo "parallel = 1" >> $HOME/.config/pip/pip.conf - - ulimit -u 16384 # Increase process/thread limit - - ulimit -n 4096 # Increase open file limit - -install: - - pip install awscli==1.18.66 - -jobs: - fast_finish: true - include: - - stage: Build, Test & Check Code Quality - name: Build, Test & Check Code Quality - script: - # Build steps - - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin || travis_terminate 1; fi - - docker-compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build || travis_terminate 1; - - # Frontend Tests - - docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" || travis_terminate 1; - - # Backend Tests - - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput || travis_terminate 1; - - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc || travis_terminate 1; - - # Check Code Quality - - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev -e VERBOSE=1 django bash -c " - echo 'Installing black, flake8, pylint and isort...' && - pip install black==24.8.0 flake8==3.8.2 pylint==3.3.6 isort==5.12.0 && - echo 'Running black check...' && - black --check --diff ./ || { echo 'Black check failed!'; travis_terminate 1; } && - echo 'Running isort check...' && - isort --check-only --diff --profile=black ./ || { echo 'isort check failed!'; travis_terminate 1; } && - echo 'Running flake8 check...' && - flake8 --config=.flake8 ./ || { echo 'Flake8 check failed!'; travis_terminate 1; } && - echo 'Running pylint check...' && - pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ || { echo 'Pylint check failed!'; travis_terminate 1; } && - echo 'All code quality checks passed!'" || travis_terminate 1; - - after_success: - - bash <(curl -s https://codecov.io/bash) - - coveralls --rcfile=.coveragerc - - - stage: Package & Deployment - name: Push & Deploy Services - script: - - eval "$(ssh-agent -s)" - - openssl aes-256-cbc -K $encrypted_77d2d82026f6_key -iv $encrypted_77d2d82026f6_iv -in scripts/deployment/evalai.pem.enc -out scripts/deployment/evalai.pem -d || true - - ./scripts/deployment/push.sh || travis_terminate 1; - - ./scripts/deployment/deploy.sh auto_deploy || travis_terminate 1; - -before_cache: - - rm -f $HOME/.cache/pip/log/debug.log - -notifications: - email: - on_success: change - on_failure: always - slack: cloudcv:gy3CGQGNXLwXOqVyzXGZfdea \ No newline at end of file From 68973b0db1c1e717ce6fc394ef4a7e82cecad22c Mon Sep 17 00:00:00 2001 From: Zahed-Riyaz Date: Sat, 21 Jun 2025 20:54:46 +0530 Subject: [PATCH 03/19] undo travis deletion --- .travis.yml | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..c2c4959b18 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,84 @@ +language: python +sudo: required +os: linux +dist: focal +virt: vm +services: + - docker + - xvfb +python: + - '3.9.21' +cache: + directories: + - $HOME/.cache/pip + +env: + global: + - COMPOSE_BAKE=true + - COMPOSE_BAKE_ARGS="--build-arg PIP_NO_CACHE_DIR=1" + +before_install: + - sudo rm -f /etc/boto.cfg + - export CHROME_BIN=chromium-browser + - export DISPLAY=:99.0 + - pip install --upgrade pip + - mkdir -p $HOME/.config/pip + - echo "[build_ext]" > $HOME/.config/pip/pip.conf + - echo "parallel = 1" >> $HOME/.config/pip/pip.conf + - ulimit -u 16384 # Increase process/thread limit + - ulimit -n 4096 # Increase open file limit + +install: + - pip install awscli==1.18.66 + +jobs: + fast_finish: true + include: + - stage: Build, Test & Check Code Quality + name: Build, Test & Check Code Quality + script: + # Build steps + - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin || travis_terminate 1; fi + - docker-compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build || travis_terminate 1; + + # Frontend Tests + - docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" || travis_terminate 1; + + # Backend Tests + - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput || travis_terminate 1; + - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc || travis_terminate 1; + + # Check Code Quality + - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev -e VERBOSE=1 django bash -c " + echo 'Installing black, flake8, pylint and isort...' && + pip install black==24.8.0 flake8==3.8.2 pylint==3.3.6 isort==5.12.0 && + echo 'Running black check...' && + black --check --diff ./ || { echo 'Black check failed!'; travis_terminate 1; } && + echo 'Running isort check...' && + isort --check-only --diff --profile=black ./ || { echo 'isort check failed!'; travis_terminate 1; } && + echo 'Running flake8 check...' && + flake8 --config=.flake8 ./ || { echo 'Flake8 check failed!'; travis_terminate 1; } && + echo 'Running pylint check...' && + pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ || { echo 'Pylint check failed!'; travis_terminate 1; } && + echo 'All code quality checks passed!'" || travis_terminate 1; + + after_success: + - bash <(curl -s https://codecov.io/bash) + - coveralls --rcfile=.coveragerc + + - stage: Package & Deployment + name: Push & Deploy Services + script: + - eval "$(ssh-agent -s)" + - openssl aes-256-cbc -K $encrypted_77d2d82026f6_key -iv $encrypted_77d2d82026f6_iv -in scripts/deployment/evalai.pem.enc -out scripts/deployment/evalai.pem -d || true + - ./scripts/deployment/push.sh || travis_terminate 1; + - ./scripts/deployment/deploy.sh auto_deploy || travis_terminate 1; + +before_cache: + - rm -f $HOME/.cache/pip/log/debug.log + +notifications: + email: + on_success: change + on_failure: always + slack: cloudcv:gy3CGQGNXLwXOqVyzXGZfdea \ No newline at end of file From d38601f7d6ea13a3f98478a1823597ae3a11acff Mon Sep 17 00:00:00 2001 From: Zahed-Riyaz Date: Sat, 21 Jun 2025 20:58:33 +0530 Subject: [PATCH 04/19] fix backend testing --- .github/workflows/ci-cd.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 37fcd0837a..15d68102f6 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -123,24 +123,11 @@ jobs: - name: Run frontend tests run: docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" + backend-test: name: Backend Tests runs-on: ubuntu-latest needs: build - services: - postgres: - image: postgres:14 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: evalai_test - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 steps: - uses: actions/checkout@v3 From 88acee2800150cdd5c03917d348533dbc69ceb86 Mon Sep 17 00:00:00 2001 From: Zahed-Riyaz Date: Sat, 21 Jun 2025 21:49:28 +0530 Subject: [PATCH 05/19] Modify travis env variables --- .coveralls.yml | 2 +- .github/workflows/ci-cd.yml | 192 +++++++++++++++++------- .travis.yml | 84 ----------- README.md | 1 - docker-compose.yml | 2 +- docker/prod/celery/Dockerfile | 4 +- frontend_v2/pr_deploy.sh | 10 +- karma.conf.js | 6 +- scripts/deployment/deploy.sh | 6 +- scripts/deployment/deploy_ec2_worker.sh | 2 +- scripts/deployment/push.sh | 10 +- 11 files changed, 165 insertions(+), 154 deletions(-) delete mode 100644 .travis.yml diff --git a/.coveralls.yml b/.coveralls.yml index a253acc08e..cb1718c859 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1,2 +1,2 @@ -service_name: travis-ci +service_name: github-actions repo_token: s4vXsUN3KoBjArm1eb7o1jg0RQHYIBr0R diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 15d68102f6..b069ef59c0 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -9,19 +9,44 @@ on: env: COMPOSE_BAKE: true COMPOSE_BAKE_ARGS: "--build-arg PIP_NO_CACHE_DIR=1" + DOCKER_COMPOSE_VERSION: "v2.23.0" jobs: - lint: - name: Code Linting + # Shared setup job to avoid duplication + setup: + name: Setup Dependencies runs-on: ubuntu-latest + outputs: + compose-cache-key: ${{ steps.compose-cache.outputs.cache-hit }} steps: - - uses: actions/checkout@v3 + - name: Cache Docker Compose binary + id: compose-cache + uses: actions/cache@v4 + with: + path: /usr/local/bin/docker-compose + key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} - name: Install Docker Compose + if: steps.compose-cache.outputs.cache-hit != 'true' run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo curl -L "https://github.com/docker/compose/releases/download/${{ env.DOCKER_COMPOSE_VERSION }}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version + + - name: Verify Docker Compose + run: docker-compose --version + + lint: + name: Code Linting + runs-on: ubuntu-latest + needs: setup + steps: + - uses: actions/checkout@v4 + + - name: Restore Docker Compose + uses: actions/cache@v4 + with: + path: /usr/local/bin/docker-compose + key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} - name: Run code quality checks in Docker run: | @@ -41,17 +66,18 @@ jobs: migration-check: name: Django Migration Check runs-on: ubuntu-latest - needs: lint + needs: [setup, lint] if: github.event_name == 'pull_request' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Install Docker Compose - run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose + - name: Restore Docker Compose + uses: actions/cache@v4 + with: + path: /usr/local/bin/docker-compose + key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} - name: Django Migration Checker run: | @@ -60,9 +86,9 @@ jobs: build: name: Docker Build runs-on: ubuntu-latest - needs: lint + needs: [setup, lint] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: System configuration run: | @@ -73,72 +99,86 @@ jobs: ulimit -u 16384 # Increase process/thread limit ulimit -n 4096 # Increase open file limit - - name: Install Docker Compose - run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version + - name: Restore Docker Compose + uses: actions/cache@v4 + with: + path: /usr/local/bin/docker-compose + key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: Docker login if: github.event_name == 'push' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build Docker image run: docker-compose --profile worker --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} - - - name: Cache Docker images - uses: actions/cache@v3 - with: - path: /var/lib/docker - key: ${{ runner.os }}-docker-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-docker- frontend-test: name: Frontend Tests runs-on: ubuntu-latest needs: build steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Install Docker Compose - run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - - name: Setup Chrome - run: | - export CHROME_BIN=chromium-browser + - name: Restore Docker Compose + uses: actions/cache@v4 + with: + path: /usr/local/bin/docker-compose + key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} - name: Setup display for browser tests run: | - export DISPLAY=:99 + sudo apt-get update sudo apt-get install -y xvfb + export DISPLAY=:99 Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + export CHROME_BIN=chromium-browser - name: Run frontend tests + env: + DISPLAY: :99 + CHROME_BIN: chromium-browser run: docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" - backend-test: name: Backend Tests runs-on: ubuntu-latest needs: build + services: + postgres: + image: postgres:14 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: evalai_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Install Docker Compose - run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version + - name: Restore Docker Compose + uses: actions/cache@v4 + with: + path: /usr/local/bin/docker-compose + key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} - name: Set up Python 3.9 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.9.21 @@ -146,12 +186,14 @@ jobs: run: pip install awscli==1.18.66 coveralls - name: Run backend tests + env: + DATABASE_URL: postgres://postgres:postgres@localhost:5432/evalai_test run: | - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc + docker-compose run --no-deps -e DJANGO_SETTINGS_MODULE=settings.test -e DATABASE_URL=$DATABASE_URL django python manage.py flush --noinput + docker-compose run --no-deps -e DJANGO_SETTINGS_MODULE=settings.test -e DATABASE_URL=$DATABASE_URL django pytest --cov . --cov-config .coveragerc - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 - name: Coveralls continue-on-error: true @@ -160,6 +202,44 @@ jobs: run: | echo "Attempting to submit coverage to Coveralls..." coveralls --rcfile=.coveragerc || echo "Coveralls submission failed, but continuing workflow" + + pr-deploy: + name: Deploy PR Preview + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + needs: [frontend-test] + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Build frontend + run: | + npm install + npm run build + + - name: Deploy PR Preview + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + GITHUB_PR_NUMBER: ${{ github.event.number }} + run: | + chmod +x ./scripts/pr_deploy.sh + ./scripts/pr_deploy.sh + + - name: Comment PR with preview link + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '🚀 Preview deployed to: https://pr-${{ github.event.number }}-evalai.surge.sh' + }) deploy: name: Package & Deploy @@ -167,10 +247,10 @@ jobs: needs: [frontend-test, backend-test] if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.9.21 @@ -186,6 +266,16 @@ jobs: ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts - name: Run deployment scripts + env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + GITHUB_REF_NAME: ${{ github.ref_name }} + JUMPBOX_INSTANCE: ${{ secrets.JUMPBOX_INSTANCE }} + PRODUCTION_INSTANCE: ${{ secrets.PRODUCTION_INSTANCE }} + STAGING_INSTANCE: ${{ secrets.STAGING_INSTANCE }} + PRODUCTION_MONITORING_INSTANCE: ${{ secrets.PRODUCTION_MONITORING_INSTANCE }} + STAGING_MONITORING_INSTANCE: ${{ secrets.STAGING_MONITORING_INSTANCE }} run: | export SSH_AUTH_SOCK=/tmp/ssh_agent.sock ssh-agent -a $SSH_AUTH_SOCK > /dev/null diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c2c4959b18..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,84 +0,0 @@ -language: python -sudo: required -os: linux -dist: focal -virt: vm -services: - - docker - - xvfb -python: - - '3.9.21' -cache: - directories: - - $HOME/.cache/pip - -env: - global: - - COMPOSE_BAKE=true - - COMPOSE_BAKE_ARGS="--build-arg PIP_NO_CACHE_DIR=1" - -before_install: - - sudo rm -f /etc/boto.cfg - - export CHROME_BIN=chromium-browser - - export DISPLAY=:99.0 - - pip install --upgrade pip - - mkdir -p $HOME/.config/pip - - echo "[build_ext]" > $HOME/.config/pip/pip.conf - - echo "parallel = 1" >> $HOME/.config/pip/pip.conf - - ulimit -u 16384 # Increase process/thread limit - - ulimit -n 4096 # Increase open file limit - -install: - - pip install awscli==1.18.66 - -jobs: - fast_finish: true - include: - - stage: Build, Test & Check Code Quality - name: Build, Test & Check Code Quality - script: - # Build steps - - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin || travis_terminate 1; fi - - docker-compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build || travis_terminate 1; - - # Frontend Tests - - docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" || travis_terminate 1; - - # Backend Tests - - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput || travis_terminate 1; - - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc || travis_terminate 1; - - # Check Code Quality - - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev -e VERBOSE=1 django bash -c " - echo 'Installing black, flake8, pylint and isort...' && - pip install black==24.8.0 flake8==3.8.2 pylint==3.3.6 isort==5.12.0 && - echo 'Running black check...' && - black --check --diff ./ || { echo 'Black check failed!'; travis_terminate 1; } && - echo 'Running isort check...' && - isort --check-only --diff --profile=black ./ || { echo 'isort check failed!'; travis_terminate 1; } && - echo 'Running flake8 check...' && - flake8 --config=.flake8 ./ || { echo 'Flake8 check failed!'; travis_terminate 1; } && - echo 'Running pylint check...' && - pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ || { echo 'Pylint check failed!'; travis_terminate 1; } && - echo 'All code quality checks passed!'" || travis_terminate 1; - - after_success: - - bash <(curl -s https://codecov.io/bash) - - coveralls --rcfile=.coveragerc - - - stage: Package & Deployment - name: Push & Deploy Services - script: - - eval "$(ssh-agent -s)" - - openssl aes-256-cbc -K $encrypted_77d2d82026f6_key -iv $encrypted_77d2d82026f6_iv -in scripts/deployment/evalai.pem.enc -out scripts/deployment/evalai.pem -d || true - - ./scripts/deployment/push.sh || travis_terminate 1; - - ./scripts/deployment/deploy.sh auto_deploy || travis_terminate 1; - -before_cache: - - rm -f $HOME/.cache/pip/log/debug.log - -notifications: - email: - on_success: change - on_failure: always - slack: cloudcv:gy3CGQGNXLwXOqVyzXGZfdea \ No newline at end of file diff --git a/README.md b/README.md index 89ef03313e..a61a228d7d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ ------------------------------------------------------------------------------------------ [![Join the chat on Slack](https://img.shields.io/badge/Join%20Slack-Chat-blue?logo=slack)](https://join.slack.com/t/cloudcv-community/shared_invite/zt-3252n6or8-e0QuZKIZFLB0zXtQ6XgxfA) -[![Build Status](https://travis-ci.org/Cloud-CV/EvalAI.svg?branch=master)](https://travis-ci.org/Cloud-CV/EvalAI) [![codecov](https://codecov.io/gh/Cloud-CV/EvalAI/branch/master/graph/badge.svg)](https://codecov.io/gh/Cloud-CV/EvalAI) [![Coverage Status](https://coveralls.io/repos/github/Cloud-CV/EvalAI/badge.svg)](https://coveralls.io/github/Cloud-CV/EvalAI) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) diff --git a/docker-compose.yml b/docker-compose.yml index a8a1b9a9cb..a89a8ab5dd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: db: - image: postgres:16.8 + image: postgres:10.4 ports: - "5432:5432" env_file: diff --git a/docker/prod/celery/Dockerfile b/docker/prod/celery/Dockerfile index bb99580046..c05b7a9daf 100644 --- a/docker/prod/celery/Dockerfile +++ b/docker/prod/celery/Dockerfile @@ -1,7 +1,7 @@ ARG AWS_ACCOUNT_ID ARG COMMIT_ID -ARG TRAVIS_BRANCH +ARG GITHUB_REF_NAME -FROM ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/evalai-${TRAVIS_BRANCH}-backend:${COMMIT_ID} +FROM ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/evalai-${GITHUB_REF_NAME}-backend:${COMMIT_ID} CMD ["sh", "/code/docker/prod/celery/container-start.sh"] diff --git a/frontend_v2/pr_deploy.sh b/frontend_v2/pr_deploy.sh index 9ddc65c119..16b314b89b 100644 --- a/frontend_v2/pr_deploy.sh +++ b/frontend_v2/pr_deploy.sh @@ -1,13 +1,17 @@ #!/usr/bin/env bash -if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then + +# Check if this is a pull request +if [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then echo "Not a Pull Request. Skipping surge deployment" exit 0 fi echo "PR deployment start" npm i -g surge echo "Installed surge successfully" -export DEPLOY_DOMAIN=https://pr-${TRAVIS_PULL_REQUEST}-evalai.surge.sh -echo "Deployment domain -" + +# Use GitHub's pull request number from the event payload +export DEPLOY_DOMAIN=https://pr-${GITHUB_PR_NUMBER}-evalai.surge.sh +echo "Deployment domain:" echo $DEPLOY_DOMAIN surge --project ./dist --domain $DEPLOY_DOMAIN --token $SURGE_TOKEN diff --git a/karma.conf.js b/karma.conf.js index 293e4e9e48..4f21c2a511 100755 --- a/karma.conf.js +++ b/karma.conf.js @@ -99,9 +99,11 @@ module.exports = function(config) { } }; - // Detect if this is TravisCI running the tests and tell it to use chromium - if(process.env.TRAVIS){ + // Detect if this is Github Actions running the tests and tell it to use chromium + if(process.env.GITHUB_ACTIONS){ configuration.browsers = ['ChromeWithNoSandbox']; + configuration.singleRun = true; + configuration.autoWatch = false; } config.set(configuration); diff --git a/scripts/deployment/deploy.sh b/scripts/deployment/deploy.sh index 93688c1dcc..4e91acc425 100755 --- a/scripts/deployment/deploy.sh +++ b/scripts/deployment/deploy.sh @@ -17,11 +17,11 @@ if [ -z ${COMMIT_ID} ]; then export COMMIT_ID="latest" fi -if [ -z ${TRAVIS_BRANCH} ]; then - echo "Please set the TRAVIS_BRANCH first." +if [ -z ${GITHUB_REF_NAME} ]; then + echo "Please set the GITHUB_REF_NAME first." fi -env=${TRAVIS_BRANCH} +env=${GITHUB_REF_NAME} JUMPBOX=${JUMPBOX_INSTANCE} if [[ ${env} == "production" ]]; then diff --git a/scripts/deployment/deploy_ec2_worker.sh b/scripts/deployment/deploy_ec2_worker.sh index 33048ba603..8909c852ed 100644 --- a/scripts/deployment/deploy_ec2_worker.sh +++ b/scripts/deployment/deploy_ec2_worker.sh @@ -33,7 +33,7 @@ aws configure set default.region ${AWS_REGION} export AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID} export COMMIT_ID="latest" export AWS_DEFAULT_REGION=${AWS_REGION} -export TRAVIS_BRANCH=${ENVIRONMENT} +export GITHUB_REF_NAME=${ENVIRONMENT} eval $(aws ecr get-login --no-include-email) # Step 7: Copying Docker environment file diff --git a/scripts/deployment/push.sh b/scripts/deployment/push.sh index c2e91788c4..4ceb2f8d95 100755 --- a/scripts/deployment/push.sh +++ b/scripts/deployment/push.sh @@ -9,11 +9,11 @@ build_and_push() { echo "Pulling ssl certificates and nginx configuration..." aws s3 cp s3://cloudcv-secrets/eval.ai/ssl/ ./ssl/ --recursive # Need ssl files related to *.cloudcv.org since we want to provide backward compatibility - aws s3 cp s3://cloudcv-secrets/evalai/${TRAVIS_BRANCH}/ssl/ ./ssl/ --recursive + aws s3 cp s3://cloudcv-secrets/evalai/${GITHUB_REF_NAME}/ssl/ ./ssl/ --recursive echo "Pulled ssl certificates and nginx configuration successfully" docker-compose -f docker-compose-$1.yml build \ --build-arg COMMIT_ID=${COMMIT_ID} \ - --build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} \ + --build-arg GITHUB_REF_NAME=${GITHUB_REF_NAME} \ --build-arg AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID} --compress docker-compose -f docker-compose-$1.yml push @@ -29,11 +29,11 @@ build_and_push() { done } -if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then +if [ "${GITHUB_EVENT_NAME}" != "push" ]; then echo "Skipping deploy to staging or production server; The request or commit is not on staging or production branch" exit 0 -elif [ "${TRAVIS_BRANCH}" == "staging" -o "${TRAVIS_BRANCH}" == "production" ]; then - build_and_push $TRAVIS_BRANCH +elif [ "${GITHUB_REF_NAME}" == "staging" -o "${GITHUB_REF_NAME}" == "production" ]; then + build_and_push $GITHUB_REF_NAME exit 0 else echo "Skipping deploy!" From 85eb02101832f56e6c29634411ff2730c616b24f Mon Sep 17 00:00:00 2001 From: Zahed-Riyaz Date: Sun, 22 Jun 2025 16:30:17 +0530 Subject: [PATCH 06/19] Update travis variables to github actions --- .github/workflows/ci-cd.yml | 194 ++++++++++-------------------------- 1 file changed, 52 insertions(+), 142 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b069ef59c0..8e7bbd0886 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -9,44 +9,19 @@ on: env: COMPOSE_BAKE: true COMPOSE_BAKE_ARGS: "--build-arg PIP_NO_CACHE_DIR=1" - DOCKER_COMPOSE_VERSION: "v2.23.0" jobs: - # Shared setup job to avoid duplication - setup: - name: Setup Dependencies + lint: + name: Code Linting runs-on: ubuntu-latest - outputs: - compose-cache-key: ${{ steps.compose-cache.outputs.cache-hit }} steps: - - name: Cache Docker Compose binary - id: compose-cache - uses: actions/cache@v4 - with: - path: /usr/local/bin/docker-compose - key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} + - uses: actions/checkout@v3 - name: Install Docker Compose - if: steps.compose-cache.outputs.cache-hit != 'true' run: | - sudo curl -L "https://github.com/docker/compose/releases/download/${{ env.DOCKER_COMPOSE_VERSION }}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose - - - name: Verify Docker Compose - run: docker-compose --version - - lint: - name: Code Linting - runs-on: ubuntu-latest - needs: setup - steps: - - uses: actions/checkout@v4 - - - name: Restore Docker Compose - uses: actions/cache@v4 - with: - path: /usr/local/bin/docker-compose - key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} + docker-compose --version - name: Run code quality checks in Docker run: | @@ -66,18 +41,17 @@ jobs: migration-check: name: Django Migration Check runs-on: ubuntu-latest - needs: [setup, lint] + needs: lint if: github.event_name == 'pull_request' steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Restore Docker Compose - uses: actions/cache@v4 - with: - path: /usr/local/bin/docker-compose - key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose - name: Django Migration Checker run: | @@ -86,9 +60,9 @@ jobs: build: name: Docker Build runs-on: ubuntu-latest - needs: [setup, lint] + needs: lint steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 - name: System configuration run: | @@ -99,86 +73,72 @@ jobs: ulimit -u 16384 # Increase process/thread limit ulimit -n 4096 # Increase open file limit - - name: Restore Docker Compose - uses: actions/cache@v4 - with: - path: /usr/local/bin/docker-compose - key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} - - - name: Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version - name: Docker login if: github.event_name == 'push' - uses: docker/login-action@v3 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build Docker image run: docker-compose --profile worker --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} + + - name: Cache Docker images + uses: actions/cache@v3 + with: + path: /var/lib/docker + key: ${{ runner.os }}-docker-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-docker- frontend-test: name: Frontend Tests runs-on: ubuntu-latest needs: build steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 - - name: Restore Docker Compose - uses: actions/cache@v4 - with: - path: /usr/local/bin/docker-compose - key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + + - name: Setup Chrome + run: | + export CHROME_BIN=chromium-browser - name: Setup display for browser tests run: | - sudo apt-get update - sudo apt-get install -y xvfb export DISPLAY=:99 + sudo apt-get install -y xvfb Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - export CHROME_BIN=chromium-browser - name: Run frontend tests - env: - DISPLAY: :99 - CHROME_BIN: chromium-browser run: docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" + backend-test: name: Backend Tests runs-on: ubuntu-latest needs: build - services: - postgres: - image: postgres:14 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: evalai_test - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 - - name: Restore Docker Compose - uses: actions/cache@v4 - with: - path: /usr/local/bin/docker-compose - key: docker-compose-${{ env.DOCKER_COMPOSE_VERSION }} + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version - name: Set up Python 3.9 - uses: actions/setup-python@v5 + uses: actions/setup-python@v4 with: python-version: 3.9.21 @@ -186,14 +146,12 @@ jobs: run: pip install awscli==1.18.66 coveralls - name: Run backend tests - env: - DATABASE_URL: postgres://postgres:postgres@localhost:5432/evalai_test run: | - docker-compose run --no-deps -e DJANGO_SETTINGS_MODULE=settings.test -e DATABASE_URL=$DATABASE_URL django python manage.py flush --noinput - docker-compose run --no-deps -e DJANGO_SETTINGS_MODULE=settings.test -e DATABASE_URL=$DATABASE_URL django pytest --cov . --cov-config .coveragerc + docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput + docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v3 - name: Coveralls continue-on-error: true @@ -202,44 +160,6 @@ jobs: run: | echo "Attempting to submit coverage to Coveralls..." coveralls --rcfile=.coveragerc || echo "Coveralls submission failed, but continuing workflow" - - pr-deploy: - name: Deploy PR Preview - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' - needs: [frontend-test] - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '18' - cache: 'npm' - - - name: Build frontend - run: | - npm install - npm run build - - - name: Deploy PR Preview - env: - SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} - GITHUB_PR_NUMBER: ${{ github.event.number }} - run: | - chmod +x ./scripts/pr_deploy.sh - ./scripts/pr_deploy.sh - - - name: Comment PR with preview link - uses: actions/github-script@v7 - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '🚀 Preview deployed to: https://pr-${{ github.event.number }}-evalai.surge.sh' - }) deploy: name: Package & Deploy @@ -247,10 +167,10 @@ jobs: needs: [frontend-test, backend-test] if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v3 - name: Set up Python 3.9 - uses: actions/setup-python@v5 + uses: actions/setup-python@v4 with: python-version: 3.9.21 @@ -266,19 +186,9 @@ jobs: ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts - name: Run deployment scripts - env: - AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - GITHUB_REF_NAME: ${{ github.ref_name }} - JUMPBOX_INSTANCE: ${{ secrets.JUMPBOX_INSTANCE }} - PRODUCTION_INSTANCE: ${{ secrets.PRODUCTION_INSTANCE }} - STAGING_INSTANCE: ${{ secrets.STAGING_INSTANCE }} - PRODUCTION_MONITORING_INSTANCE: ${{ secrets.PRODUCTION_MONITORING_INSTANCE }} - STAGING_MONITORING_INSTANCE: ${{ secrets.STAGING_MONITORING_INSTANCE }} run: | export SSH_AUTH_SOCK=/tmp/ssh_agent.sock ssh-agent -a $SSH_AUTH_SOCK > /dev/null ssh-add ~/.ssh/deploy_key ./scripts/deployment/push.sh - ./scripts/deployment/deploy.sh auto_deploy + ./scripts/deployment/deploy.sh auto_deploy \ No newline at end of file From 3f4fb0c020b631d16b20edf0cacb4a46ddf5d33d Mon Sep 17 00:00:00 2001 From: Zahed-Riyaz Date: Sun, 22 Jun 2025 17:24:25 +0530 Subject: [PATCH 07/19] Decommission Travis CI --- .github/CONTRIBUTING.md | 2 +- .../04-development/contributing/contribution-guide.md | 2 +- docs/source/contribution.rst | 11 ++++++----- frontend_v2/README.md | 4 ++-- tests/unit/jobs/test_views.py | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9310201b8d..5a0b09ca8a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -68,7 +68,7 @@ Our central development branch is development. Coding is done on feature branche - On your GitHub fork, select your branch and click “New pull request”. Select “master” as the base branch and your branch in the “compare” dropdown. If the code is mergeable (you get a message saying “Able to merge”), go ahead and create the pull request. - - Check back after some time to see if the Travis checks have passed, if not you should click on “Details” link on your PR thread at the right of “The Travis CI build failed”, which will take you to the dashboard for your PR. You will see what failed / stalled, and will need to resolve them. + - Check back after a few minutes to see if the GitHub Actions workflow has completed. If it hasn’t passed, click the "View details" link next to the failed check in your PR’s Job checks section—this will open the Actions run page for your workflow. There you can review the logs, pinpoint any errors or stalled steps, and fix them before pushing another commit. - If your checks have passed, your PR will be assigned a reviewer who will review your code and provide comments. Please address each review comment by pushing new commits to the same branch (the PR will automatically update, so you don’t need to submit a new one). Once you are done, comment below each review comment marking it as “Done”. Feel free to use the thread to have a discussion about comments that you don’t understand completely or don’t agree with. - Once all comments are addressed, the maintainer will approve the PR. diff --git a/docs/source/04-development/contributing/contribution-guide.md b/docs/source/04-development/contributing/contribution-guide.md index b64ac1ab0c..d84e08c0d6 100644 --- a/docs/source/04-development/contributing/contribution-guide.md +++ b/docs/source/04-development/contributing/contribution-guide.md @@ -67,7 +67,7 @@ Our central development branch is development. Coding is done on feature branche - On your GitHub fork, select your branch and click “New pull request”. Select “master” as the base branch and your branch in the “compare” dropdown. If the code is mergeable (you get a message saying “Able to merge”), go ahead and create the pull request. - - Check back after some time to see if the Travis checks have passed, if not you should click on “Details” link on your PR thread at the right of “The Travis CI build failed”, which will take you to the dashboard for your PR. You will see what failed / stalled, and will need to resolve them. + - - Check back after a few minutes to see if the GitHub Actions workflow has completed. If it hasn’t passed, click the "View details" link next to the failed check in your PR’s Job checks section—this will open the Actions run page for your workflow. There you can review the logs, pinpoint any errors or stalled steps, and fix them before pushing another commit. - If your checks have passed, your PR will be assigned a reviewer who will review your code and provide comments. Please address each review comment by pushing new commits to the same branch (the PR will automatically update, so you don’t need to submit a new one). Once you are done, comment below each review comment marking it as “Done”. Feel free to use the thread to have a discussion about comments that you don’t understand completely or don’t agree with. - Once all comments are addressed, the maintainer will approve the PR. diff --git a/docs/source/contribution.rst b/docs/source/contribution.rst index 9b6b00ef73..d96cfa7fd2 100644 --- a/docs/source/contribution.rst +++ b/docs/source/contribution.rst @@ -75,11 +75,12 @@ reviewed. To submit code, follow these steps: the “compare” dropdown. If the code is mergeable (you get a message saying “Able to merge”), go ahead and create the pull request. - - Check back after some time to see if the Travis checks have - passed, if not you should click on “Details” link on your PR - thread at the right of “The Travis CI build failed”, which will - take you to the dashboard for your PR. You will see what failed / - stalled, and will need to resolve them. + - Check back after a few minutes to see if the GitHub Actions + workflow has completed. If it hasn’t passed, click the "View details" + link next to the failed check in your PR’s Job checks section—this + will open the Actions run page for your workflow. There you can review + the logs, pinpoint any errors or stalled steps, and fix them before + pushing another commit. - If your checks have passed, your PR will be assigned a reviewer who will review your code and provide comments. Please address each review comment by pushing new commits to the same branch (the diff --git a/frontend_v2/README.md b/frontend_v2/README.md index 8459585cdc..1665d4fa44 100644 --- a/frontend_v2/README.md +++ b/frontend_v2/README.md @@ -4,9 +4,9 @@ Revamped codebase of EvalAI Frontend ### For deploying with [Surge](https://surge.sh/): -Surge will automatically generate deployment link whenever a pull request passes Travis CI. +Surge will automatically generate deployment link whenever a pull request passes Github Actions. -Suppose pull request number is 123 and it passes Travis CI. The deployment link can be found here: `https://pr-123-evalai.surge.sh` +Suppose pull request number is 123 and it passes Github Actions. The deployment link can be found here: `https://pr-123-evalai.surge.sh` ## Code scaffolding diff --git a/tests/unit/jobs/test_views.py b/tests/unit/jobs/test_views.py index 9945dc5164..3361923486 100644 --- a/tests/unit/jobs/test_views.py +++ b/tests/unit/jobs/test_views.py @@ -2478,7 +2478,7 @@ def test_update_submission_for_invalid_data_in_result_key(self): # } self.client.force_authenticate(user=self.challenge_host.user) response = self.client.put(self.url, self.data) - # Fix the travis build by un-commenting this line. + # Fix the build by un-commenting this line. # self.assertEqual(response.data, expected) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) From b5fbab80c072709c3789f58e9dc2f1126215e0c6 Mon Sep 17 00:00:00 2001 From: Zahed-Riyaz Date: Sun, 22 Jun 2025 21:51:39 +0530 Subject: [PATCH 08/19] Add Github actions build status --- README.md | 1 + docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a61a228d7d..2a938c29e6 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ ------------------------------------------------------------------------------------------ [![Join the chat on Slack](https://img.shields.io/badge/Join%20Slack-Chat-blue?logo=slack)](https://join.slack.com/t/cloudcv-community/shared_invite/zt-3252n6or8-e0QuZKIZFLB0zXtQ6XgxfA) +[![CI/CD](https://github.com/Cloud-CV/EvalAI/actions/workflows/ci-cd.yml/badge.svg?branch=master)](https://github.com/Cloud-CV/EvalAI/actions/workflows/ci-cd.yml) [![codecov](https://codecov.io/gh/Cloud-CV/EvalAI/branch/master/graph/badge.svg)](https://codecov.io/gh/Cloud-CV/EvalAI) [![Coverage Status](https://coveralls.io/repos/github/Cloud-CV/EvalAI/badge.svg)](https://coveralls.io/github/Cloud-CV/EvalAI) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) diff --git a/docker-compose.yml b/docker-compose.yml index a89a8ab5dd..a8a1b9a9cb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: db: - image: postgres:10.4 + image: postgres:16.8 ports: - "5432:5432" env_file: From 7ba09e2b2e0c442433a72f85303c4af2dc8762b8 Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Sun, 22 Jun 2025 21:58:11 +0530 Subject: [PATCH 09/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a938c29e6..6a9a5de336 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ------------------------------------------------------------------------------------------ [![Join the chat on Slack](https://img.shields.io/badge/Join%20Slack-Chat-blue?logo=slack)](https://join.slack.com/t/cloudcv-community/shared_invite/zt-3252n6or8-e0QuZKIZFLB0zXtQ6XgxfA) -[![CI/CD](https://github.com/Cloud-CV/EvalAI/actions/workflows/ci-cd.yml/badge.svg?branch=master)](https://github.com/Cloud-CV/EvalAI/actions/workflows/ci-cd.yml) +[![Build Status](https://github.com/Cloud-CV/EvalAI/actions/workflows/ci-cd.yml/badge.svg?branch=master)](https://github.com/Cloud-CV/EvalAI/actions/workflows/ci-cd.yml) [![codecov](https://codecov.io/gh/Cloud-CV/EvalAI/branch/master/graph/badge.svg)](https://codecov.io/gh/Cloud-CV/EvalAI) [![Coverage Status](https://coveralls.io/repos/github/Cloud-CV/EvalAI/badge.svg)](https://coveralls.io/github/Cloud-CV/EvalAI) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) From 8a596114ab7cd3094be0316154f4c3af57bde3f6 Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Thu, 10 Jul 2025 00:52:34 +0530 Subject: [PATCH 10/19] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 218 ++++++++++++++++-------------------- 1 file changed, 99 insertions(+), 119 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 8e7bbd0886..9f3b21d0d8 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -9,186 +9,166 @@ on: env: COMPOSE_BAKE: true COMPOSE_BAKE_ARGS: "--build-arg PIP_NO_CACHE_DIR=1" + CHROME_BIN: chromium-browser + DISPLAY: :99.0 jobs: - lint: - name: Code Linting + quality-check: + name: Code Quality & Migration Check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - name: Install Docker Compose + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: System configuration run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - - name: Run code quality checks in Docker + sudo rm -f /etc/boto.cfg + mkdir -p $HOME/.config/pip + echo "[build_ext]" > $HOME/.config/pip/pip.conf + echo "parallel = 1" >> $HOME/.config/pip/pip.conf + ulimit -u 16384 + ulimit -n 4096 + + - name: Setup Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: '3.9' + cache: 'pip' + + - name: Install dependencies + run: pip install awscli==1.18.66 + + - name: Run code quality checks run: | docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev -e VERBOSE=1 django bash -c " - echo 'Installing black, flake8, pylint and isort...' && + echo 'Installing linting tools...' && pip install black==24.8.0 flake8==3.8.2 pylint==3.3.6 isort==5.12.0 && echo 'Running black check...' && - black --check --diff ./ || { echo 'Black check failed!'; exit 1; } && + black --check --diff ./ && echo 'Running isort check...' && - isort --check-only --diff --profile=black ./ || { echo 'isort check failed!'; exit 1; } && + isort --check-only --diff --profile=black ./ && echo 'Running flake8 check...' && - flake8 --config=.flake8 ./ || { echo 'Flake8 check failed!'; exit 1; } && + flake8 --config=.flake8 ./ && echo 'Running pylint check...' && - pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ || { echo 'Pylint check failed!'; exit 1; } && + pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ && echo 'All code quality checks passed!'" - migration-check: - name: Django Migration Check - runs-on: ubuntu-latest - needs: lint - if: github.event_name == 'pull_request' - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Install Docker Compose - run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - - - name: Django Migration Checker + - name: Django Migration Check + if: github.event_name == 'pull_request' run: | docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev django python manage.py makemigrations --check --dry-run - build: - name: Docker Build + build-and-test: + name: Build & Test runs-on: ubuntu-latest - needs: lint + needs: quality-check steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - - name: System configuration - run: | - sudo rm -f /etc/boto.cfg - mkdir -p $HOME/.config/pip - echo "[build_ext]" > $HOME/.config/pip/pip.conf - echo "parallel = 1" >> $HOME/.config/pip/pip.conf - ulimit -u 16384 # Increase process/thread limit - ulimit -n 4096 # Increase open file limit - - - name: Install Docker Compose - run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - name: Docker login if: github.event_name == 'push' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build Docker image - run: docker-compose --profile worker --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} - - - name: Cache Docker images - uses: actions/cache@v3 + - name: Build Docker images + run: | + docker-compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} + + - name: Setup Python for backend tests + uses: actions/setup-python@v4 with: - path: /var/lib/docker - key: ${{ runner.os }}-docker-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-docker- + python-version: '3.9' + cache: 'pip' - frontend-test: - name: Frontend Tests - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v3 + - name: Install test dependencies + run: pip install awscli==1.18.66 coveralls - - name: Install Docker Compose - run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - - name: Setup Chrome + - name: Setup display for frontend tests run: | - export CHROME_BIN=chromium-browser - - - name: Setup display for browser tests - run: | - export DISPLAY=:99 - sudo apt-get install -y xvfb + sudo apt-get update + sudo apt-get install -y xvfb chromium-browser Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - - - name: Run frontend tests - run: docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" - - - backend-test: - name: Backend Tests - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v3 - - name: Install Docker Compose + - name: Run frontend tests run: | - sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - docker-compose --version - - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9.21 - - - name: Install dependencies - run: pip install awscli==1.18.66 coveralls + docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" - name: Run backend tests run: | docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc - + - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 + with: + fail_ci_if_error: false - - name: Coveralls + - name: Upload coverage to Coveralls continue-on-error: true env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} run: | - echo "Attempting to submit coverage to Coveralls..." - coveralls --rcfile=.coveragerc || echo "Coveralls submission failed, but continuing workflow" - + coveralls --rcfile=.coveragerc || echo "Coveralls submission failed, continuing..." + deploy: - name: Package & Deploy + name: Deploy & Notify runs-on: ubuntu-latest - needs: [frontend-test, backend-test] + needs: build-and-test if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') + environment: production steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: Setup Python 3.9 uses: actions/setup-python@v4 with: - python-version: 3.9.21 + python-version: '3.9' + cache: 'pip' - - name: Install dependencies + - name: Install deployment dependencies run: pip install awscli==1.18.66 - - name: Setup SSH key for deployment + - name: Configure SSH run: | mkdir -p ~/.ssh echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts - - - name: Run deployment scripts + + - name: Deploy services run: | - export SSH_AUTH_SOCK=/tmp/ssh_agent.sock - ssh-agent -a $SSH_AUTH_SOCK > /dev/null + eval "$(ssh-agent -s)" ssh-add ~/.ssh/deploy_key ./scripts/deployment/push.sh - ./scripts/deployment/deploy.sh auto_deploy \ No newline at end of file + ./scripts/deployment/deploy.sh auto_deploy + + - name: Notify on failure + if: failure() + uses: 8398a7/action-slack@v3 + with: + status: failure + channel: '#ci-cd' + webhook_url: ${{ secrets.SLACK_WEBHOOK }} + + - name: Notify on success + if: success() + uses: 8398a7/action-slack@v3 + with: + status: success + channel: '#ci-cd' + webhook_url: ${{ secrets.SLACK_WEBHOOK }} From 390f179ebe5af8d9bb2573eb0fbdbd3c066969f7 Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Thu, 10 Jul 2025 00:56:53 +0530 Subject: [PATCH 11/19] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9f3b21d0d8..8ce0df729b 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -41,7 +41,7 @@ jobs: - name: Run code quality checks run: | - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev -e VERBOSE=1 django bash -c " + docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test -e VERBOSE=1 django bash -c " echo 'Installing linting tools...' && pip install black==24.8.0 flake8==3.8.2 pylint==3.3.6 isort==5.12.0 && echo 'Running black check...' && @@ -57,7 +57,7 @@ jobs: - name: Django Migration Check if: github.event_name == 'pull_request' run: | - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.dev django python manage.py makemigrations --check --dry-run + docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py makemigrations --check --dry-run build-and-test: name: Build & Test From 99afd722dc3ad3c77aad1ad60fd32f85f87c5621 Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Thu, 10 Jul 2025 01:00:33 +0530 Subject: [PATCH 12/19] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 8ce0df729b..0c6f25c0d5 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -41,7 +41,7 @@ jobs: - name: Run code quality checks run: | - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test -e VERBOSE=1 django bash -c " + docker compose run -e DJANGO_SETTINGS_MODULE=settings.test -e VERBOSE=1 django bash -c " echo 'Installing linting tools...' && pip install black==24.8.0 flake8==3.8.2 pylint==3.3.6 isort==5.12.0 && echo 'Running black check...' && @@ -57,7 +57,7 @@ jobs: - name: Django Migration Check if: github.event_name == 'pull_request' run: | - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py makemigrations --check --dry-run + docker compose run -e DJANGO_SETTINGS_MODULE=settings.dev django python manage.py makemigrations --check --dry-run build-and-test: name: Build & Test @@ -86,7 +86,7 @@ jobs: - name: Build Docker images run: | - docker-compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} + docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} - name: Setup Python for backend tests uses: actions/setup-python@v4 @@ -105,12 +105,12 @@ jobs: - name: Run frontend tests run: | - docker-compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" + docker compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" - name: Run backend tests run: | - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput - docker-compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc + docker compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput + docker compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 From e7a690e4c47ecb63106d35f1a9b6b907d0bb1e11 Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Thu, 10 Jul 2025 01:09:04 +0530 Subject: [PATCH 13/19] Modify workflow to reduce redundant lines --- .github/workflows/ci-cd.yml | 57 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 0c6f25c0d5..72f2930879 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -11,6 +11,8 @@ env: COMPOSE_BAKE_ARGS: "--build-arg PIP_NO_CACHE_DIR=1" CHROME_BIN: chromium-browser DISPLAY: :99.0 + PYTHON_VERSION: '3.9' + AWSCLI_VERSION: '1.18.66' jobs: quality-check: @@ -21,8 +23,20 @@ jobs: with: fetch-depth: 0 - - name: System configuration + - name: Setup Python and dependencies + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: 'pip' + + - name: Setup Docker Compose + uses: docker/setup-compose-action@v1 + with: + version: latest + + - name: Install dependencies and configure system run: | + pip install awscli==${{ env.AWSCLI_VERSION }} sudo rm -f /etc/boto.cfg mkdir -p $HOME/.config/pip echo "[build_ext]" > $HOME/.config/pip/pip.conf @@ -30,15 +44,6 @@ jobs: ulimit -u 16384 ulimit -n 4096 - - name: Setup Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: '3.9' - cache: 'pip' - - - name: Install dependencies - run: pip install awscli==1.18.66 - - name: Run code quality checks run: | docker compose run -e DJANGO_SETTINGS_MODULE=settings.test -e VERBOSE=1 django bash -c " @@ -66,8 +71,21 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Setup Python and dependencies + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: 'pip' + + - name: Setup Docker environment + run: | + docker buildx create --use + pip install awscli==${{ env.AWSCLI_VERSION }} coveralls + + - name: Setup Docker Compose + uses: docker/setup-compose-action@v1 + with: + version: latest - name: Cache Docker layers uses: actions/cache@v3 @@ -88,15 +106,6 @@ jobs: run: | docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} - - name: Setup Python for backend tests - uses: actions/setup-python@v4 - with: - python-version: '3.9' - cache: 'pip' - - - name: Install test dependencies - run: pip install awscli==1.18.66 coveralls - - name: Setup display for frontend tests run: | sudo apt-get update @@ -133,14 +142,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Python 3.9 + - name: Setup Python and dependencies uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: ${{ env.PYTHON_VERSION }} cache: 'pip' - name: Install deployment dependencies - run: pip install awscli==1.18.66 + run: pip install awscli==${{ env.AWSCLI_VERSION }} - name: Configure SSH run: | From 37ef6907ca6d86247e18506ab0ac2875900e74de Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Thu, 10 Jul 2025 01:39:26 +0530 Subject: [PATCH 14/19] Run jobs in parallel --- .github/workflows/ci-cd.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 72f2930879..bd74fad5d8 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -67,7 +67,7 @@ jobs: build-and-test: name: Build & Test runs-on: ubuntu-latest - needs: quality-check + # REMOVED: needs: quality-check <-- This enables parallel execution steps: - uses: actions/checkout@v4 @@ -136,7 +136,7 @@ jobs: deploy: name: Deploy & Notify runs-on: ubuntu-latest - needs: build-and-test + needs: [build-and-test, quality-check] # MODIFIED: Now depends on both jobs if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') environment: production steps: @@ -176,7 +176,7 @@ jobs: - name: Notify on success if: success() - uses: 8398a7/action-slack@v3 + uses: 8398a7/action-slug@v3 with: status: success channel: '#ci-cd' From 0e0370781e439bcbeb3d3234a46bced98a8ddfa3 Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Thu, 10 Jul 2025 01:54:14 +0530 Subject: [PATCH 15/19] Build docker image in parallel --- .github/workflows/ci-cd.yml | 64 ++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index bd74fad5d8..a9d21b0d73 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -64,28 +64,20 @@ jobs: run: | docker compose run -e DJANGO_SETTINGS_MODULE=settings.dev django python manage.py makemigrations --check --dry-run - build-and-test: - name: Build & Test + build-docker: + name: Build Docker Images runs-on: ubuntu-latest - # REMOVED: needs: quality-check <-- This enables parallel execution steps: - uses: actions/checkout@v4 - - name: Setup Python and dependencies - uses: actions/setup-python@v4 + - name: Setup Docker Compose + uses: docker/setup-compose-action@v1 with: - python-version: ${{ env.PYTHON_VERSION }} - cache: 'pip' + version: latest - name: Setup Docker environment run: | docker buildx create --use - pip install awscli==${{ env.AWSCLI_VERSION }} coveralls - - - name: Setup Docker Compose - uses: docker/setup-compose-action@v1 - with: - version: latest - name: Cache Docker layers uses: actions/cache@v3 @@ -106,6 +98,48 @@ jobs: run: | docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} + - name: Save Docker images + run: | + docker save $(docker images --format "table {{.Repository}}:{{.Tag}}" | grep -v REPOSITORY | tr '\n' ' ') -o /tmp/docker-images.tar + + - name: Upload Docker images + uses: actions/upload-artifact@v3 + with: + name: docker-images + path: /tmp/docker-images.tar + retention-days: 1 + + test: + name: Run Tests + runs-on: ubuntu-latest + needs: build-docker + steps: + - uses: actions/checkout@v4 + + - name: Setup Python and dependencies + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: 'pip' + + - name: Setup Docker Compose + uses: docker/setup-compose-action@v1 + with: + version: latest + + - name: Install test dependencies + run: pip install awscli==${{ env.AWSCLI_VERSION }} coveralls + + - name: Download Docker images + uses: actions/download-artifact@v3 + with: + name: docker-images + path: /tmp + + - name: Load Docker images + run: | + docker load -i /tmp/docker-images.tar + - name: Setup display for frontend tests run: | sudo apt-get update @@ -136,7 +170,7 @@ jobs: deploy: name: Deploy & Notify runs-on: ubuntu-latest - needs: [build-and-test, quality-check] # MODIFIED: Now depends on both jobs + needs: [test, quality-check] if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') environment: production steps: @@ -176,7 +210,7 @@ jobs: - name: Notify on success if: success() - uses: 8398a7/action-slug@v3 + uses: 8398a7/action-slack@v3 with: status: success channel: '#ci-cd' From 1de5c6d353fc7ba165c0a326725466dd47793672 Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Thu, 10 Jul 2025 01:59:52 +0530 Subject: [PATCH 16/19] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a9d21b0d73..7fedf1f963 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -103,7 +103,7 @@ jobs: docker save $(docker images --format "table {{.Repository}}:{{.Tag}}" | grep -v REPOSITORY | tr '\n' ' ') -o /tmp/docker-images.tar - name: Upload Docker images - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: docker-images path: /tmp/docker-images.tar From 32dcfdfc1ea4454e6a6ddd5dacd788142bf8d208 Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Thu, 10 Jul 2025 02:13:53 +0530 Subject: [PATCH 17/19] Update ci-cd.yml --- .github/workflows/ci-cd.yml | 84 +++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 7fedf1f963..0f5480ce64 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -13,6 +13,8 @@ env: DISPLAY: :99.0 PYTHON_VERSION: '3.9' AWSCLI_VERSION: '1.18.66' + REGISTRY: ${{ secrets.DOCKER_USERNAME }} + IMAGE_TAG: ${{ github.sha }} jobs: quality-check: @@ -24,7 +26,7 @@ jobs: fetch-depth: 0 - name: Setup Python and dependencies - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} cache: 'pip' @@ -64,9 +66,11 @@ jobs: run: | docker compose run -e DJANGO_SETTINGS_MODULE=settings.dev django python manage.py makemigrations --check --dry-run - build-docker: - name: Build Docker Images + build-and-push: + name: Build & Push Docker Images runs-on: ubuntu-latest + outputs: + image-digest: ${{ steps.build.outputs.digest }} steps: - uses: actions/checkout@v4 @@ -75,12 +79,11 @@ jobs: with: version: latest - - name: Setup Docker environment - run: | - docker buildx create --use + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Cache Docker layers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} @@ -88,36 +91,46 @@ jobs: ${{ runner.os }}-buildx- - name: Docker login - if: github.event_name == 'push' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build Docker images + - name: Build and push Docker images + id: build run: | + # Build and push images with unique tags + docker buildx build \ + --cache-from type=local,src=/tmp/.buildx-cache \ + --cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max \ + --push \ + --tag ${{ env.REGISTRY }}/evalai:${{ env.IMAGE_TAG }} \ + --tag ${{ env.REGISTRY }}/evalai:latest \ + . + + # Build compose services and push + export COMPOSE_DOCKER_CLI_BUILD=1 + export DOCKER_BUILDKIT=1 + docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} - - - name: Save Docker images - run: | - docker save $(docker images --format "table {{.Repository}}:{{.Tag}}" | grep -v REPOSITORY | tr '\n' ' ') -o /tmp/docker-images.tar - - - name: Upload Docker images - uses: actions/upload-artifact@v4 - with: - name: docker-images - path: /tmp/docker-images.tar - retention-days: 1 + docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd push + + # Clean up cache + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache test: name: Run Tests runs-on: ubuntu-latest - needs: build-docker + strategy: + matrix: + test-type: [frontend, backend] + fail-fast: false steps: - uses: actions/checkout@v4 - name: Setup Python and dependencies - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} cache: 'pip' @@ -127,40 +140,47 @@ jobs: with: version: latest + - name: Docker login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Install test dependencies run: pip install awscli==${{ env.AWSCLI_VERSION }} coveralls - - name: Download Docker images - uses: actions/download-artifact@v3 - with: - name: docker-images - path: /tmp - - - name: Load Docker images + - name: Pull Docker images run: | - docker load -i /tmp/docker-images.tar + # Pull the latest images (they might be building in parallel) + timeout 300 bash -c 'until docker pull ${{ env.REGISTRY }}/evalai:${{ env.IMAGE_TAG }} 2>/dev/null; do echo "Waiting for image..."; sleep 10; done' + docker compose pull - name: Setup display for frontend tests + if: matrix.test-type == 'frontend' run: | sudo apt-get update sudo apt-get install -y xvfb chromium-browser Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - name: Run frontend tests + if: matrix.test-type == 'frontend' run: | docker compose run nodejs bash -c "gulp dev && karma start --single-run && gulp staging" - name: Run backend tests + if: matrix.test-type == 'backend' run: | docker compose run -e DJANGO_SETTINGS_MODULE=settings.test django python manage.py flush --noinput docker compose run -e DJANGO_SETTINGS_MODULE=settings.test django pytest --cov . --cov-config .coveragerc - name: Upload coverage to Codecov + if: matrix.test-type == 'backend' uses: codecov/codecov-action@v3 with: fail_ci_if_error: false - name: Upload coverage to Coveralls + if: matrix.test-type == 'backend' continue-on-error: true env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} @@ -170,14 +190,14 @@ jobs: deploy: name: Deploy & Notify runs-on: ubuntu-latest - needs: [test, quality-check] + needs: [build-and-push, test, quality-check] if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') environment: production steps: - uses: actions/checkout@v4 - name: Setup Python and dependencies - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} cache: 'pip' From c6092c16feee403979f64c8896bbafc5c2f14f3b Mon Sep 17 00:00:00 2001 From: ZahedR_327 Date: Thu, 10 Jul 2025 02:19:32 +0530 Subject: [PATCH 18/19] Restructure workflow to minimise build time --- .github/workflows/ci-cd.yml | 74 +++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 0f5480ce64..936591a606 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -11,7 +11,7 @@ env: COMPOSE_BAKE_ARGS: "--build-arg PIP_NO_CACHE_DIR=1" CHROME_BIN: chromium-browser DISPLAY: :99.0 - PYTHON_VERSION: '3.9' + PYTHON_VERSION: '3.9.21' AWSCLI_VERSION: '1.18.66' REGISTRY: ${{ secrets.DOCKER_USERNAME }} IMAGE_TAG: ${{ github.sha }} @@ -38,6 +38,7 @@ jobs: - name: Install dependencies and configure system run: | + pip install --upgrade pip pip install awscli==${{ env.AWSCLI_VERSION }} sudo rm -f /etc/boto.cfg mkdir -p $HOME/.config/pip @@ -48,17 +49,17 @@ jobs: - name: Run code quality checks run: | - docker compose run -e DJANGO_SETTINGS_MODULE=settings.test -e VERBOSE=1 django bash -c " - echo 'Installing linting tools...' && + docker compose run -e DJANGO_SETTINGS_MODULE=settings.dev -e VERBOSE=1 django bash -c " + echo 'Installing black, flake8, pylint and isort...' && pip install black==24.8.0 flake8==3.8.2 pylint==3.3.6 isort==5.12.0 && echo 'Running black check...' && - black --check --diff ./ && + black --check --diff ./ || { echo 'Black check failed!'; exit 1; } && echo 'Running isort check...' && - isort --check-only --diff --profile=black ./ && + isort --check-only --diff --profile=black ./ || { echo 'isort check failed!'; exit 1; } && echo 'Running flake8 check...' && - flake8 --config=.flake8 ./ && + flake8 --config=.flake8 ./ || { echo 'Flake8 check failed!'; exit 1; } && echo 'Running pylint check...' && - pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ && + pylint --rcfile=.pylintrc --output-format=colorized --score=y --fail-under=7.5 ./ || { echo 'Pylint check failed!'; exit 1; } && echo 'All code quality checks passed!'" - name: Django Migration Check @@ -69,6 +70,7 @@ jobs: build-and-push: name: Build & Push Docker Images runs-on: ubuntu-latest + # REMOVED: No dependencies - runs in parallel outputs: image-digest: ${{ steps.build.outputs.digest }} steps: @@ -91,6 +93,7 @@ jobs: ${{ runner.os }}-buildx- - name: Docker login + if: github.event_name == 'push' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -99,29 +102,19 @@ jobs: - name: Build and push Docker images id: build run: | - # Build and push images with unique tags - docker buildx build \ - --cache-from type=local,src=/tmp/.buildx-cache \ - --cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max \ - --push \ - --tag ${{ env.REGISTRY }}/evalai:${{ env.IMAGE_TAG }} \ - --tag ${{ env.REGISTRY }}/evalai:latest \ - . - - # Build compose services and push export COMPOSE_DOCKER_CLI_BUILD=1 export DOCKER_BUILDKIT=1 docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} - docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd push - # Clean up cache - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + if [ "${{ github.event_name }}" = "push" ]; then + docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd push + fi test: name: Run Tests runs-on: ubuntu-latest + # REMOVED: No dependencies - runs in parallel with build strategy: matrix: test-type: [frontend, backend] @@ -140,20 +133,14 @@ jobs: with: version: latest - - name: Docker login - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Install test dependencies - run: pip install awscli==${{ env.AWSCLI_VERSION }} coveralls + run: | + pip install --upgrade pip + pip install awscli==${{ env.AWSCLI_VERSION }} coveralls - - name: Pull Docker images + - name: Build images for testing (if not available) run: | - # Pull the latest images (they might be building in parallel) - timeout 300 bash -c 'until docker pull ${{ env.REGISTRY }}/evalai:${{ env.IMAGE_TAG }} 2>/dev/null; do echo "Waiting for image..."; sleep 10; done' - docker compose pull + docker compose --profile worker_py3_7 --profile worker_py3_8 --profile worker_py3_9 --profile statsd build ${{ env.COMPOSE_BAKE_ARGS }} - name: Setup display for frontend tests if: matrix.test-type == 'frontend' @@ -175,9 +162,8 @@ jobs: - name: Upload coverage to Codecov if: matrix.test-type == 'backend' - uses: codecov/codecov-action@v3 - with: - fail_ci_if_error: false + run: | + bash <(curl -s https://codecov.io/bash) - name: Upload coverage to Coveralls if: matrix.test-type == 'backend' @@ -185,12 +171,12 @@ jobs: env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} run: | - coveralls --rcfile=.coveragerc || echo "Coveralls submission failed, continuing..." + coveralls --rcfile=.coveragerc deploy: - name: Deploy & Notify + name: Package & Deploy Services runs-on: ubuntu-latest - needs: [build-and-push, test, quality-check] + needs: [build-and-push, test, quality-check] # Waits for ALL jobs to complete if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') environment: production steps: @@ -203,10 +189,13 @@ jobs: cache: 'pip' - name: Install deployment dependencies - run: pip install awscli==${{ env.AWSCLI_VERSION }} + run: | + pip install --upgrade pip + pip install awscli==${{ env.AWSCLI_VERSION }} - - name: Configure SSH + - name: Configure SSH and decrypt keys run: | + eval "$(ssh-agent -s)" mkdir -p ~/.ssh echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key @@ -215,11 +204,14 @@ jobs: - name: Deploy services run: | - eval "$(ssh-agent -s)" ssh-add ~/.ssh/deploy_key ./scripts/deployment/push.sh ./scripts/deployment/deploy.sh auto_deploy + - name: Clean up pip cache + run: | + rm -f $HOME/.cache/pip/log/debug.log + - name: Notify on failure if: failure() uses: 8398a7/action-slack@v3 From 88290cb4764fbf50d007283b4afbd14b87f48726 Mon Sep 17 00:00:00 2001 From: Zahed-Riyaz Date: Tue, 22 Jul 2025 03:42:51 +0530 Subject: [PATCH 19/19] Update env var --- docker/prod/celery/Dockerfile | 4 ++-- scripts/deployment/deploy.sh | 6 +++--- scripts/deployment/deploy_ec2_worker.sh | 2 +- scripts/deployment/push.sh | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docker/prod/celery/Dockerfile b/docker/prod/celery/Dockerfile index c05b7a9daf..c034b12f0e 100644 --- a/docker/prod/celery/Dockerfile +++ b/docker/prod/celery/Dockerfile @@ -1,7 +1,7 @@ ARG AWS_ACCOUNT_ID ARG COMMIT_ID -ARG GITHUB_REF_NAME +ARG GITHUB_BRANCH_NAME -FROM ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/evalai-${GITHUB_REF_NAME}-backend:${COMMIT_ID} +FROM ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/evalai-${GITHUB_BRANCH_NAME}-backend:${COMMIT_ID} CMD ["sh", "/code/docker/prod/celery/container-start.sh"] diff --git a/scripts/deployment/deploy.sh b/scripts/deployment/deploy.sh index 4e91acc425..ec9ec58506 100755 --- a/scripts/deployment/deploy.sh +++ b/scripts/deployment/deploy.sh @@ -17,11 +17,11 @@ if [ -z ${COMMIT_ID} ]; then export COMMIT_ID="latest" fi -if [ -z ${GITHUB_REF_NAME} ]; then - echo "Please set the GITHUB_REF_NAME first." +if [ -z ${GITHUB_BRANCH_NAME} ]; then + echo "Please set the GITHUB_BRANCH_NAME first." fi -env=${GITHUB_REF_NAME} +env=${GITHUB_BRANCH_NAME} JUMPBOX=${JUMPBOX_INSTANCE} if [[ ${env} == "production" ]]; then diff --git a/scripts/deployment/deploy_ec2_worker.sh b/scripts/deployment/deploy_ec2_worker.sh index 8909c852ed..1b0b02c3e0 100644 --- a/scripts/deployment/deploy_ec2_worker.sh +++ b/scripts/deployment/deploy_ec2_worker.sh @@ -33,7 +33,7 @@ aws configure set default.region ${AWS_REGION} export AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID} export COMMIT_ID="latest" export AWS_DEFAULT_REGION=${AWS_REGION} -export GITHUB_REF_NAME=${ENVIRONMENT} +export GITHUB_BRANCH_NAME=${ENVIRONMENT} eval $(aws ecr get-login --no-include-email) # Step 7: Copying Docker environment file diff --git a/scripts/deployment/push.sh b/scripts/deployment/push.sh index 4ceb2f8d95..27db44a10d 100755 --- a/scripts/deployment/push.sh +++ b/scripts/deployment/push.sh @@ -9,11 +9,11 @@ build_and_push() { echo "Pulling ssl certificates and nginx configuration..." aws s3 cp s3://cloudcv-secrets/eval.ai/ssl/ ./ssl/ --recursive # Need ssl files related to *.cloudcv.org since we want to provide backward compatibility - aws s3 cp s3://cloudcv-secrets/evalai/${GITHUB_REF_NAME}/ssl/ ./ssl/ --recursive + aws s3 cp s3://cloudcv-secrets/evalai/${GITHUB_BRANCH_NAME}/ssl/ ./ssl/ --recursive echo "Pulled ssl certificates and nginx configuration successfully" docker-compose -f docker-compose-$1.yml build \ --build-arg COMMIT_ID=${COMMIT_ID} \ - --build-arg GITHUB_REF_NAME=${GITHUB_REF_NAME} \ + --build-arg GITHUB_BRANCH_NAME=${GITHUB_BRANCH_NAME} \ --build-arg AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID} --compress docker-compose -f docker-compose-$1.yml push @@ -32,8 +32,8 @@ build_and_push() { if [ "${GITHUB_EVENT_NAME}" != "push" ]; then echo "Skipping deploy to staging or production server; The request or commit is not on staging or production branch" exit 0 -elif [ "${GITHUB_REF_NAME}" == "staging" -o "${GITHUB_REF_NAME}" == "production" ]; then - build_and_push $GITHUB_REF_NAME +elif [ "${GITHUB_BRANCH_NAME}" == "staging" -o "${GITHUB_BRANCH_NAME}" == "production" ]; then + build_and_push $GITHUB_BRANCH_NAME exit 0 else echo "Skipping deploy!"