-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script that gets the list of PRs since last release
- Loading branch information
Showing
12 changed files
with
2,185 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
{ | ||
"dependencies": { | ||
"node-fetch": "^3.3.2" | ||
} | ||
} |
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 @@ | ||
*.json |
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,7 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"printWidth": 120, | ||
"singleQuote": true, | ||
"semi": false, | ||
"trailingComma": "none" | ||
} |
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,3 @@ | ||
{ | ||
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"] | ||
} |
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,19 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run Test (current file)", | ||
"type": "node", | ||
"request": "launch", | ||
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", | ||
"args": [ | ||
"${relativeFile}" | ||
], | ||
"cwd": "${workspaceRoot}", | ||
"console": "integratedTerminal" | ||
} | ||
] | ||
} |
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 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"editor.tabSize": 2 | ||
} |
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,8 @@ | ||
# Integration Test | ||
|
||
## Resources | ||
|
||
1. Integration tests are located at ./test to support the integration-test.yml GitHub Action. | ||
1. The test configuration is located at [./test/testConfig.js](./test/testConfig.js). The test cases to be run are documented there. | ||
1. The classes used in the integration tests are located at ./lib. Tests for those tooling classes are located at ./test/lib. Run `npm test` to test the tooling classes. | ||
1. Sample API test calls to the production deployment can be found at ./api-test. The [Insomnia collection](./api-test/clearlydefined_prod_api_test_insomnia_collection.json) is organized by endpoints (definitions, harvest, and notices). Refer to the [Swagger UI](https://api.clearlydefined.io/api-docs/#/) for detailed documentation. The `Ping/health check` can be used as the first check to see if the service is up and running. |
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,25 @@ | ||
// (c) Copyright 2024, SAP SE and ClearlyDefined contributors. Licensed under the MIT license. | ||
// SPDX-License-Identifier: MIT | ||
|
||
const js = require('@eslint/js') | ||
const globals = require('globals') | ||
const eslintConfigPrettier = require('eslint-config-prettier') | ||
|
||
module.exports = [ | ||
js.configs.recommended, | ||
{ | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
...globals.mocha | ||
}, | ||
parserOptions: { | ||
sourceType: 'module' | ||
} | ||
}, | ||
rules: { | ||
'no-console': 'off' | ||
} | ||
}, | ||
eslintConfigPrettier | ||
] |
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,69 @@ | ||
// (c) Copyright ClearlyDefined. Licensed under the MIT license. | ||
// SPDX-License-Identifier: MIT | ||
|
||
// Prerequisites: | ||
// 1. Install node-fetch package by running `npm install node-fetch` | ||
|
||
// Usage: | ||
// node getPRs.mjs <repository> <tag1> <tag2> <gh-pat-token> | ||
|
||
import fetch from 'node-fetch'; | ||
|
||
const owner = 'clearlydefined'; | ||
const repo = process.argv[2]; // Pass the repository name as an argument | ||
const tag1 = process.argv[3]; // Pass the first tag as an argument | ||
const tag2 = process.argv[4]; // Pass the second tag as an argument | ||
const token = process.argv[5]; // Pass the GitHub token as an argument | ||
|
||
async function getPRs(owner, repo, token) { | ||
const url = `https://api.github.com/repos/${owner}/${repo}/pulls?state=closed`; | ||
const headers = { | ||
'Authorization': `token ${token}`, | ||
'User-Agent': 'GitHub-Pull-Request-Info' | ||
}; | ||
|
||
const response = await fetch(url, { headers }); | ||
const data = await response.json(); | ||
|
||
return data; | ||
} | ||
|
||
async function getTagComparison(owner, repo, tag1, tag2, token) { | ||
const url = `https://api.github.com/repos/${owner}/${repo}/compare/${tag1}...${tag2}`; | ||
const headers = { | ||
'Authorization': `token ${token}`, | ||
'User-Agent': 'GitHub-Pull-Request-Info' | ||
}; | ||
|
||
const response = await fetch(url, { headers }); | ||
const data = await response.json(); | ||
|
||
const shas = data.commits.map(commit => commit.sha); | ||
console.log("count shas: " + shas.length) | ||
const basesha = data.base_commit.sha; | ||
console.log("basesha: " + basesha) | ||
if (!(basesha === null || typeof basesha === 'undefined')) { | ||
shas.push(basesha); | ||
} | ||
console.log("count shas: " + shas.length) | ||
|
||
return shas; | ||
} | ||
|
||
async function getPRDetails() { | ||
const prs = await getPRs(owner, repo, token); | ||
const comparison = await getTagComparison(owner, repo, tag1, tag2, token); | ||
|
||
const mergedPRs = prs.filter(pr => pr.merged_at && comparison.includes(pr.merge_commit_sha)); | ||
|
||
const prDetails = mergedPRs.map(pr => { | ||
const prNumber = pr.number; | ||
const prTitle = pr.title; | ||
const contributors = pr.user.login; | ||
return `- ${prTitle} (#${prNumber}) (@${contributors})`; | ||
}); | ||
|
||
console.log(prDetails.join('\n')); | ||
} | ||
|
||
getPRDetails(); |
Oops, something went wrong.