test: Add event E2E tests #190
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
on: | |
push: | |
branches: | |
- develop | |
paths: ['apps/api/**', '.github/workflows/api.yaml'] | |
tags: | |
- '*' | |
pull_request: | |
paths: ['apps/api/**', '.github/workflows/api.yaml'] | |
jobs: | |
validate: | |
runs-on: ubuntu-latest | |
name: Validate | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install packages | |
run: | | |
pnpm i | |
- name: Lint | |
run: | | |
pnpm run lint:api | |
- name: Unit tests | |
run: | | |
pnpm run db:generate-types | |
pnpm run test:api | |
- name: E2E tests | |
env: | |
GITHUB_CLIENT_ID: dummy | |
GITHUB_CLIENT_SECRET: dummy | |
GITHUB_CALLBACK_URL: dummy | |
run: pnpm run e2e:api | |
- name: Upload e2e test coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
flags: api-e2e-tests | |
files: /coverage-e2e/api/coverage-final.json | |
deploy-stage: | |
runs-on: ubuntu-latest | |
name: Deploy to stage | |
if: github.ref == 'refs/heads/develop' | |
needs: validate | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install fly CLI | |
run: | | |
curl -L https://fly.io/install.sh | sh | |
- name: Deploy to stage | |
run: ~/.fly/bin/fly deploy --config fly.api.toml --dockerfile ./apps/api/Dockerfile --app keyshade-api-stage --access-token ${{ secrets.FLY_ACCESS_TOKEN }} | |
build-api-release: | |
needs: validate | |
runs-on: ubuntu-latest | |
name: Build and push API docker image for release | |
if: ${{ startsWith(github.ref , 'refs/tags/')}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build Docker image | |
run: docker build -t keyshade/keyshade-api:${{ github.ref_name }} keyshade/keyshade-api:latest -f ./apps/api/Dockerfile . | |
- name: Push Docker image | |
run: docker push keyshade/keyshade-api |