Skip to content

Commit

Permalink
first draft of gh action with test data
Browse files Browse the repository at this point in the history
  • Loading branch information
radishmouse committed Jun 11, 2024
1 parent e2a2c72 commit 2e662cb
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: validate-json

on:
[push]
# push:
# branches: ["main"]
# pull_request:
# branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.22.4"
- name: Install dependencies
run: go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest
- name: Validate JSON files
run: jv test/data/snapshot-schema.json test/data/json/*.json
60 changes: 60 additions & 0 deletions test/data/json/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[
{
"id": "f103c749-9932-48bb-8f61-2e8ed2beacc3",
"start_at": "2012-03-29T10:05:45-06:00",
"end_at": "2012-03-29T10:05:45-06:00",
"title": "hello user - this needs translation",
"description": "lorem ipsum user - this needs translation",
"CTA": "lorem ipsum user - this needs translation",
"URL": "https://thunderbird.net",
"severity": 5,
"type": "donation",
"targeting": {
"percent_chance": 10,
"exclude": [
{
"locales": [],
"versions": [],
"channels": [],
"operating_systems": []
}
],
"include": [
{
"locales": [],
"versions": [],
"channels": []
}
]
}
},
{
"id": "f103c749-9932-48bb-8f61-2e8ed2beacc3",
"start_at": "2012-03-29T10:05:45-06:00",
"end_at": "2024-05-03T15:49:20.331Z",
"title": "hello user - this needs translation",
"description": "lorem ipsum user - this needs translation",
"CTA": "lorem ipsum user - this needs translation",
"URL": "https://thunderbird.net",
"severity": 5,
"type": "donation",
"targeting": {
"percent_chance": 10,
"exclude": [
{
"locales": [],
"versions": [],
"channels": [],
"operating_systems": []
}
],
"include": [
{
"locales": [],
"versions": [],
"channels": []
}
]
}
}
]
125 changes: 125 additions & 0 deletions test/data/snapshot-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Thunderbird In-App Notifications",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "Unique ID set by the server"
},
"start_at": {
"type": "string",
"format": "date-time",
"description": "UTC Timestamp after which Thunderbird will show the event after startup."
},
"end_at": {
"type": "string",
"format": "date-time",
"description": "UTC Timestamp after which Thunderbird will never show the event, even if it has never been shown to the user."
},
"title": {
"type": "string",
"description": "Short sentence describing the event which will be displayed in the Thunderbird UI."
},
"description": {
"type": "string",
"description": "A short paragraph that can contain HTML and will be displayed in the Thunderbird UI."
},
"URL": {
"type": "string",
"format": "uri",
"description": "URL to open from the CTA, if any."
},
"CTA": {
"type": "string",
"description": "Link text to show for the URL."
},
"severity": {
"enum": [1, 2, 3, 4, 5],
"description": "Severity level, where 1 is the most important/urgent and 5 is the least."
},
"type": {
"enum": ["donation", "message", "security", "blog"],
"description": "Category of notification."
},
"targeting": {
"type": "object",
"properties": {
"percent_chance": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"exclude": {
"type": "array",
"items": {
"$ref": "#/definitions/profile"
}
},
"include": {
"type": "array",
"items": {
"$ref": "#/definitions/profile"
}
}
}
}
},
"required": [
"id",
"start_at",
"end_at",
"title",
"description",
"severity",
"type",
"targeting"
],
"dependentRequired": { "CTA": ["URL"] }
},
"definitions": {
"profile": {
"type": "object",
"properties": {
"locales": {
"type": "array",
"items": {
"type": "string"
}
},
"versions": {
"type": "array",
"items": {
"type": "string"
}
},
"channels": {
"type": "array",
"items": {
"enum": ["default", "esr", "release", "beta", "daily"],
"description": "Channel"
}
},
"operating_systems": {
"type": "array",
"items": {
"enum": [
"win",
"macosx",
"linux",
"freebsd",
"openbsd",
"netbsd",
"solaris",
"other"
],
"description": "Operating System"
}
}
}
}
}
}

0 comments on commit 2e662cb

Please sign in to comment.