Skip to content

Commit 0ff435e

Browse files
authored
Add status badges (#87)
* Add status badge * cleanup
1 parent c179bf3 commit 0ff435e

7 files changed

Lines changed: 51 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ When submitting your index file make sure it follows the current [`JSON schema`]
1313

1414
It is also recommended to fill the `contact` field with support information for your organization. This will be displayed when users click the **Support** button in the Add-on's tile.
1515

16+
It is also possible to display a workflow status badge of an add-on. It works in a similar manner as a badges displayed on the README pages on Github. Use the `testStatus` field to provide
17+
the badge's URL for your add-on. Learn more about generating the [badges urls](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/adding-a-workflow-status-badge#using-the-workflow-file-name).
18+
1619
## Validation
1720

1821
If you use Visual Studio Code, the editor will automatically provide validation and autocompletion for the index file. If you are using another editor, you can use the JSON schema located at `resources/schema.json` to validate your file. Make sure that your file correctly follows the schema before creating your pull request, otherwise the CI pipeline will fail. Use the `validate-index` script to make sure that the schema validates successfully:

index/nrfconnect.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
"apps": "app",
104104
"avatar": "https://avatars.githubusercontent.com/u/40860733?s=200&v=4",
105105
"docsUrl": "https://github.com/nrfconnect/ncs-example-application/blob/main/README.md",
106+
"testStatus": {
107+
"badge": "https://github.com/nrfconnect/ncs-example-application/actions/workflows/build-using-docker.yml/badge.svg"
108+
},
106109
"releases": [
107110
{
108111
"date": "2024-12-17T16:52:00Z",

resources/output_schema.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@
189189
"avatar": {
190190
"type": "string",
191191
"description": "An image displayed next to an Add-on"
192+
},
193+
"testStatus": {
194+
"type": "object",
195+
"properties": {
196+
"badge": {
197+
"type": "string",
198+
"description": "An url pointing to a workflow status badge. How to get the badge for a repo hosted on Github: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/adding-a-workflow-status-badge#using-the-workflow-file-name"
199+
}
200+
}
192201
}
193202
},
194203
"required": [

resources/schema.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@
161161
"required": [
162162
"detailsUrl"
163163
]
164+
},
165+
"testStatus": {
166+
"type": "object",
167+
"properties": {
168+
"badge": {
169+
"type": "string",
170+
"description": "An url pointing to a workflow status badge. How to get the badge for a repo hosted on Github: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/adding-a-workflow-status-badge#using-the-workflow-file-name"
171+
}
172+
}
164173
}
165174
},
166175
"additionalProperties": false,

scripts/generate-index-json.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ async function fetchRepoData(
113113
docsUrl: app.docsUrl,
114114
restricted: app.restricted,
115115
avatar: app.avatar,
116+
testStatus: app.testStatus,
116117
} as Application;
117118
} catch {
118119
throw new Error(`Failed to fetch data for ${orgId}/${app.name}`);

site/src/app/AppBlock.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ function AppBlock({ app, setShowingAppDetails }: Props): JSX.Element {
9393
})}
9494
/>
9595
)}
96+
97+
{app.testStatus &&
98+
<div className="mx-2">
99+
<img src={`${app.testStatus.badge}`} className="" />
100+
</div>
101+
}
96102
</div>
97103
</div>
98104
</div>
@@ -167,7 +173,7 @@ function AppBlock({ app, setShowingAppDetails }: Props): JSX.Element {
167173
</button>
168174
</div>
169175

170-
<div className="flex w-full justify-between gap-3 text-xs text-gray-600">
176+
<div className="flex w-full px-1 gap-5 text-xs text-gray-600">
171177
{app.license && (
172178
<div className="flex items-center gap-1">
173179
<LawIcon /> {app.license}

site/src/schema.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ export const appMetadataSchema = {
142142
},
143143
description: 'Mark the restricted access to any of the dependencies.',
144144
required: ['detailsUrl'],
145+
},
146+
testStatus: {
147+
type: 'object',
148+
properties: {
149+
badge: {
150+
type: 'string',
151+
description: 'An url pointing to a workflow status badge. How to get the badge for a repo hosted on Github: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/adding-a-workflow-status-badge#using-the-workflow-file-name',
152+
}
153+
}
145154
}
146155
},
147156
additionalProperties: false,
@@ -265,7 +274,16 @@ export const appSchema = {
265274
avatar: {
266275
type: 'string',
267276
description: 'An image displayed next to an Add-on',
268-
}
277+
},
278+
testStatus: {
279+
type: 'object',
280+
properties: {
281+
badge: {
282+
type: 'string',
283+
description: 'An url pointing to a workflow status badge. How to get the badge for a repo hosted on Github: https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/monitoring-workflows/adding-a-workflow-status-badge#using-the-workflow-file-name',
284+
}
285+
}
286+
},
269287
},
270288
required: [
271289
'id',

0 commit comments

Comments
 (0)