Skip to content

Commit 7524d73

Browse files
authored
Branch was updated using the 'autoupdate branch' Actions workflow.
2 parents fa3c34a + cbcd383 commit 7524d73

File tree

2 files changed

+299
-0
lines changed

2 files changed

+299
-0
lines changed

script/search/search-qa-data.json

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
[
2+
{
3+
"query": "interactions",
4+
"href": "/rest/reference/interactions"
5+
},
6+
{
7+
"query": "repositories",
8+
"href": "/rest/reference/repos"
9+
},
10+
{
11+
"query": "workflow_run",
12+
"href": "/developers/webhooks-and-events/webhooks/webhook-events-and-payloads"
13+
},
14+
{
15+
"query": "workflow_dispatch",
16+
"href": "/developers/webhooks-and-events/webhooks/webhook-events-and-payloads"
17+
},
18+
{
19+
"query": "pull_request",
20+
"href": "/developers/webhooks-and-events/webhooks/webhook-events-and-payloads"
21+
},
22+
{
23+
"query": "workflow_run",
24+
"href": "/actions/learn-github-actions/events-that-trigger-workflows"
25+
},
26+
{
27+
"query": "workflow_dispatch",
28+
"href": "/actions/learn-github-actions/events-that-trigger-workflows"
29+
},
30+
{
31+
"query": "register for an account",
32+
"href": "/get-started/signing-up-for-github/signing-up-for-a-new-github-account"
33+
},
34+
{
35+
"query": "registering on GitHub",
36+
"href": "/get-started/signing-up-for-github/signing-up-for-a-new-github-account"
37+
},
38+
{
39+
"query": "signing up for a GitHub account",
40+
"href": "/get-started/signing-up-for-github/signing-up-for-a-new-github-account"
41+
},
42+
{
43+
"query": "new account",
44+
"href": "/get-started/signing-up-for-github/signing-up-for-a-new-github-account"
45+
},
46+
{
47+
"query": "create a GitHub account",
48+
"href": "/get-started/signing-up-for-github/signing-up-for-a-new-github-account"
49+
},
50+
{
51+
"query": "apis",
52+
"href": "/graphql"
53+
},
54+
{
55+
"query": "apis",
56+
"href": "/rest"
57+
},
58+
{
59+
"query": "api",
60+
"href": "/graphql"
61+
},
62+
{
63+
"query": "api",
64+
"href": "/rest"
65+
},
66+
{
67+
"query": "create a new branch",
68+
"href": "/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository"
69+
},
70+
{
71+
"query": "fix merge conflict",
72+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line"
73+
},
74+
{
75+
"query": "conflicts",
76+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line"
77+
},
78+
{
79+
"query": "merge conflict",
80+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line"
81+
},
82+
{
83+
"query": "branch conflicts",
84+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line"
85+
},
86+
{
87+
"query": "conflicting files",
88+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line"
89+
},
90+
{
91+
"query": "resolve conflicts",
92+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line"
93+
},
94+
{
95+
"query": "fix merge conflict",
96+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github"
97+
},
98+
{
99+
"query": "conflicts",
100+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github"
101+
},
102+
{
103+
"query": "merge conflict",
104+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github"
105+
},
106+
{
107+
"query": "branch conflicts",
108+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github"
109+
},
110+
{
111+
"query": "conflicting files",
112+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github"
113+
},
114+
{
115+
"query": "resolve conflicts",
116+
"href": "/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github"
117+
},
118+
{
119+
"query": "actions billable minutes",
120+
"href": "/billing/managing-billing-for-github-actions/about-billing-for-github-actions"
121+
},
122+
{
123+
"query": "actions trigger pull requests",
124+
"href": "/actions/learn-github-actions/events-that-trigger-workflows"
125+
},
126+
{
127+
"query": "about teams",
128+
"href": "/organizations/organizing-members-into-teams/about-teams"
129+
},
130+
{
131+
"query": "about organizations",
132+
"href": "/organizations/collaborating-with-groups-in-organizations/about-organizations"
133+
},
134+
{
135+
"query": "create pages site",
136+
"href": "/pages/getting-started-with-github-pages/creating-a-github-pages-site"
137+
},
138+
{
139+
"query": "create pages site",
140+
"href": "/pages/setting-up-a-github-pages-site-with-jekyll/creating-a-github-pages-site-with-jekyll"
141+
},
142+
{
143+
"query": "make a team",
144+
"href": "/organizations/organizing-members-into-teams/creating-a-team"
145+
},
146+
{
147+
"query": "new team",
148+
"href": "/organizations/organizing-members-into-teams/creating-a-team"
149+
},
150+
{
151+
"query": "team",
152+
"href": "/organizations/organizing-members-into-teams/about-teams"
153+
},
154+
{
155+
"query": "rest create issue",
156+
"href": "/rest/reference/issues"
157+
},
158+
{
159+
"query": "fork",
160+
"href": "/rest/reference/repos"
161+
},
162+
{
163+
"query": "commit email",
164+
"href": "/account-and-profile/setting-up-and-managing-your-github-user-account/managing-email-preferences/setting-your-commit-email-address"
165+
},
166+
{
167+
"query": "graphql organization",
168+
"href": "/graphql/reference/objects"
169+
},
170+
{
171+
"query": "device flow",
172+
"href": "/developers/apps/building-oauth-apps/authorizing-oauth-apps"
173+
},
174+
{
175+
"query": "convert user",
176+
"href": "/account-and-profile/setting-up-and-managing-your-github-user-account/managing-user-account-settings/converting-a-user-into-an-organization"
177+
},
178+
{
179+
"query": "add email",
180+
"href": "/account-and-profile/setting-up-and-managing-your-github-user-account/managing-email-preferences/adding-an-email-address-to-your-github-account"
181+
},
182+
{
183+
"query": "transfer ownership",
184+
"href": "/organizations/managing-organization-settings/transferring-organization-ownership"
185+
},
186+
{
187+
"query": "merge accounts",
188+
"href": "/account-and-profile/setting-up-and-managing-your-github-user-account/managing-user-account-settings/merging-multiple-user-accounts"
189+
},
190+
{
191+
"query": "search syntax",
192+
"href": "/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax"
193+
},
194+
{
195+
"query": "scim okta",
196+
"href": "/organizations/managing-saml-single-sign-on-for-your-organization/configuring-saml-single-sign-on-and-scim-using-okta"
197+
},
198+
{
199+
"query": "keeping your account and data secure",
200+
"href": "/authentication/keeping-your-account-and-data-secure"
201+
},
202+
{
203+
"query": "ssh troubleshoot",
204+
"href": "/authentication/troubleshooting-ssh"
205+
}
206+
]

script/search/search-qa-test.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env node
2+
3+
// [start-readme]
4+
//
5+
// This script is a quality assurance test for the Lunr search configuration.
6+
// This test runs example queries and expects a specific page to land in the top
7+
// 3 results.
8+
//
9+
// The data source used by this script is a JSON file `script/search/search-qa-data.json`,
10+
// which is populated from spreadsheet data here:
11+
// https://docs.google.com/spreadsheets/d/1Dt5JRVcmyAGWKBwGjwmXxi7Ww_vdfYLfZ-EFpu2S2CQ/edit?usp=sharing
12+
//
13+
// [end-readme]
14+
15+
import loadLunrResults from '../../lib/search/lunr-search.js'
16+
import { readFileSync } from 'fs'
17+
import { join } from 'path'
18+
19+
const queryData = JSON.parse(readFileSync(join(process.cwd(), 'script/search/search-qa-data.json')))
20+
21+
const version = 'dotcom'
22+
const language = 'en'
23+
const limit = 10
24+
const TOP_RANK = 3
25+
26+
main()
27+
28+
async function main() {
29+
const rankResults = []
30+
31+
for (const item in queryData) {
32+
const { query, href } = queryData[item]
33+
34+
try {
35+
const results = await loadLunrResults({
36+
version,
37+
language,
38+
query,
39+
limit,
40+
})
41+
42+
const hrefs = results.map((result) => result.url.replace('/en', ''))
43+
let rank = hrefs.indexOf(href)
44+
// this allows us to sort the results by rank, including total misses
45+
if (rank === -1) {
46+
rank = limit
47+
}
48+
rankResults.push({ query, href, rank })
49+
} catch (err) {
50+
console.error(err)
51+
}
52+
}
53+
logResults(rankResults)
54+
}
55+
56+
async function logResults(results) {
57+
results.sort((a, b) => a.rank - b.rank)
58+
59+
let first = 0
60+
let top = 0
61+
let low = 0
62+
let miss = 0
63+
results.forEach((result) => {
64+
const { query, href, rank } = result
65+
if (rank === limit) {
66+
miss++
67+
console.log(`🔴 query: ${query} - Expected href: ${href}\n`)
68+
return
69+
}
70+
if (rank === 0) {
71+
first++
72+
console.log(`⭐ Query: ${query} - Expected href: ${href}`)
73+
return
74+
}
75+
if (rank < TOP_RANK) {
76+
top++
77+
console.log(`🟢 Query: ${query} - Expected href: ${href}`)
78+
return
79+
}
80+
low++
81+
console.log(`🟡 Query: ${query} - Expected href: ${href}`)
82+
})
83+
84+
const firstPercentage = ((first / queryData.length) * 100).toFixed(1)
85+
const topPercentage = ((top / queryData.length) * 100).toFixed(1)
86+
const lowPercentage = ((low / queryData.length) * 100).toFixed(1)
87+
const missPercentage = ((miss / queryData.length) * 100).toFixed(1)
88+
89+
console.log(`\n⭐ First hit ${firstPercentage}%`)
90+
console.log(`\n🟢 Top ${TOP_RANK} hit ${topPercentage}%`)
91+
console.log(`\n🟡 Top ${limit} hit ${lowPercentage}%`)
92+
console.log(`\n🔴 Miss ${missPercentage}%`)
93+
}

0 commit comments

Comments
 (0)