-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
757 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Submit Verification Request | ||
on: | ||
issue_comment: | ||
types: [created, edited] | ||
jobs: | ||
submit: | ||
if: ${{ github.event.issue.pull_request }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Node | ||
uses: actions/setup-node@v3 | ||
if: contains(github.event.comment.body, '/verify') | ||
with: | ||
node-version: 16 | ||
- uses: actions/github-script@v6 | ||
id: process-comment | ||
with: | ||
script: | | ||
const body = context.payload.comment.body | ||
return body | ||
- uses: actions/checkout@v3 | ||
- name: Install Packages | ||
run: yarn --cwd ./scripts install --frozen-lockfile | ||
- name: Submit Request to Discord | ||
run: node --no-warnings ./scripts/verify/index.js | ||
env: | ||
DISCORD_VERIFY_WEBHOOK: ${{ secrets.DISCORD_VERIFY_WEBHOOK }} | ||
EXTENSION_KEY: ${{ steps.process-comment.outputs.result }} | ||
- uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'Verification has been submitted' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { expect, test } from "vitest"; | ||
import { validateManifest } from "../validation/manifest"; | ||
|
||
test("successfully validates valid manifest", () => { | ||
const validManifest = { | ||
title: "Example Extension Manifest", | ||
description: "An example manifest for testing", | ||
author: "Extension Tests", | ||
image: "https://example.com/", | ||
icon: "https://example.com/", | ||
tags: ["combat", "tool", "automation"], | ||
manifest: "https://example.com/manifest.json", | ||
"learn-more": "[email protected]", | ||
}; | ||
|
||
const expectedResult = []; | ||
|
||
expect(validateManifest(validManifest)).toStrictEqual(expectedResult); | ||
}); | ||
|
||
test("throws error on invalid tag", () => { | ||
const invalidTagInManifest = { | ||
title: "Example Extension Manifest", | ||
description: "An example manifest for testing", | ||
author: "Extension Tests", | ||
image: "https://example.com/", | ||
icon: "https://example.com/", | ||
tags: ["combat", "tool", "automation", "built-by-owlbear"], | ||
manifest: "https://example.com/manifest.json", | ||
"learn-more": "[email protected]", | ||
}; | ||
|
||
const expectedResult = ['"tags[3]" contains an excluded value']; | ||
|
||
expect(validateManifest(invalidTagInManifest)).toStrictEqual(expectedResult); | ||
}); | ||
|
||
test("should return all validation errors in one message", () => { | ||
const mulitpleValidationIssues = { | ||
description: "An example manifest for testing", | ||
author: "Extension Tests", | ||
icon: "example.com/", | ||
tags: [], | ||
manifest: "https://example.com/manifest.json", | ||
}; | ||
|
||
const expectedResult = [ | ||
'"title" is required', | ||
'"image" is required', | ||
'"icon" failed custom validation because Invalid URL', | ||
'"tags" must contain at least 1 items', | ||
'"learn-more" is required', | ||
]; | ||
|
||
expect(validateManifest(mulitpleValidationIssues)).toStrictEqual( | ||
expectedResult | ||
); | ||
}); | ||
|
||
test("should return issue when learn-more is invalid", () => { | ||
const learnMoreInvalidationIssue = { | ||
title: "Example Extension Manifest", | ||
description: "An example manifest for testing", | ||
author: "Extension Tests", | ||
image: "https://example.com/", | ||
icon: "https://example.com/", | ||
tags: ["combat", "tool", "automation"], | ||
manifest: "https://example.com/manifest.json", | ||
"learn-more": "learn-more.com", | ||
}; | ||
|
||
const expectedResult = [ | ||
'"learn-more" does not match any of the allowed types', | ||
]; | ||
|
||
expect(validateManifest(learnMoreInvalidationIssue)).toStrictEqual( | ||
expectedResult | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import fetch from "node-fetch"; | ||
import { getExtensionDetailsFromKey } from "../common/extensionDetails.js"; | ||
|
||
function createDiscordVerificationPost(id, data) { | ||
const text = `## Extension Verfication Request\n\n${data.title} would like to be verified.\n\nIt can be installed via this [store page](https://extensions.owlbear.rodeo/${id}).\n\nTo be verified the extension must meet these criteria:\n\n- Extension design uses accessible colors :art:\n- Extension design uses accessible font sizes :blue_book:\n- Extension is legible with Owlbear Rodeo’s light and dark theme :ghost:\n- Extension is fully functional on mobile devices (1) :mobile_phone:\n- Extension is fully functional across all major browsers (2) :computer:\n- Extension requires no other extensions to be installed :link: \n- Extension functions in a private browsing window or with cookies disabled :lock:\n- Extension makes proper use of the Owlbear Rodeo APIs (3) :jigsaw: \n- Extension functions in all configurations of an Owlbear Rodeo Room (4) :house:\n- Extension provides user support for queries, issues and requests :question:\n- Extension has no known bugs :bug: \n- Extension manifest is hosted on a custom domain controlled by the extension developer :pencil:\n\nNotes:\n\n1) This includes iPhone’s, Android devices as well as tablets such as an iPad.\n\n2) Major browsers include Chrome, Firefox and Safari\n\n3) For example the Scene API is only used to store data that shares the Scene lifecycle\n\n4) Valid configurations include a Room with a Scene open and no Scene open\n\nAlso note that the term “fully functional” above means all extension functionally works correctly whereas the term “functional” means the extension still functions but some features may not be available.\n\n### To help verify this extension react to this message with the criteria that are met! (i.e. react :bug: if it has no known bugs)`; | ||
|
||
const post = { | ||
thread_name: `${data.title} wants to be verified`, | ||
content: text, | ||
}; | ||
|
||
return post; | ||
} | ||
|
||
export async function sendDiscordWebhook(value) { | ||
const values = value.replaceAll('"', "").split(" "); | ||
if (values.length !== 2) { | ||
console.log(values); | ||
throw Error("invalid submission"); | ||
} | ||
|
||
const key = values[1]; | ||
const { key: id, data } = await getExtensionDetailsFromKey(key); | ||
|
||
const embed = createDiscordVerificationPost(id, data); | ||
|
||
const response = await fetch(process.env.DISCORD_VERIFY_WEBHOOK, { | ||
method: "POST", | ||
body: JSON.stringify(embed), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
|
||
if (response.ok) { | ||
console.log("Success!!"); | ||
} else { | ||
console.log(JSON.stringify(await response.text(), null, 2)); | ||
} | ||
} | ||
|
||
await sendDiscordWebhook(process.env.EXTENSION_KEY); |
Oops, something went wrong.