Skip to content

Commit

Permalink
Merge pull request #1 from felipe-loka/feature/basic-ci
Browse files Browse the repository at this point in the history
add CI workflow
  • Loading branch information
felipe-loka authored Nov 9, 2023
2 parents 35aa985 + 421c63c commit a37673e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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
7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ services:
mysql:
image: mysql:8.0
container_name: mysql
networks:
- pollNetwork
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ${DB_NAME}
Expand All @@ -13,3 +15,8 @@ services:
- "${DB_PORT}:${DB_PORT}"
restart: always
command: --default-authentication-plugin=mysql_native_password


networks:
pollNetwork:
name: pollNetwork

0 comments on commit a37673e

Please sign in to comment.