Skip to content

Commit e1c79f3

Browse files
committed
add(ci) Tests with coverage
1 parent 5b9ecd2 commit e1c79f3

File tree

12 files changed

+2607
-192
lines changed

12 files changed

+2607
-192
lines changed

.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
VITE_PIZZA_SERVICE_URL=http://localhost:3000
2+
# VITE_PIZZA_SERVICE_URL=https://pizza-service.cs329.click
23
VITE_PIZZA_FACTORY_URL=https://pizza-factory.cs329.click

.github/workflows/ci.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup Node
1919
uses: actions/setup-node@v4
2020
with:
21-
node-version: '22.x'
21+
node-version: "22.x"
2222

2323
- name: set version
2424
id: set_version
@@ -36,6 +36,18 @@ jobs:
3636
uses: actions/upload-pages-artifact@v3
3737
with:
3838
path: dist/
39+
40+
- name: Run tests
41+
run: |
42+
npx playwright install --with-deps chromium
43+
npm run test:coverage
44+
45+
- name: Update coverage
46+
run: |
47+
coverage=$(jq '.total.lines.pct' coverage/coverage-summary.json)
48+
color=$(echo "$coverage < 80" | bc | awk '{if ($1) print "red"; else print "green"}')
49+
curl -s -X POST "https://pizza-factory.cs329.click/api/badge/${{ secrets.NET_ID }}/jwtpizzacoverage?label=Coverage&value=$coverage%25&color=$color" -H "authorization: bearer ${{ secrets.FACTORY_API_KEY }}"
50+
3951
deploy:
4052
needs: build
4153
permissions:
@@ -48,4 +60,4 @@ jobs:
4860
steps:
4961
- name: Deploy to GitHub Pages
5062
id: deployment
51-
uses: actions/deploy-pages@v4
63+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ node_modules/
1313
/blob-report/
1414
/playwright/.cache/
1515
/playwright/.auth/
16+
/playwright/.cache/
17+
.nyc_output
18+
19+

.nycrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"check-coverage": true,
3+
"branches": 0,
4+
"lines": 80,
5+
"functions": 0,
6+
"statements": 0
7+
}

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# 🍕 JWT Pizza
22

3-
![Coverage badge](https://pizza-factory.cs329.click/api/badge/accountId/jwtpizzacoverage?t=1)
3+
<!-- ![Coverage badge](https://pizza-factory.cs329.click/api/badge/accountId/jwtpizzacoverage?t=1) -->
4+
5+
![Coverage badge](https://pizza-factory.cs329.click/api/badge/YOURNETID/jwtpizzacoverage)
46

57
[![CI Pipeline](https://github.com/samuelsotogit/jwt-pizza/actions/workflows/ci.yml/badge.svg)](https://github.com/samuelsotogit/jwt-pizza/actions/workflows/ci.yml)
68

@@ -75,7 +77,7 @@ Modify `tailwind.config.js`
7577
```js
7678
/** @type {import('tailwindcss').Config} */
7779
module.exports = {
78-
content: ['index.html', './src/**/*.{html,js,jsx}'],
80+
content: ["index.html", "./src/**/*.{html,js,jsx}"],
7981
theme: {
8082
extend: {},
8183
},
@@ -113,25 +115,29 @@ npm i preline
113115
Updated the tailwind config to use preline.
114116

115117
```js
116-
const defaultTheme = require('tailwindcss/defaultTheme');
118+
const defaultTheme = require("tailwindcss/defaultTheme");
117119

118120
module.exports = {
119-
content: ['index.html', './src/**/*.{html,js,jsx}', './node_modules/preline/preline.js'],
121+
content: [
122+
"index.html",
123+
"./src/**/*.{html,js,jsx}",
124+
"./node_modules/preline/preline.js",
125+
],
120126
theme: {
121127
extend: {
122128
fontFamily: {
123-
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
129+
sans: ["Inter var", ...defaultTheme.fontFamily.sans],
124130
},
125131
},
126132
},
127-
plugins: [require('preline/plugin')],
133+
plugins: [require("preline/plugin")],
128134
};
129135
```
130136

131137
Import preline into app.jsx.
132138

133139
```js
134-
import 'preline/preline';
140+
import "preline/preline";
135141
```
136142

137143
Initialize components whenever the page location changes.

0 commit comments

Comments
 (0)