Skip to content

Commit

Permalink
adding tests to ci (#10)
Browse files Browse the repository at this point in the history
* adding tests to ci

* use npm ci for package installation

* also install dev dependencies

* try npm install as npm ci is failing

* npm instead of npx

* coverage enabled

* installing missing dependency
  • Loading branch information
mohit2152sharma authored Dec 19, 2024
1 parent 5771c08 commit 8983e86
Show file tree
Hide file tree
Showing 6 changed files with 508 additions and 56 deletions.
61 changes: 17 additions & 44 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,33 @@
# File: .github/workflows/publish.yml
# TODO: Add setup to run tests and linting in ci
name: publish-to-github-pages
name: Deploy to dokploy
on:
push:
branches:
- main

permissions:
contents: read
pages: write
id-token: write

env:
NODE_ENV: production
pull_request:
workflow_dispatch:

concurrency:
group: 'pages'
cancel-in-progress: false
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
run-test:
runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: write
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Setup Node.js ⚙️ - Cache dependencies ⚡ - Install dependencies 🔧
uses: ./.github/workflows/setup-node
with:
working-directory: longpost
node-env: ${{ env.NODE_ENV }}

- name: Setup Pages ⚙️
uses: actions/configure-pages@v4
with:
static_site_generator: next

- name: Build with Next.js 🏗️
run: npx next build
working-directory: longpost

- name: Upload artifact 📡
uses: actions/upload-pages-artifact@v3
with:
path: longpost/out

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
needs: build

steps:
- name: Publish to GitHub Pages 🚀
id: deployment
uses: actions/deploy-pages@v4
node-env: development
- name: Run unit tests
run: npm run test:unit -- --coverage.enabled=true
- name: Run playwrite tests
run: npm run test:e2e
- name: Report converage
if: always()
uses: davelosert/vitest-coverage-report-action@v2
Empty file.
17 changes: 6 additions & 11 deletions .github/workflows/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,31 @@ description: 'Setup Node.js ⚙️ - Cache dependencies ⚡ - Install dependenci
inputs:
working-directory:
description: 'Working directory'
required: true
required: false
default: '.'
node-env:
description: 'Node Environment'
required: false
default: 'production'
required: true
runs:
using: 'composite'
steps:
- name: Setup Node.js ⚙️
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
node-version: 22.10.0

- name: Cache dependencies ⚡
id: cache_dependencies
uses: actions/cache@v3
with:
path: node_modules
# TODO: use correct path for hash key
key: node-modules-${{ hashFiles('pnpm-lock.yaml') }}
key: node-modules-${{ hashFiles('package-lock.json') }}

- name: Install dependencies 🔧
shell: bash
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile
run: npm install
working-directory: ${{ inputs.working-directory }}
env:
NODE_ENV: ${{ inputs.NODE_ENV }}
Loading

0 comments on commit 8983e86

Please sign in to comment.