Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[be] chore: Update to use yarn #53

Merged
merged 6 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/backend-contract-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Use Node.js 18.x
uses: actions/setup-node@v3
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x

- name: Create .env file
run: |
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" > .env

- name: Start service in docker
run: |
npm run docker:up
yarn docker:up

- name: Wait for service to start
run: |
Expand All @@ -47,9 +47,9 @@ jobs:

- name: Run Contract Tests
run: |
npm ci
npm run test:contract
yarn
yarn test:contract

- name: Stop service in docker
run: |
npm run docker:down
yarn docker:down
2 changes: 1 addition & 1 deletion .github/workflows/backend-docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
env:
IMAGE_TAG: ${{ steps.extract_version.outputs.VERSION }}
run: |
npm run docker:app:build
yarn docker:app:build
docker tag notes-app-be:latest ${{ secrets.DOCKERHUB_USERNAME }}/notes-app-be:$IMAGE_TAG
docker push ${{ secrets.DOCKERHUB_USERNAME }}/notes-app-be:$IMAGE_TAG
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Backend Service Tests
name: Backend e2e Tests

on:
push:
Expand All @@ -20,22 +20,24 @@ jobs:
env:
API_URL: http://localhost:5000
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Use Node.js 18.x
uses: actions/setup-node@v3
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x

- name: Create .env file
run: echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" > .env
run: |
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" > .env
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env

- name: Start service in docker
run: |
npm run docker:up
yarn docker:up

- name: Wait for service to start
run: |
Expand All @@ -47,11 +49,11 @@ jobs:
- name: Test connectivity
run: curl ${API_URL}

- name: Run Service Tests
- name: Run e2e Tests
run: |
npm ci
npm run test:service
yarn
yarn test:e2e

- name: Stop service in docker
run: |
npm run docker:down
yarn docker:down
14 changes: 7 additions & 7 deletions .github/workflows/backend-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 18.x
uses: actions/setup-node@v3
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x

- name: Install and build
run: |
npm ci
npm run build
yarn
yarn build

- name: Integration Tests with Coverage
run: npm run test:coverage
run: yarn test:coverage

- name: Coverage Report
uses: romeovs/[email protected]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/backend-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install packages
run: npm ci
run: yarn

- name: Run ESLint
run: npm run lint
run: yarn lint
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ Refactored the app for testability and added a few additional tweaks.
- [Primsa](https://www.prisma.io/) (DB ORM)

### BE Tests
[![Backend Service Tests](https://github.com/helloitsdave/notes-app-full-stack-testing/actions/workflows/backend-service-tests.yml/badge.svg)](https://github.com/helloitsdave/notes-app-full-stack-testing/actions/workflows/backend-service-tests.yml)
[![Backend e2e Tests](https://github.com/helloitsdave/notes-app-full-stack-testing/actions/workflows/backend-e2e-tests.yml/badge.svg)](https://github.com/helloitsdave/notes-app-full-stack-testing/actions/workflows/backend-e2e-tests.yml)
[![Backend Integration Tests](https://github.com/helloitsdave/notes-app-full-stack-testing/actions/workflows/backend-integration-tests.yml/badge.svg)](https://github.com/helloitsdave/notes-app-full-stack-testing/actions/workflows/backend-integration-tests.yml)

- Service tests with docker, [supertest](https://github.com/ladjs/supertest) and [vitest](https://vitest.dev/)
- e2e tests with docker, [supertest](https://github.com/ladjs/supertest) and [vitest](https://vitest.dev/)
- Integration tests with [supertest](https://github.com/ladjs/supertest), [vitest](https://vitest.dev/) and [vitest-mock-extended](https://github.com/eratio08/vitest-mock-extended)

### Contract Tests
Expand Down
8 changes: 4 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use an official Node.js runtime based on Alpine Linux as the base image
FROM node:18-alpine
FROM node:20-alpine

# Install bash
RUN apk add --no-cache bash
Expand All @@ -8,10 +8,10 @@ RUN apk add --no-cache bash
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
COPY package.json yarn.lock ./

# Install the application dependencies
RUN npm ci
RUN yarn

# Required for prisma
RUN apk add openssl3
Expand All @@ -31,7 +31,7 @@ RUN chmod +x wait-for-it.sh
RUN npx prisma generate

# Build TypeScript code
RUN npm run build
RUN yarn build

# Expose the port that the application will run on
EXPOSE 5000
Expand Down
2 changes: 1 addition & 1 deletion backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- "5432:5432"
app:
build: .
command: ["sh", "-c", "./wait-for-it.sh postgres:5432 -- npx prisma migrate deploy && npm run seed && npm start"]
command: ["sh", "-c", "./wait-for-it.sh postgres:5432 -- yarn prisma migrate deploy && yarn seed && yarn start"]
ports:
- "5000:5000"
environment:
Expand Down
Loading
Loading