copy-sweep-roundup (ENG-1158) #2239
Workflow file for this run
This file contains 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
name: Ci branch | |
on: | |
pull_request: | |
branches: | |
- 'staging' | |
push: | |
branches: | |
- 'staging' | |
env: | |
BASE: ${{ github.ref == 'refs/heads/staging' && 'origin/master' || 'origin/staging' }} | |
HEROKU_API_KEY: ${{ secrets.HEROKU_API_TOKEN }} | |
SKYNET_API_KEY: ${{ secrets.SKYNET_API_KEY }} | |
PROTOCOL_FRONTEND_STAGING_SEED: ${{ secrets.PROTOCOL_FRONTEND_STAGING_SEED }} | |
CONTRIBUTION_REPORT_STAGING_SEED: ${{ secrets.CONTRIBUTION_REPORT_STAGING_SEED }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Install Foundry | |
uses: onbjerg/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
cache: 'yarn' | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 'pypy3.8' | |
- name: Frozen lock | |
run: yarn install --frozen-lockfile # optional, --immutable | |
- run: npm install -g @graphprotocol/graph-cli | |
- name: Install poetry | |
run: pip install poetry | |
- name: Install deps | |
run: yarn nx affected --target install --base $BASE | |
- name: Check Prettier | |
run: yarn check-prettier | |
- name: Create env file | |
run: | | |
touch .env | |
echo API_TOKEN= >> .env | |
echo CLIENT_ID= >> .env | |
echo BOT_DEBUG=true >> .env | |
echo REDIS_URL=redis://0.0.0.0:6379 >> .env | |
echo IS_DEV=True >> .env | |
echo GOVRN_GUILD_ID= >> .env | |
echo PROTOCOL_URL=http://localhost:4000/graphql >> .env | |
echo PROTOCOL_TOKEN= >> .env | |
echo TEST_CHANNEL= >> .env | |
echo TASK_WAKEUP_PERIOD_MINUTES= >> .env | |
echo WEEKLY_REPORT_MINIMUM_TIME_BETWEEN_LOOP_SECONDS= >> .env | |
echo WEEKLY_REPORT_WEEKDAY= >> .env | |
echo WEEKLY_REPORT_TIME= >> .env | |
echo WEEKLY_REPORT_ENABLE= >> .env | |
- run: yarn nx affected --target format --base $BASE | |
- run: yarn nx affected:lint --base $BASE | |
- name: Test | |
run: yarn nx affected:test --base $BASE | |
- name: Add frontend env vars | |
run: | | |
echo VITE_PROTOCOL_BASE_URL=https://api-staging.govrn.app >> .env | |
echo VITE_PROTOCOL_URL=https://api-staging.govrn.app/graphql >> .env | |
echo VITE_URL=${{secrets.VITE_URL_STAGING}} >> .env | |
echo VITE_INFURA_PROJECT_ID=${{secrets.VITE_INFURA_PROJECT_ID_STAGING}} >> .env | |
echo VITE_INFURA_PROJECT_SECRET=${{secrets.VITE_INFURA_PROJECT_SECRET_STAGING}} >> .env | |
echo VITE_LINEAR_REDIRECT_URI=https://api-staging.govrn.app/linear/oauth >> .env | |
echo VITE_LINEAR_CLIENT_ID=0cc73e0a21f8cd7087d78634a9e4e0ce >> .env | |
echo VITE_INFURA_SUBDOMAIN=https://govrn-staging.infura-ipfs.io >> .env | |
echo VITE_PUBLIC_ALCHEMY_KEY=${{ secrets.PUBLIC_ALCHEMY_KEY }} >> .env | |
echo VITE_STAGING_MODE=false >> .env | |
echo CLOUDFLARE_ACCOUNT_ID=${{ secrets.CLOUDFLARE_ACCOUNT_ID }} >> .env | |
echo CLOUDFLARE_API_TOKEN=${{ secrets.CLOUDFLARE_API_TOKEN }} >> .env | |
echo VITE_DISCORD_CLIENT_ID=${{secrets.DISCORD_CLIENT_ID}} >> .env | |
echo VITE_DISCORD_CLIENT_ID=${{secrets.DISCORD_STAGING_CLIENT_ID}} >> .env | |
echo VITE_DISCORD_REDIRECT_URI=https://api-staging.govrn.app/discord/oauth >> .env | |
echo VITE_BUILD_ENV=production >> .env | |
- name: Build | |
run: yarn nx affected:build --configuration production --base $BASE | |
- uses: actions/cache@v3 | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }} | |
docker-build: | |
if: ${{ github.ref == 'refs/heads/staging' }} | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Install Foundry | |
uses: onbjerg/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
cache: 'yarn' | |
- run: npm install -g @graphprotocol/graph-cli | |
- uses: actions/cache@v3 | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }} | |
- name: Docker Build | |
run: yarn nx affected --target docker-build --base $BASE --parallel --max-parallel=3 | |
env: | |
INPUT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker Login | |
run: yarn nx affected --target docker-login --base $BASE --parallel --max-parallel=3 | |
- name: Docker Push | |
run: yarn nx affected --target docker-push --base $BASE --parallel --max-parallel=3 | |
env: | |
INPUT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: npm install -g wrangler | |
- name: Deploy | |
run: yarn nx affected --target deployStaging --base $BASE --parallel --max-parallel=3 | |
- name: Verify | |
run: yarn nx affected --target verify --base $BASE --parallel --max-parallel=3 | |
cypress-run: | |
needs: build | |
runs-on: | |
ubuntu-20.04 | |
# Service containers to run with `runner-job` | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres | |
# Provide the password for postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: test | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
cache: 'yarn' | |
- uses: actions/cache@v3 | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }} | |
- name: Frozen lock | |
run: yarn install --frozen-lockfile # optional, --immutable | |
- name: Cypress install | |
run: ./node_modules/cypress/bin/cypress install | |
- name: Create env file | |
run: | | |
echo DATABASE_URL=postgresql://postgres:postgres@localhost:5432/test > .env | |
echo PROTOCOL_FRONTEND=http://localhost:3000 >> .env | |
echo CORS_ORIGIN=http://localhost:3000 >> .env | |
echo PROTOCOL_COOKIE_SECRET=asdfasjdfl >> .env | |
echo VITE_PROTOCOL_BASE_URL=http://localhost:4000 >> .env | |
echo VITE_PROTOCOL_URL=http://localhost:4000/graphql >> .env | |
echo VITE_URL=http://localhost:3000 >> .env | |
echo VITE_INFURA_PROJECT_ID=${{secrets.VITE_INFURA_PROJECT_ID_STAGING}} >> .env | |
echo VITE_INFURA_PROJECT_SECRET=${{secrets.VITE_INFURA_PROJECT_SECRET_STAGING}} >> .env | |
echo VITE_LINEAR_REDIRECT_URI=http://lochost:4000/linear/oauth >> .env | |
echo VITE_LINEAR_CLIENT_ID=0cc73e0a21f8cd7087d78634a9e4e0ce >> .env | |
echo VITE_INFURA_SUBDOMAIN=https://govrn-staging.infura-ipfs.io >> .env | |
echo VITE_STAGING_MODE=true >> .env | |
echo VITE_BUILD_ENV=production >> .env | |
echo VITE_PUBLIC_ALCHEMY_KEY=${{ secrets.PUBLIC_ALCHEMY_KEY }} >> .env | |
- name: Create Database | |
run: yarn nx run protocol-api:migrate | |
- name: Cypress run | |
uses: cypress-io/github-action@v4 | |
env: | |
DEBUG: 'cypress:server' | |
with: | |
start: yarn nx run protocol-api:serve | |
command: yarn nx run protocol-frontend-e2e:e2eTest --verbose | |
install: false | |
- uses: actions/upload-artifact@v2 | |
if: failure() | |
with: | |
name: cypress-screenshots | |
path: ./dist/cypress/apps/protocol-frontend-e2e/screenshots | |
# Test run video was always captured, so this action uses "always()" condition | |
- uses: actions/upload-artifact@v2 | |
if: always() | |
with: | |
name: cypress-videos | |
path: ./dist/cypress/apps/protocol-frontend-e2e/videos |