-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:interledger/web-monetization-extens…
…ion into chore/payment-flow-restructure
- Loading branch information
Showing
30 changed files
with
7,713 additions
and
7,516 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
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,99 @@ | ||
name: Bug report | ||
description: File a bug report | ||
title: '[BUG] ' | ||
labels: ['bug', 'triage'] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thanks for taking the time to fill out this bug report! | ||
- type: textarea | ||
id: reproduce | ||
attributes: | ||
label: Steps to reproduce | ||
description: Explain how the behavior can be reproduced. | ||
value: | | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. Click on '...' | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: expected | ||
attributes: | ||
label: Expected result | ||
description: A clear and concise description of what you expected to happen. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: actual | ||
attributes: | ||
label: Actual result | ||
description: A clear and concise description of what is happening. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: screenshots | ||
attributes: | ||
label: Screenshots or videos | ||
description: If applicable, add screenshots and/or a short video to help explain your problem. | ||
|
||
- type: textarea | ||
id: additional-context | ||
attributes: | ||
label: Additional context | ||
description: Add any other context about the problem here. | ||
|
||
- type: dropdown | ||
id: os | ||
attributes: | ||
label: Operating system | ||
description: What operating system are you seeing the problem on? | ||
multiple: true | ||
options: | ||
- Windows | ||
- macOS | ||
- Linux | ||
- Android | ||
- iOS | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
id: os-version | ||
attributes: | ||
label: Operating system version | ||
description: What version of the operating system(s) are you seeing the problem on? | ||
|
||
- type: dropdown | ||
id: browsers | ||
attributes: | ||
label: Browsers | ||
description: What browser(s) are you seeing the problem on? | ||
multiple: true | ||
options: | ||
- Chrome | ||
- Microsoft Edge | ||
- Firefox | ||
- Opera | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
id: browser-version | ||
attributes: | ||
label: Browser version | ||
description: What version of the browser(s) are you seeing the problem on? | ||
|
||
- type: input | ||
id: version | ||
attributes: | ||
label: Extension version | ||
description: What version of our extension are you running? | ||
validations: | ||
required: true |
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,5 @@ | ||
blank_issues_enabled: true | ||
contact_links: | ||
- name: Ask a question | ||
url: https://github.com/interledger/web-monetization-extension/discussions | ||
about: Ask questions and discuss with other community members |
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,31 @@ | ||
name: Feature request | ||
description: Submit a feature request | ||
title: '[FEATURE REQUEST] ' | ||
labels: ['discussion: idea', 'triage'] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thanks for taking the time to fill out this feature request! Please fill out this form as completely as possible. If this issue has a `needs approval` label, please do not start coding yet. Wait until a core member approves the feature request by removing this label. | ||
- type: textarea | ||
id: describe | ||
attributes: | ||
label: Describe the feature you would like to request | ||
description: A clear and concise description of what you want and what your use case is. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: solution | ||
attributes: | ||
label: Describe the solution you would like | ||
description: A clear and concise description of what you want to happen. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: context | ||
attributes: | ||
label: Additional context | ||
description: Add any other context or screenshots about the feature request here. |
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,18 @@ | ||
name: Feature | ||
description: Scope out a feature implementation | ||
body: | ||
- type: textarea | ||
id: context | ||
attributes: | ||
label: Context | ||
description: A clear and concise description of the feature. | ||
validations: | ||
required: true | ||
|
||
- type: textarea | ||
id: todos | ||
attributes: | ||
label: Todos | ||
description: List of todos to complete the feature. | ||
validations: | ||
required: true |
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,24 @@ | ||
<!-- | ||
Pull request titles should follow conventional commit format. | ||
https://www.conventionalcommits.org/en/v1.0.0/ | ||
--> | ||
|
||
## Context | ||
|
||
<!-- | ||
What were you trying to do? | ||
Provide further details about how the feature should be tested/reviewed if necessary. | ||
If the PR is related to an open issue(s) please provide a list of them. | ||
Example: | ||
- closes (or fixes) #<issue number> | ||
- closes (or fixes) #<issue number> | ||
--> | ||
|
||
Closes #<issue number>. | ||
|
||
## Changes proposed in this pull request | ||
|
||
<!-- | ||
Provide a succinct description of what this pull request entails. | ||
--> |
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,22 @@ | ||
const BADGE = | ||
'<img src="https://img.shields.io/badge/{{ CONCLUSION }}-{{ BADGE_COLOR }}?style=for-the-badge&label={{ BADGE_LABEL }}" alt="Badge" />' | ||
const BROWSERS = ['chrome', 'firefox', 'opera', 'edge'] | ||
const COLORS = { | ||
green: '3fb950', | ||
red: 'd73a49', | ||
} | ||
const TEMPLATE_VARS = { | ||
tableBody: '{{ TABLE_BODY }}', | ||
sha: '{{ SHA }}', | ||
conslusion: '{{ CONCLUSION }}', | ||
badgeColor: '{{ BADGE_COLOR }}', | ||
badgeLabel: '{{ BADGE_LABEL }}', | ||
jobLogs: '{{ JOB_LOGS }}', | ||
} | ||
|
||
module.exports = { | ||
BADGE, | ||
BROWSERS, | ||
COLORS, | ||
TEMPLATE_VARS, | ||
} |
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,67 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
/* eslint-disable no-console */ | ||
const { BROWSERS } = require('./constants.cjs') | ||
|
||
async function getBrowserArfifacts({ github, owner, repo, name }) { | ||
const artifacts = [] | ||
const result = await github.rest.actions.listArtifactsForRepo({ | ||
owner, | ||
repo, | ||
name, | ||
}) | ||
|
||
for (let i = 0; i < result.data.total_count; i++) { | ||
artifacts.push(result.data.artifacts[i].id) | ||
} | ||
|
||
return artifacts | ||
} | ||
|
||
async function getPRArtifacts({ github, owner, repo, prNumber }) { | ||
const promises = [] | ||
const artifacts = [] | ||
|
||
BROWSERS.forEach(browser => | ||
promises.push( | ||
getBrowserArfifacts({ | ||
github, | ||
owner, | ||
repo, | ||
name: `${prNumber}-${browser}`, | ||
}), | ||
), | ||
) | ||
|
||
const data = await Promise.all(promises) | ||
|
||
for (let i = 0; i < data.length; i++) { | ||
artifacts.push.apply(artifacts, data[i]) | ||
} | ||
|
||
return artifacts | ||
} | ||
|
||
module.exports = async ({ github, context, core }) => { | ||
if (context.payload.action !== 'closed') { | ||
core.setFailed('This action only works on closed PRs.') | ||
} | ||
|
||
const { owner, repo } = context.repo | ||
const prNumber = context.payload.number | ||
const promises = [] | ||
|
||
const artifacts = await getPRArtifacts({ github, owner, repo, prNumber }) | ||
|
||
for (let i = 0; i < artifacts.length; i++) { | ||
promises.push( | ||
github.rest.actions.deleteArtifact({ | ||
owner, | ||
repo, | ||
artifact_id: artifacts[i], | ||
}), | ||
) | ||
} | ||
|
||
await Promise.all(promises) | ||
console.log(`Deleted ${artifacts.length} artifacts for PR #${prNumber}.`) | ||
} |
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,96 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
/* eslint-disable no-console */ | ||
const fs = require('node:fs/promises') | ||
const { COLORS, TEMPLATE_VARS, BADGE } = require('./constants.cjs') | ||
|
||
const ARTIFACTS_DATA = { | ||
chrome: { | ||
name: 'Chrome', | ||
url: null, | ||
size: null, | ||
}, | ||
firefox: { | ||
name: 'Firefox', | ||
url: null, | ||
size: null, | ||
}, | ||
opera: { | ||
name: 'Opera', | ||
url: null, | ||
size: null, | ||
}, | ||
edge: { | ||
name: 'Edge', | ||
url: null, | ||
size: null, | ||
}, | ||
} | ||
|
||
function getBadge(conclusion, badgeColor, badgeLabel) { | ||
return BADGE.replace(TEMPLATE_VARS.conslusion, conclusion) | ||
.replace(TEMPLATE_VARS.badgeColor, badgeColor) | ||
.replace(TEMPLATE_VARS.badgeLabel, badgeLabel) | ||
} | ||
|
||
function formatBytes(bytes, decimals = 2) { | ||
if (!Number(bytes)) return '0B' | ||
const k = 1024 | ||
const dm = decimals < 0 ? 0 : decimals | ||
const sizes = ['B', 'KB', 'MB', 'GB'] | ||
const i = Math.floor(Math.log(bytes) / Math.log(k)) | ||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))}${sizes[i]}` | ||
} | ||
|
||
module.exports = async ({ github, context, core }) => { | ||
const { owner, repo } = context.repo | ||
const baseUrl = context.payload.repository.html_url | ||
const suiteId = context.payload.workflow_run.check_suite_id | ||
const runId = context.payload.workflow_run.id | ||
const conclusion = context.payload.workflow_run.conclusion | ||
const sha = context.payload.workflow_run.pull_requests[0].head.sha | ||
const prNumber = context.payload.workflow_run.pull_requests[0].number | ||
const jobLogsUrl = `${baseUrl}/actions/runs/${context.payload.workflow_run.id}` | ||
const template = await fs.readFile('./.github/actions/templates/build-status.md', 'utf8') | ||
const tableRows = [] | ||
|
||
core.setOutput('conclusion', conclusion) | ||
|
||
if (conclusion === 'cancelled') { | ||
return | ||
} | ||
|
||
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
owner, | ||
repo, | ||
run_id: runId, | ||
}) | ||
|
||
artifacts.data.artifacts.forEach(artifact => { | ||
const [, key] = artifact.name.split('-') | ||
ARTIFACTS_DATA[key].url = `${baseUrl}/suites/${suiteId}/artifacts/${artifact.id}` | ||
ARTIFACTS_DATA[key].size = formatBytes(artifact.size_in_bytes) | ||
}) | ||
|
||
Object.keys(ARTIFACTS_DATA).forEach(k => { | ||
const { name, url, size } = ARTIFACTS_DATA[k] | ||
if (url === null && size === null) { | ||
const badgeUrl = getBadge('failure', COLORS.red, name) | ||
tableRows.push(`<tr><td align="center">${badgeUrl}</td><td align="center">N/A</td></tr>`) | ||
} else { | ||
const badgeUrl = getBadge('success', COLORS.green, `${name} (${size})`) | ||
tableRows.push( | ||
`<tr><td align="center">${badgeUrl}</td><td align="center"><a href="${url}">Download</a></td></tr>`, | ||
) | ||
} | ||
}) | ||
|
||
const tableBody = tableRows.join('') | ||
const commentBody = template | ||
.replace(TEMPLATE_VARS.conslusion, conclusion) | ||
.replace(TEMPLATE_VARS.sha, sha) | ||
.replace(TEMPLATE_VARS.jobLogs, `<a href="${jobLogsUrl}">Run #${runId}</a>`) | ||
.replace(TEMPLATE_VARS.tableBody, tableBody) | ||
|
||
core.setOutput('comment_body', commentBody) | ||
core.setOutput('pr_number', prNumber) | ||
} |
Oops, something went wrong.