Merge pull request #5 from felipe-loka/feat/instrumentation #12
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: Node.js CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
env: | |
PORT: "3000" | |
NODE_ENV: "development" | |
DB_USERNAME: "user" | |
DB_PASSWORD: "password123" | |
DB_NAME: "api" | |
DB_HOST: "localhost" | |
DB_PORT: "3306" | |
DATABASE_URL: "mysql://user:password123@localhost:3306/api" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Use PNPM as package manager | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20" | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run ESLint | |
run: pnpm exec eslint src/**/*.ts | |
- name: Build | |
run: pnpm build | |
- name: Run tests | |
run: | | |
pnpm infra:up | |
sleep 5 | |
pnpm test | |
- name: Build container and test health | |
run: | | |
docker build -t poll-api . | |
pnpm infra:up | |
docker container run -d -p 3000:3000 \ | |
--rm --name poll \ | |
-e DB_USERNAME='user' -e DB_PASSWORD='password123' \ | |
-e DB_NAME='api' -e DB_HOST='mysql' \ | |
-e DB_PORT='3306' -e NODE_ENV='development' \ | |
-e PORT='3000' \ | |
--network pollNetwork \ | |
poll-api | |
sleep 5 | |
curl localhost:3000/healthy |