Skip to content

Add Codecov to CI

Add Codecov to CI #43

Workflow file for this run

name: Testing and update Codecov
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
jobs:
update-codecov:
environment: prod
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Nécessaire pour récupérer tous les tags
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: "20.x"
- name: Use NPM to install dependencies
uses: actions/setup-node@v1
with:
node-version: "20.x"
- run: npm install
- name: Set .env file
run: |
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "DISCORD_SERVER_ID=${{ secrets.DISCORD_SERVER_ID }}" >> .env
echo "DISCORD_CHANNEL_ID=${{ secrets.DISCORD_CHANNEL_ID }}" >> .env
echo "DISCORD_SALAI_TOKEN=${{ secrets.DISCORD_SALAI_TOKEN }}" >> .env
echo "API_KEY=${{ secrets.API_KEY }}" >> .env
- name: Build application
run: npm run build
- name: Setup Firebase emulator
run: |
curl -sL https://firebase.tools | bash
echo $GCP_SA_KEY > $HOME/gcloud_service_key.json
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/gcloud_service_key.json"
env:
GCP_SA_KEY: ${{ secrets.FIREBASE_SA_KEY }}
- name: Run tests
run: |
export NODE_ENV=development
npm run firebase:emulator:ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
file: ./coverage/lcov.info
fail_ci_if_error: true