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

Update template deps, Dockerfile and workflow #4

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
126 changes: 0 additions & 126 deletions .github/workflows/deploy.yml

This file was deleted.

121 changes: 121 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: 🧪 Run tests

on:
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: ⬣ ESLint
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: '.nvmrc'
# Change the below to your lockfile
cache-dependency-path: package.json

- name: ➡️ Set Config
run: |
npm config set //npm.pkg.github.com/:_authToken ${{ secrets.PERSONAL_ACCESS_TOKEN }}
npm config set @paystackhq:registry https://npm.pkg.github.com

- name: 📥 Install deps
run: npm install

- name: 🔬 Lint
run: npm run lint

typecheck:
name: ʦ TypeScript
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: '.nvmrc'
# Change the below to your lockfile
cache-dependency-path: package.json

- name: ➡️ Set Config
run: |
npm config set //npm.pkg.github.com/:_authToken ${{ secrets.PERSONAL_ACCESS_TOKEN }}
npm config set @paystackhq:registry https://npm.pkg.github.com

- name: 📥 Install deps
run: npm install

- name: 🔎 Type check
run: npm run typecheck

vitest:
name: ⚡ Vitest
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: '.nvmrc'
# Change the below to your lockfile
cache-dependency-path: package.json

- name: ➡️ Set Config
run: |
npm config set //npm.pkg.github.com/:_authToken ${{ secrets.PERSONAL_ACCESS_TOKEN }}
npm config set @paystackhq:registry https://npm.pkg.github.com

- name: 📥 Install deps
run: npm install

- name: ⚡ Run vitest
run: npm run test --coverage

cypress:
name: ⚫️ Cypress
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: 🏄 Copy test env vars
run: cp .env.example .env

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: '.nvmrc'
# Change the below to your lockfile
cache-dependency-path: package.json

- name: 📥 Install deps
run: npm install

- name: ⚙️ Build
run: npm run build

- name: 🌳 Cypress run
uses: cypress-io/github-action@v6
with:
start: npm run start:mocks
wait-on: http://localhost:3000
env:
PORT: 3000
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine as base
FROM node:18-alpine as base

ARG PERSONAL_ACCESS_TOKEN

Expand All @@ -12,26 +12,25 @@ RUN npm config set @paystackhq:registry https://npm.pkg.github.com

WORKDIR $APP_DIR

COPY package*.json yarn.lock ./
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM node:16-alpine AS release
FROM node:18-alpine AS release

ENV APP_DIR /usr/local/app

WORKDIR $APP_DIR

COPY --from=base $APP_DIR/*.json $APP_DIR/*.js $APP_DIR/*.ts ./
COPY --from=base $APP_DIR/package.json ./
COPY --from=base $APP_DIR/node_modules ./node_modules
COPY --from=base $APP_DIR/build ./build
COPY --from=base $APP_DIR/app ./app
COPY --from=base $APP_DIR/public ./public

EXPOSE 4202
EXPOSE 3000

ARG APP_VERSION
ENV DD_VERSION ${APP_VERSION}

CMD ["yarn", "start"]
CMD ["npm", "start"]
5 changes: 3 additions & 2 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export {};
declare global {
namespace Cypress {
interface Chainable {
Expand All @@ -15,7 +16,7 @@ declare global {
}

function login() {
return 'logged in'
return 'logged in';
}

Cypress.Commands.add("login", login);
Cypress.Commands.add('login', login);
Loading
Loading