diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 9be01597..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,126 +0,0 @@ -name: ๐Ÿš€ Deploy - -on: - push: - branches: - - main - - dev - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - actions: write - contents: read - -jobs: - lint: - name: โฌฃ ESLint - runs-on: ubuntu-latest - steps: - - name: โฌ‡๏ธ Checkout repo - uses: actions/checkout@v3 - - - name: โŽ” Setup node - uses: actions/setup-node@v3 - with: - cache: npm - cache-dependency-path: ./package.json - node-version: 18 - - - 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@v3 - - - name: โŽ” Setup node - uses: actions/setup-node@v3 - with: - cache: npm - cache-dependency-path: ./package.json - node-version: 18 - - - name: ๐Ÿ“ฅ Install deps - run: npm install - - - name: ๐Ÿ”Ž Type check - run: npm run typecheck --if-present - - vitest: - name: โšก Vitest - runs-on: ubuntu-latest - steps: - - name: โฌ‡๏ธ Checkout repo - uses: actions/checkout@v3 - - - name: โŽ” Setup node - uses: actions/setup-node@v3 - with: - cache: npm - cache-dependency-path: ./package.json - node-version: 18 - - - 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@v3 - with: - cache: npm - cache-dependency-path: ./package.json - node-version: 18 - - - name: ๐Ÿ“ฅ Install deps - run: npm install - - - name: โš™๏ธ Build - run: npm run build - - - name: ๐ŸŒณ Cypress run - uses: cypress-io/github-action@v5 - with: - start: npm run start:mocks - wait-on: http://localhost:8811 - env: - PORT: 8811 - - deploy: - name: ๐Ÿš€ Deploy - runs-on: ubuntu-latest - needs: [lint, typecheck, vitest, cypress] - # only build/deploy main branch on pushes - if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }} - - steps: - - name: โฌ‡๏ธ Checkout repo - uses: actions/checkout@v3 - - - name: ๐Ÿ‘€ Read app name - - - name: ๐Ÿš€ Deploy Staging - - - - name: ๐Ÿš€ Deploy Production diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 00000000..594fe8e6 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -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 diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..25bf17fc --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3c9a0d41..8ba6c802 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-alpine as base +FROM node:18-alpine as base ARG PERSONAL_ACCESS_TOKEN @@ -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"] \ No newline at end of file +CMD ["npm", "start"] \ No newline at end of file diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 7015eb14..dd524a94 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -1,3 +1,4 @@ +export {}; declare global { namespace Cypress { interface Chainable { @@ -15,7 +16,7 @@ declare global { } function login() { - return 'logged in' + return 'logged in'; } -Cypress.Commands.add("login", login); +Cypress.Commands.add('login', login); diff --git a/package.json b/package.json index 3423f614..40b27630 100644 --- a/package.json +++ b/package.json @@ -9,62 +9,60 @@ "format": "prettier --write .", "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .", "start": "remix-serve ./build/index.js", - "start:mocks": "binode --require ./mocks -- @remix-run/serve:remix-serve ./build/index.js", "test": "vitest", "test:e2e:dev": "start-server-and-test dev http://localhost:3000 \"npx cypress open\"", - "pretest:e2e:run": "npm run build", - "test:e2e:run": "cross-env PORT=8811 start-server-and-test start:mocks http://localhost:8811 \"npx cypress run\"", + "test:e2e:run": "cross-env PORT=8811 start-server-and-test dev:serve http://localhost:8811 \"npx cypress run\"", "typecheck": "tsc && tsc -p cypress", "validate": "run-p \"test -- --run\" lint typecheck test:e2e:run" }, "dependencies": { - "@paystackhq/pax": "^1.12.3", + "@paystackhq/pax": "^1.15.1", "@remix-run/css-bundle": "*", "@remix-run/node": "*", "@remix-run/react": "*", "@remix-run/serve": "*", - "isbot": "^3.6.12", + "isbot": "^3.7.0", "react": "^18.2.0", "react-dom": "^18.2.0", "tiny-invariant": "^1.3.1" }, "devDependencies": { - "@faker-js/faker": "^8.0.2", + "@faker-js/faker": "^8.2.0", "@remix-run/dev": "*", - "@remix-run/eslint-config": "*", - "@testing-library/cypress": "^9.0.0", - "@testing-library/jest-dom": "^5.16.5", - "@types/bcryptjs": "^2.4.2", - "@types/eslint": "^8.40.2", - "@types/node": "^18.16.18", - "@types/react": "^18.2.14", - "@types/react-dom": "^18.2.6", - "@vitejs/plugin-react": "^4.0.1", - "@vitest/coverage-v8": "^0.32.2", - "autoprefixer": "^10.4.14", + "@remix-run/eslint-config": "^2.2.0", + "@testing-library/cypress": "^10.0.1", + "@testing-library/jest-dom": "^6.1.4", + "@types/bcryptjs": "^2.4.5", + "@types/eslint": "^8.44.6", + "@types/node": "^18.18.6", + "@types/react": "^18.2.31", + "@types/react-dom": "^18.2.14", + "@vitejs/plugin-react": "^4.1.0", + "@vitest/coverage-v8": "^0.34.6", + "autoprefixer": "^10.4.16", "binode": "^1.0.5", "cookie": "^0.5.0", "cross-env": "^7.0.3", - "cypress": "^12.16.0", - "eslint": "^8.43.0", - "eslint-config-prettier": "^8.8.0", - "eslint-plugin-cypress": "^2.13.3", - "eslint-plugin-import": "^2.28.0", - "eslint-plugin-markdown": "^3.0.0", - "happy-dom": "^9.20.3", - "msw": "^1.2.2", + "cypress": "^13.3.2", + "eslint": "^8.52.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-cypress": "^2.15.1", + "eslint-plugin-import": "^2.28.1", + "eslint-plugin-markdown": "^3.0.1", + "happy-dom": "^12.9.1", + "msw": "^1.3.2", "npm-run-all": "^4.1.5", - "postcss": "^8.4.24", - "prettier": "2.8.8", - "start-server-and-test": "^2.0.0", + "postcss": "^8.4.31", + "prettier": "3.0.3", + "start-server-and-test": "^2.0.1", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", - "typescript": "^5.1.3", - "vite": "^4.3.9", - "vite-tsconfig-paths": "^3.6.0", - "vitest": "^0.32.2" + "typescript": "^5.2.2", + "vite": "^4.5.0", + "vite-tsconfig-paths": "^4.2.1", + "vitest": "^0.34.6" }, "engines": { - "node": ">=18" + "node": ">=18.0.0" } }