Skip to content

Commit ba1bdbf

Browse files
authored
Move Test URL check to Vitest (refined-github#7694)
1 parent 0436148 commit ba1bdbf

10 files changed

Lines changed: 24 additions & 138 deletions

.github/workflows/features.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,3 @@ jobs:
2020
cache: npm
2121
- run: npm ci
2222
- run: npm run vitest -- build/features
23-
24-
TestURLs:
25-
runs-on: ubuntu-latest
26-
# Exclude commit pushes, there's no need there
27-
if: github.event_name == 'pull_request'
28-
steps:
29-
- uses: actions/checkout@v4
30-
with:
31-
fetch-depth: 0 # Must
32-
33-
- name: Get changed files
34-
id: changed-files
35-
uses: tj-actions/changed-files@v44
36-
with:
37-
files: source/features/*.{tsx,css}
38-
39-
- name: Every new/edited file must have a test URL
40-
run: bash build/verify-test-urls.sh ${{steps.changed-files.outputs.all_changed_files}}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ test/web-ext-profile
66
.cache
77
.parcel-cache
88
artifacts
9+
.DS_Store
10+
desktop.ini
911

1012
LocalOverrides.xcconfig

build/features.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {test, describe, assert} from 'vitest';
2-
import {parse, join} from 'node:path';
31
import {existsSync, readdirSync, readFileSync} from 'node:fs';
2+
import path from 'node:path';
3+
import {test, describe, assert} from 'vitest';
44
import regexJoin from 'regex-join';
55
import fastIgnore from 'fast-ignore';
66

@@ -55,8 +55,8 @@ class FeatureFile {
5555
readonly id: FeatureID;
5656
readonly path: string;
5757
constructor(readonly name: string) {
58-
this.id = parse(name).name as FeatureID;
59-
this.path = join('source/features', name);
58+
this.id = path.parse(name).name as FeatureID;
59+
this.path = path.join('source/features', name);
6060
}
6161

6262
exists(): boolean {
@@ -91,6 +91,8 @@ function validateCss(file: FeatureFile): void {
9191
isImportedByEntrypoint,
9292
`Should be imported by \`${entryPoint}\` or removed if it is not needed`,
9393
);
94+
95+
assert(/test url/i.test(file.contents().toString()), 'Should have test URLs');
9496
return;
9597
}
9698

@@ -103,6 +105,8 @@ function validateCss(file: FeatureFile): void {
103105
!isImportedByEntrypoint,
104106
`Should only be imported by \`${file.tsx.name}\`, not by \`${entryPoint}\``,
105107
);
108+
109+
assert(!/test url/i.test(file.contents().toString()), 'Only TSX files and *lone* CSS files should have test URLs');
106110
}
107111

108112
function validateGql(file: FeatureFile): void {
@@ -141,11 +145,11 @@ function validateTsx(file: FeatureFile): void {
141145
`Should be imported by \`${entryPoint}\``,
142146
);
143147

144-
const fileContents = readFileSync(`source/features/${file.name}`);
148+
assert(/test url/i.test(file.contents().toString()), 'Should have test URLs');
145149

146-
if (fileContents.includes('.addCssFeature')) {
150+
if (file.contents().includes('.addCssFeature')) {
147151
assert(
148-
!fileContents.includes('.add('),
152+
!file.contents().includes('.add('),
149153
`${file.id} should use either \`addCssFeature\` or \`add\`, not both`,
150154
);
151155

build/verify-test-urls.sh

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

source/features/align-issue-labels.css

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,3 @@
3232
margin-top: 4px;
3333
font-size: 11px !important;
3434
}
35-
36-
/* TODO: Remove links from CSS+JS features after https://github.com/refined-github/refined-github/issues/7656 or https://github.com/refined-github/refined-github/issues/7132 */
37-
/*
38-
39-
# Test URLs
40-
41-
https://github.com/pulls
42-
https://github.com/bmish/eslint-doc-generator/pulls
43-
https://github.com/bmish/eslint-doc-generator/issues
44-
https://github.com/bmish/eslint-doc-generator/milestone/1
45-
46-
*/

source/features/deep-reblame.css

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,3 @@ button.rgh-deep-reblame .octicon-versions {
77
color: var(--color-scale-pink-7, #800080);
88
opacity: 70%;
99
}
10-
11-
/*
12-
13-
Test URLs:
14-
15-
https://github.com/refined-github/refined-github/blame/main/source/refined-github.ts
16-
17-
*/

source/features/github-bugs.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@
7373
div.markdown-body {
7474
min-height: 2em !important;
7575
}
76+
77+
/*
78+
79+
Test URLs:
80+
81+
MAKE SURE TO ADD A ISSUE REFERENCE + TEST URL FOR EACH NEW RULE
82+
83+
*/

source/features/hide-diff-signs.css

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,3 @@
77
)::before {
88
visibility: hidden;
99
}
10-
11-
/*
12-
13-
Test URLs
14-
15-
Any commits on https://github.com/sindresorhus/refined-github/commits/main
16-
Any reviewed block on https://github.com/sindresorhus/refined-github/pull/1783
17-
Full diff on https://github.com/sindresorhus/refined-github/pull/1783/files
18-
The preview tab, after editing: https://github.com/refined-github/refined-github/edit/main/source/features/hide-diff-signs.css
19-
20-
*/

source/features/suggest-commit-title-limit.css

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,3 @@
3535
inset 0 1px 2px rgb(35 27 27 / 7.5%),
3636
0 0 0 0.2em color-mix(in srgb, var(--rgh-limit-color) 30%, transparent);
3737
}
38-
39-
/*
40-
41-
## Test URLs
42-
43-
- File edit: https://github.com/refined-github/refined-github/edit/fix-commit-title-limit/source/refined-github.css
44-
- Workflow edit: https://github.com/refined-github/refined-github/edit/fix-commit-title-limit/.github/workflows/features.yml
45-
- Any mergeable PR
46-
47-
*/

source/features/suggest-commit-title-limit.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ void features.add(import.meta.url, {
5353
## Test URLs
5454
5555
- Any mergeable PR
56-
- https://github.com/refined-github/sandbox/pull/8
56+
- https://github.com/refined-github/sandbox/pull/8
5757
- Any editable file
58-
- https://github.com/refined-github/refined-github/edit/main/readme.md
58+
- Markown: https://github.com/refined-github/refined-github/edit/main/readme.md
59+
- Workflow: https://github.com/refined-github/refined-github/edit/fix-commit-title-limit/.github/workflows/features.yml
5960
6061
*/

0 commit comments

Comments
 (0)