Skip to content

Commit d7b202a

Browse files
authored
cicd/Updating the github workflow (#55)
* cicd/Updating the github workflow * added Vitest testing setup - Added vitest config to vite.config.ts - Created basic test suite - Included tests in precheck script and in cicd workflow too
1 parent 729ea08 commit d7b202a

10 files changed

Lines changed: 767 additions & 120 deletions

.github/workflows/azure-static-web-apps-lively-smoke-0f1169200.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Deploys to Azure Static Web Apps after merge to main
2+
name: Post-merge Deploy
3+
4+
on:
5+
push:
6+
branches: [main]
7+
workflow_dispatch:
8+
inputs:
9+
environment:
10+
description: 'Deploy to'
11+
required: true
12+
default: 'production'
13+
type: choice
14+
options: [production, development]
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
environment: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || 'development' }}
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
26+
- uses: pnpm/action-setup@v2
27+
with:
28+
version: 8
29+
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: '22.15.0'
33+
34+
- name: Deploy to Azure
35+
uses: Azure/static-web-apps-deploy@v1
36+
with:
37+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
38+
repo_token: ${{ secrets.GITHUB_TOKEN }}
39+
action: upload
40+
app_location: /
41+
output_location: dist
42+
app_build_command: npm install -g pnpm && pnpm install && pnpm build
43+
env:
44+
VITE_API_URL: ${{ secrets.VITE_API_URL }}
45+
VITE_APP_INSIGHTS_KEY: ${{ secrets.VITE_APP_INSIGHTS_KEY }}
46+
VITE_APP_INSIGHTS_CONNECTION_STRING: ${{ secrets.VITE_APP_INSIGHTS_CONNECTION_STRING }}
47+
VITE_ENVIRONMENT: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || 'development' }}
48+
VITE_AUTH0_DOMAIN: ${{ secrets.VITE_AUTH0_DOMAIN }}
49+
VITE_AUTH0_CLIENT_ID: ${{ secrets.VITE_AUTH0_CLIENT_ID }}
50+
VITE_AUTH0_AUDIENCE: ${{ secrets.VITE_AUTH0_AUDIENCE }}

.github/workflows/pr-closed.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Cleanup Azure Static Web Apps preview and delete branch
2+
name: PR Closed
3+
4+
on:
5+
pull_request:
6+
types: [closed]
7+
8+
jobs:
9+
cleanup:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Close Azure Static Web Apps Preview
13+
uses: Azure/static-web-apps-deploy@v1
14+
with:
15+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LIVELY_SMOKE_0F1169200 }}
16+
action: "close"
17+
18+
- name: Delete merged branch
19+
if: github.event.pull_request.merged == true
20+
uses: dawidd6/action-delete-branch@v3
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
branches: ${{ github.event.pull_request.head.ref }}

.github/workflows/pre-merge.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Validates Pull Requests
2+
name: Pre-merge
3+
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened, ready_for_review]
7+
branches: [main]
8+
9+
jobs:
10+
validate:
11+
runs-on: ubuntu-latest
12+
if: ${{ !github.event.pull_request.draft }}
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Setup pnpm
18+
uses: pnpm/action-setup@v2
19+
with:
20+
version: 8
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 22.15.0
26+
cache: pnpm
27+
28+
- name: Install dependencies
29+
run: pnpm install
30+
31+
- name: Lint and format check
32+
run: |
33+
pnpm lint
34+
pnpm format:check
35+
36+
- name: Type check
37+
run: pnpm typecheck
38+
39+
- name: Run tests
40+
run: pnpm test
41+
42+
- name: Build test
43+
run: pnpm build

.github/workflows/scribe-web-pr-checks.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
"lint:fix": "eslint . --ext ts,tsx,js,jsx --fix --cache --no-error-on-unmatched-pattern",
1717
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
1818
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
19+
"test": "vitest run",
1920
"deps:clean": "pnpm prune && pnpm install",
2021
"deps:reset": "rm -rf node_modules && rm pnpm-lock.yaml && pnpm install",
2122
"typecheck": "tsc --noEmit",
22-
"precheck": "pnpm lint && pnpm format:check && pnpm typecheck",
23+
"precheck": "pnpm lint && pnpm format:check && pnpm typecheck && pnpm test",
2324
"prepare": "husky",
2425
"lint-staged": "lint-staged",
2526
"set-env": "node scripts/set-env.ts"
@@ -67,6 +68,7 @@
6768
"eslint-plugin-react-refresh": "^0.4.20",
6869
"eslint-plugin-unused-imports": "^4.1.4",
6970
"husky": "^9.0.11",
71+
"jsdom": "^26.1.0",
7072
"lint-staged": "^15.2.2",
7173
"prettier": "^3.5.3",
7274
"prettier-plugin-tailwindcss": "^0.6.11",
@@ -75,7 +77,8 @@
7577
"typescript": "5.5.3",
7678
"typescript-eslint": "^8.35.0",
7779
"vite": "^5.4.19",
78-
"vite-tsconfig-paths": "^4.3.2"
80+
"vite-tsconfig-paths": "^4.3.2",
81+
"vitest": "^3.2.4"
7982
},
8083
"lint-staged": {
8184
"*.{ts,tsx}": [

0 commit comments

Comments
 (0)