-
-
Notifications
You must be signed in to change notification settings - Fork 889
[Fix #4673] Migrate EvalAI CI/CD Workflow to Github Actions #4685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Zahed-Riyaz
wants to merge
20
commits into
Cloud-CV:master
Choose a base branch
from
Zahed-Riyaz:Migrate-CI/CD
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
cb83c32
add ci-cd workflow through github
Zahed-Riyaz 441057e
Omit .travis.yml
Zahed-Riyaz 68973b0
undo travis deletion
Zahed-Riyaz d38601f
fix backend testing
Zahed-Riyaz 88acee2
Modify travis env variables
Zahed-Riyaz 85eb021
Update travis variables to github actions
Zahed-Riyaz 3f4fb0c
Decommission Travis CI
Zahed-Riyaz b5fbab8
Add Github actions build status
Zahed-Riyaz 7ba09e2
Update README.md
Zahed-Riyaz 8a59611
Update ci-cd.yml
Zahed-Riyaz 390f179
Update ci-cd.yml
Zahed-Riyaz 99afd72
Update ci-cd.yml
Zahed-Riyaz e7a690e
Modify workflow to reduce redundant lines
Zahed-Riyaz 37ef690
Run jobs in parallel
Zahed-Riyaz 0e03707
Build docker image in parallel
Zahed-Riyaz 1de5c6d
Update ci-cd.yml
Zahed-Riyaz 32dcfdf
Update ci-cd.yml
Zahed-Riyaz c6092c1
Restructure workflow to minimise build time
Zahed-Riyaz 88290cb
Update env var
Zahed-Riyaz 447843e
Merge branch 'master' into Migrate-CI/CD
Zahed-Riyaz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
service_name: travis-ci | ||
service_name: github-actions | ||
repo_token: s4vXsUN3KoBjArm1eb7o1jg0RQHYIBr0R |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
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" | ||
CHROME_BIN: chromium-browser | ||
DISPLAY: :99.0 | ||
PYTHON_VERSION: '3.9.21' | ||
AWSCLI_VERSION: '1.18.66' | ||
REGISTRY: ${{ secrets.DOCKER_USERNAME }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
|
||
jobs: | ||
quality-check: | ||
name: Code Quality & Migration Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python and dependencies | ||
uses: actions/setup-python@v5 | ||
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 --upgrade pip | ||
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 | ||
echo "parallel = 1" >> $HOME/.config/pip/pip.conf | ||
ulimit -u 16384 | ||
ulimit -n 4096 | ||
|
||
- 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...' && | ||
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!'" | ||
|
||
- 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-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: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Docker Compose | ||
uses: docker/setup-compose-action@v1 | ||
with: | ||
version: latest | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- 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@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push Docker images | ||
id: build | ||
run: | | ||
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 }} | ||
|
||
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] | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Python and dependencies | ||
uses: actions/setup-python@v5 | ||
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 --upgrade pip | ||
pip install awscli==${{ env.AWSCLI_VERSION }} coveralls | ||
|
||
- name: Build images for testing (if not available) | ||
run: | | ||
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' | ||
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' | ||
run: | | ||
bash <(curl -s https://codecov.io/bash) | ||
|
||
- name: Upload coverage to Coveralls | ||
if: matrix.test-type == 'backend' | ||
continue-on-error: true | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | ||
run: | | ||
coveralls --rcfile=.coveragerc | ||
|
||
deploy: | ||
name: Package & Deploy Services | ||
runs-on: ubuntu-latest | ||
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: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Python and dependencies | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: 'pip' | ||
|
||
- name: Install deployment dependencies | ||
run: | | ||
pip install --upgrade pip | ||
pip install awscli==${{ env.AWSCLI_VERSION }} | ||
|
||
- 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 | ||
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts | ||
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts | ||
|
||
- name: Deploy services | ||
run: | | ||
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 | ||
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 }} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
ARG AWS_ACCOUNT_ID | ||
ARG COMMIT_ID | ||
ARG TRAVIS_BRANCH | ||
ARG GITHUB_BRANCH_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_BRANCH_NAME}-backend:${COMMIT_ID} | ||
|
||
CMD ["sh", "/code/docker/prod/celery/container-start.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.