Skip to content

Commit 78468f4

Browse files
authored
Clean up old test variations (#152)
* Clean up old test variations Visual-Regression-Tracker/Visual-Regression-Tracker#275
1 parent 9b04c17 commit 78468f4

File tree

14 files changed

+360
-15
lines changed

14 files changed

+360
-15
lines changed

package-lock.json

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@nestjs/passport": "^7.1.0",
2929
"@nestjs/platform-express": "^7.4.2",
3030
"@nestjs/platform-socket.io": "^7.6.17",
31+
"@nestjs/schedule": "^0.4.3",
3132
"@nestjs/swagger": "^4.8.0",
3233
"@nestjs/websockets": "^7.4.2",
3334
"@prisma/client": "2.12.1",
@@ -58,6 +59,7 @@
5859
"@prisma/cli": "2.12.1",
5960
"@types/bcryptjs": "^2.4.2",
6061
"@types/cache-manager": "^2.10.3",
62+
"@types/cron": "^1.7.2",
6163
"@types/express": "^4.17.7",
6264
"@types/jest": "26.0.14",
6365
"@types/lodash": "^4.14.168",
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Migration `20210709115233-gh-275-max-branch-lifetime`
2+
3+
This migration has been generated by Pavel Strunkin at 7/9/2021, 2:52:33 PM.
4+
You can check out the [state of the schema](./schema.prisma) after the migration.
5+
6+
## Database Steps
7+
8+
```sql
9+
ALTER TABLE "Baseline" ADD COLUMN "userId" TEXT
10+
11+
ALTER TABLE "Project" ADD COLUMN "maxBranchLifetime" INTEGER NOT NULL DEFAULT 30
12+
13+
ALTER TABLE "Baseline" ADD FOREIGN KEY("userId")REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE
14+
```
15+
16+
## Changes
17+
18+
```diff
19+
diff --git schema.prisma schema.prisma
20+
migration 20210705154453-baseline-author..20210709115233-gh-275-max-branch-lifetime
21+
--- datamodel.dml
22+
+++ datamodel.dml
23+
@@ -3,9 +3,9 @@
24+
}
25+
datasource db {
26+
provider = "postgresql"
27+
- url = "***"
28+
+ url = "***"
29+
}
30+
model Build {
31+
id String @id @default(uuid())
32+
@@ -31,8 +31,9 @@
33+
mainBranchName String @default("master")
34+
builds Build[]
35+
buildsCounter Int @default(0)
36+
maxBuildAllowed Int @default(100)
37+
+ maxBranchLifetime Int @default(30)
38+
testVariations TestVariation[]
39+
updatedAt DateTime @updatedAt
40+
createdAt DateTime @default(now())
41+
// config
42+
@@ -104,24 +105,24 @@
43+
testRunId String?
44+
testRun TestRun? @relation(fields: [testRunId], references: [id])
45+
userId String?
46+
user User? @relation(fields: [userId], references: [id])
47+
- updatedAt DateTime @updatedAt
48+
+ updatedAt DateTime @updatedAt
49+
createdAt DateTime @default(now())
50+
}
51+
model User {
52+
- id String @id @default(uuid())
53+
- email String @unique
54+
+ id String @id @default(uuid())
55+
+ email String @unique
56+
password String
57+
firstName String?
58+
lastName String?
59+
- apiKey String @unique
60+
- isActive Boolean @default(true)
61+
+ apiKey String @unique
62+
+ isActive Boolean @default(true)
63+
builds Build[]
64+
baselines Baseline[]
65+
- updatedAt DateTime @updatedAt
66+
- createdAt DateTime @default(now())
67+
+ updatedAt DateTime @updatedAt
68+
+ createdAt DateTime @default(now())
69+
}
70+
enum TestStatus {
71+
failed
72+
```
73+
74+
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
generator client {
2+
provider = "prisma-client-js"
3+
}
4+
5+
datasource db {
6+
provider = "postgresql"
7+
url = "***"
8+
}
9+
10+
model Build {
11+
id String @id @default(uuid())
12+
ciBuildId String?
13+
number Int?
14+
branchName String?
15+
status String?
16+
testRuns TestRun[]
17+
projectId String
18+
project Project @relation(fields: [projectId], references: [id])
19+
updatedAt DateTime @updatedAt
20+
createdAt DateTime @default(now())
21+
user User? @relation(fields: [userId], references: [id])
22+
userId String?
23+
isRunning Boolean?
24+
25+
@@unique([projectId, ciBuildId])
26+
}
27+
28+
model Project {
29+
id String @id @default(uuid())
30+
name String
31+
mainBranchName String @default("master")
32+
builds Build[]
33+
buildsCounter Int @default(0)
34+
maxBuildAllowed Int @default(100)
35+
maxBranchLifetime Int @default(30)
36+
testVariations TestVariation[]
37+
updatedAt DateTime @updatedAt
38+
createdAt DateTime @default(now())
39+
// config
40+
autoApproveFeature Boolean @default(false)
41+
imageComparison ImageComparison @default(pixelmatch)
42+
imageComparisonConfig String @default("{ \"threshold\": 0.1, \"ignoreAntialiasing\": true, \"allowDiffDimensions\": false }")
43+
44+
@@unique([name])
45+
}
46+
47+
model TestRun {
48+
id String @id @default(uuid())
49+
imageName String
50+
diffName String?
51+
diffPercent Float?
52+
diffTollerancePercent Float @default(0)
53+
pixelMisMatchCount Int?
54+
status TestStatus
55+
buildId String
56+
build Build @relation(fields: [buildId], references: [id])
57+
testVariationId String?
58+
testVariation TestVariation? @relation(fields: [testVariationId], references: [id])
59+
merge Boolean @default(false)
60+
updatedAt DateTime @updatedAt
61+
createdAt DateTime @default(now())
62+
// Test variation data
63+
name String @default("")
64+
browser String?
65+
device String?
66+
os String?
67+
viewport String?
68+
customTags String? @default("")
69+
baselineName String?
70+
comment String?
71+
baseline Baseline?
72+
branchName String @default("master")
73+
baselineBranchName String?
74+
ignoreAreas String @default("[]")
75+
tempIgnoreAreas String @default("[]")
76+
}
77+
78+
model TestVariation {
79+
id String @id @default(uuid())
80+
name String
81+
branchName String @default("master")
82+
browser String @default("")
83+
device String @default("")
84+
os String @default("")
85+
viewport String @default("")
86+
customTags String @default("")
87+
baselineName String?
88+
ignoreAreas String @default("[]")
89+
projectId String
90+
project Project @relation(fields: [projectId], references: [id])
91+
testRuns TestRun[]
92+
baselines Baseline[]
93+
comment String?
94+
updatedAt DateTime @updatedAt
95+
createdAt DateTime @default(now())
96+
97+
@@unique([projectId, name, browser, device, os, viewport, customTags, branchName])
98+
}
99+
100+
model Baseline {
101+
id String @id @default(uuid())
102+
baselineName String
103+
testVariationId String
104+
testVariation TestVariation @relation(fields: [testVariationId], references: [id])
105+
testRunId String?
106+
testRun TestRun? @relation(fields: [testRunId], references: [id])
107+
userId String?
108+
user User? @relation(fields: [userId], references: [id])
109+
updatedAt DateTime @updatedAt
110+
createdAt DateTime @default(now())
111+
}
112+
113+
model User {
114+
id String @id @default(uuid())
115+
email String @unique
116+
password String
117+
firstName String?
118+
lastName String?
119+
apiKey String @unique
120+
isActive Boolean @default(true)
121+
builds Build[]
122+
baselines Baseline[]
123+
updatedAt DateTime @updatedAt
124+
createdAt DateTime @default(now())
125+
}
126+
127+
enum TestStatus {
128+
failed
129+
new
130+
ok
131+
unresolved
132+
approved
133+
autoApproved
134+
}
135+
136+
enum ImageComparison {
137+
pixelmatch
138+
lookSame
139+
odiff
140+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"version": "0.3.14-fixed",
3+
"steps": [
4+
{
5+
"tag": "CreateField",
6+
"model": "Project",
7+
"field": "maxBranchLifetime",
8+
"type": "Int",
9+
"arity": "Required"
10+
},
11+
{
12+
"tag": "CreateDirective",
13+
"location": {
14+
"path": {
15+
"tag": "Field",
16+
"model": "Project",
17+
"field": "maxBranchLifetime"
18+
},
19+
"directive": "default"
20+
}
21+
},
22+
{
23+
"tag": "CreateArgument",
24+
"location": {
25+
"tag": "Directive",
26+
"path": {
27+
"tag": "Field",
28+
"model": "Project",
29+
"field": "maxBranchLifetime"
30+
},
31+
"directive": "default"
32+
},
33+
"argument": "",
34+
"value": "30"
35+
}
36+
]
37+
}

prisma/migrations/migrate.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
20210517203552-add-custom-tags
2121
20210605124856-image-compare-config-as-json
2222
20210612140950-limit-build-number
23-
20210705154453-baseline-author
23+
20210705154453-baseline-author
24+
20210709115233-gh-275-max-branch-lifetime

prisma/schema.prisma

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ model Project {
3232
builds Build[]
3333
buildsCounter Int @default(0)
3434
maxBuildAllowed Int @default(100)
35+
maxBranchLifetime Int @default(30)
3536
testVariations TestVariation[]
3637
updatedAt DateTime @updatedAt
3738
createdAt DateTime @default(now())
@@ -105,22 +106,22 @@ model Baseline {
105106
testRun TestRun? @relation(fields: [testRunId], references: [id])
106107
userId String?
107108
user User? @relation(fields: [userId], references: [id])
108-
updatedAt DateTime @updatedAt
109+
updatedAt DateTime @updatedAt
109110
createdAt DateTime @default(now())
110111
}
111112

112113
model User {
113-
id String @id @default(uuid())
114-
email String @unique
114+
id String @id @default(uuid())
115+
email String @unique
115116
password String
116117
firstName String?
117118
lastName String?
118-
apiKey String @unique
119-
isActive Boolean @default(true)
119+
apiKey String @unique
120+
isActive Boolean @default(true)
120121
builds Build[]
121122
baselines Baseline[]
122-
updatedAt DateTime @updatedAt
123-
createdAt DateTime @default(now())
123+
updatedAt DateTime @updatedAt
124+
createdAt DateTime @default(now())
124125
}
125126

126127
enum TestStatus {

src/_data_/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const TEST_PROJECT: Project = {
66
name: 'Test Project',
77
buildsCounter: 2,
88
maxBuildAllowed: 100,
9+
maxBranchLifetime: 30,
910
mainBranchName: 'master',
1011
createdAt: new Date(),
1112
updatedAt: new Date(),

0 commit comments

Comments
 (0)