whoops #630
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
| # Generated by cdkactions. Do not modify | |
| # Generated as part of the 'platform' stack. | |
| name: Build and Deploy | |
| on: push | |
| jobs: | |
| django-check: | |
| name: Django Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Cache | |
| uses: actions/cache@v2 | |
| with: | |
| path: ~/.local/share/virtualenvs | |
| key: v0-${{ hashFiles('backend/Pipfile.lock') }} | |
| - name: Install Dependencies | |
| run: |- | |
| cd backend | |
| pip install pipenv | |
| pipenv install --deploy --dev | |
| - name: Lint (flake8) | |
| run: |- | |
| cd backend | |
| pipenv run flake8 . | |
| - name: Lint (black) | |
| run: |- | |
| cd backend | |
| pipenv run black --check . | |
| - name: Test (run in parallel) | |
| run: |- | |
| cd backend | |
| pipenv run coverage run --concurrency=multiprocessing manage.py test --settings=Platform.settings.ci --parallel | |
| pipenv run coverage combine | |
| - name: Upload Code Coverage | |
| run: |- | |
| ROOT=$(pwd) | |
| cd backend | |
| pipenv run codecov --root $ROOT --flags backend | |
| container: | |
| image: python:3.8-buster | |
| env: | |
| DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres | |
| services: | |
| postgres: | |
| image: postgres:12 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_DB: postgres | |
| POSTGRES_PASSWORD: postgres | |
| options: "--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5" | |
| publish-backend: | |
| name: Publish backend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - uses: docker/setup-qemu-action@v1 | |
| - uses: docker/setup-buildx-action@v1 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v2 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: buildx-publish-backend | |
| - uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build/Publish | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: backend | |
| file: backend/Dockerfile | |
| push: ${{ github.ref == 'refs/heads/master' }} | |
| cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/platform-backend:latest | |
| cache-to: type=local,dest=/tmp/.buildx-cache | |
| tags: pennlabs/platform-backend:latest,pennlabs/platform-backend:${{ github.sha }} | |
| needs: django-check | |
| publish-platform-dev: | |
| name: Publish platform-dev | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - uses: docker/setup-qemu-action@v1 | |
| - uses: docker/setup-buildx-action@v1 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v2 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: buildx-publish-platform-dev | |
| - uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build/Publish | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: backend | |
| file: backend/Dockerfile.dev | |
| push: ${{ github.ref == 'refs/heads/master' }} | |
| cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/platform-dev:latest | |
| cache-to: type=local,dest=/tmp/.buildx-cache | |
| tags: pennlabs/platform-dev:latest,pennlabs/platform-dev:${{ github.sha }} | |
| needs: django-check | |
| react-check: | |
| name: React Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Cache | |
| uses: actions/cache@v2 | |
| with: | |
| path: "**/node_modules" | |
| key: v0-${{ hashFiles('frontend/yarn.lock') }} | |
| - name: Install Dependencies | |
| run: |- | |
| cd frontend | |
| yarn install --frozen-lockfile | |
| - name: Lint | |
| run: |- | |
| cd frontend | |
| yarn lint | |
| - name: Test | |
| run: |- | |
| cd frontend | |
| yarn test | |
| - name: Upload Code Coverage | |
| run: |- | |
| ROOT=$(pwd) | |
| cd frontend | |
| yarn run codecov -p $ROOT -F frontend | |
| container: | |
| image: node:14 | |
| publish-frontend: | |
| name: Publish frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - uses: docker/setup-qemu-action@v1 | |
| - uses: docker/setup-buildx-action@v1 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v2 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: buildx-publish-frontend | |
| - uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build/Publish | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: frontend | |
| file: frontend/Dockerfile | |
| push: ${{ github.ref == 'refs/heads/master' }} | |
| cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/platform-frontend:latest | |
| cache-to: type=local,dest=/tmp/.buildx-cache | |
| tags: pennlabs/platform-frontend:latest,pennlabs/platform-frontend:${{ github.sha }} | |
| needs: react-check | |
| deploy: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: pennlabs/helm-tools:39b60af248944898fcbc58d1fe5b0f1995420aef | |
| if: github.ref == 'refs/heads/master' | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Deploy | |
| run: |- | |
| aws eks --region us-east-1 update-kubeconfig --name production --role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/kubectl | |
| # get repo name (by removing owner/organization) | |
| RELEASE_NAME=${REPOSITORY#*/} | |
| # this specifies what tag of icarus to pull down | |
| DEPLOY_TAG=$(yq r k8s/values.yaml deploy_version) | |
| if [ "$DEPLOY_TAG" = "null" ]; then | |
| echo "Could not find deploy tag" | |
| exit 1 | |
| fi | |
| helm repo add pennlabs https://helm.pennlabs.org/ | |
| for i in {1..10}; do | |
| # This is bash soup, but it'll do. | |
| # 1. Attempt to install with helm | |
| # 2. If this succeeds, exit with a success status code | |
| # 3. If it fails, mark the command as succeeded so that '-e' doesn't kick us out | |
| # 4. Wait 10s and try again | |
| helm upgrade --install --atomic --set=image_tag=$IMAGE_TAG -f k8s/values.yaml --version "${DEPLOY_TAG}" $RELEASE_NAME pennlabs/icarus && exit 0 || true | |
| sleep 10s | |
| echo "Retrying deploy for $i times" | |
| done | |
| # If we get here, all helm installs failed so our command should fail | |
| exit 1 | |
| env: | |
| IMAGE_TAG: ${{ github.sha }} | |
| AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
| AWS_ACCESS_KEY_ID: ${{ secrets.GH_AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.GH_AWS_SECRET_ACCESS_KEY }} | |
| DO_AUTH_TOKEN: ${{ secrets.DO_AUTH_TOKEN }} | |
| REPOSITORY: ${{ github.repository }} | |
| needs: | |
| - publish-backend | |
| - publish-frontend | |
| - publish-platform-dev |