Skip to content

Commit

Permalink
Feature: Web version announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmhtr committed Mar 4, 2024
1 parent 1d60392 commit 5d06691
Show file tree
Hide file tree
Showing 15 changed files with 188 additions and 45 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

## [2.14.0] - 2024-03-03
### Added
- Announcing the web version development.
- Improved telemetry, by adding a reviewers summary.
- "Build with" link in the footer.

## [2.13.0] - 2024-02-10
### Added
- `exclude` option to exclude specific users from the stats.
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,33 @@ Used by hundreds of successful teams:
| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: |
| <a href="https://www.intel.com"><img src="https://avatars.githubusercontent.com/u/17888862?s=200&v=4" width="64"></a><br/>**Intel** | <a href="https://auth0.com/"><img src="https://avatars.githubusercontent.com/u/2824157?s=200&v=4" width="64"></a><br/>**Auth0** | <a href="https://www.additionwealth.com/"><img src="https://avatars.githubusercontent.com/u/86253902?s=200&v=4" width="64"></a><br/>**Addition** | <a href="https://fauna.com/"><img src="https://avatars.githubusercontent.com/u/1477000?s=200&v=4" width="64"></a><br/>**Fauna** | <a href="http://open.cdc.gov/"><img src="https://avatars.githubusercontent.com/u/12104975?s=200&v=4" width="64"></a><br/>**CDC** | <a href="https://www.wecasa.fr/"><img src="https://avatars.githubusercontent.com/u/56955553?s=200&v=4" width="64"></a><br/>**Wecasa** | <a href="https://bolt.eu/"><img src="https://avatars.githubusercontent.com/u/37693190?s=200&v=4" width="64"></a><br/>**Bolt** | <a href="https://republic.com/"><img src="https://avatars.githubusercontent.com/u/18252987?s=200&v=4" width="64"></a><br/>**Republic** |

## Author
## Authors

|<a href="https://github.com/manuelmhtr"><img src="https://avatars.githubusercontent.com/u/1031639?v=4" width="32"></a>|[@manuelmhtr](https://github.com/manuelmhtr)<br/>🇲🇽 Guadalajara, MX|
| -- | :-- |
|<a href="https://github.com/CarlosCRG19"><img src="https://avatars.githubusercontent.com/u/61464973?v=4" width="32"></a>|[@CarlosCRG19](https://github.com/CarlosCRG19)<br/>🇲🇽 Colima, MX|


## Help

This project is maintained by a single person, considering supporting the project by:
This project is maintained by a small team, considering supporting the project by:

* ⭐ Star this repo.
* Sharing your [feedback](https://github.com/flowwer-dev/pull-request-stats/discussions/new).
* Joining the [community](https://discord.gg/SGYbZkac).
* Sharing your [feedback](https://forms.gle/xNakBCbfjEnVvmcZ7).
* Joining the [community](https://discord.gg/wk5zy5aAZQ).
* Becoming a [sponsor](https://github.com/sponsors/manuelmhtr).

### License
## NEW: We are building the web version! ⚡

![](/assets/web-banner.png)

Exciting News! After receiving numerous requests from developers, we're actively developing a stand-alone version of this action!

**Get early access** by filling out [this form](https://c4tj3h4y5wh.typeform.com/to/Ejo56p27).

Psst! Current sponsors will receive early access and free premium feature for a limited time 🤫


## License

MIT
Binary file added assets/web-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 41 additions & 18 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41280,7 +41280,7 @@ const run = async (params) => {

if (alreadyPublished(pullRequest)) {
core.info('Skipping execution because stats are published already');
return;
return null;
}

const pulls = await getPulls({
Expand All @@ -41306,7 +41306,7 @@ const run = async (params) => {
core.debug('Stats table built successfully');

const content = buildComment({
table, periodLength, org, repos,
table, periodLength, org, repos, isSponsor: params.isSponsor,
});
core.debug(`Commit content built successfully: ${content}`);

Expand All @@ -41318,15 +41318,21 @@ const run = async (params) => {
await core.setOutput('resultsMd', content);
await core.setOutput('resultsJson', whParams);

if (!pullRequestId) return;
await postComment({
octokit,
content,
publishAs,
pullRequestId,
currentBody: pullRequest.body,
});
core.debug('Posted comment successfully');
if (pullRequestId) {
await postComment({
octokit,
content,
publishAs,
pullRequestId,
currentBody: pullRequest.body,
});
core.debug('Posted comment successfully');
}

return {
reviewers,
pullRequest,
};
};

module.exports = async (params) => {
Expand All @@ -41340,8 +41346,8 @@ module.exports = async (params) => {

try {
telemetry.start(params);
await run({ ...params, isSponsor, octokit });
telemetry.success();
const results = await run({ ...params, isSponsor, octokit });
telemetry.success(results);
} catch (error) {
telemetry.error(error);
throw error;
Expand Down Expand Up @@ -41392,6 +41398,9 @@ const PR_BY_ID_QUERY = `
url
body
number
author {
login
}
comments(last: 100) {
nodes {
author {
Expand Down Expand Up @@ -41703,11 +41712,13 @@ module.exports = ({
table,
org,
repos,
isSponsor,
periodLength,
}) => {
const sources = buildSources({ buildGithubLink, org, repos });
const message = t('table.subtitle', { sources, count: periodLength });
return `## ${t('table.title')}\n${message}:\n${table}`;
const footer = isSponsor ? '' : `\n${t('table.footer')}`;
return `## ${t('table.title')}\n${message}:\n${table}${footer}`;
};


Expand Down Expand Up @@ -43360,11 +43371,12 @@ class Telemetry {
});
}

success() {
success(results) {
if (!this.useTelemetry) return;
sendSuccess({
timeMs: new Date() - this.startDate,
tracker: this.tracker,
...(results || {}),
});
}
}
Expand Down Expand Up @@ -43437,14 +43449,25 @@ module.exports = ({
/***/ 7513:
/***/ ((module) => {

module.exports = ({ tracker, timeMs }) => {
module.exports = ({
timeMs,
tracker,
pullRequest,
reviewers: reviewersInput,
}) => {
const timeSec = Math.floor(timeMs / 1000);
const timeMin = Math.floor(timeMs / 60000);
const prAuthor = pullRequest?.author?.login;
const reviewers = (reviewersInput || []).map((r) => r?.author?.login);
const reviewersCount = reviewers.length;

tracker.track('success', {
timeMs,
timeSec,
timeMin,
prAuthor,
reviewers,
reviewersCount,
});
};

Expand Down Expand Up @@ -48032,7 +48055,7 @@ module.exports = JSON.parse('{"name":"mixpanel","description":"A simple server-s
/***/ ((module) => {

"use strict";
module.exports = JSON.parse('{"name":"pull-request-stats","version":"2.13.0","description":"Github action to print relevant stats about Pull Request reviewers","main":"dist/index.js","type":"commonjs","scripts":{"build":"eslint src && ncc build src/index.js -o dist -a","test":"jest","lint":"eslint ./"},"keywords":[],"author":"Manuel de la Torre","license":"MIT","jest":{"testEnvironment":"node","testMatch":["**/?(*.)+(spec|test).[jt]s?(x)"]},"dependencies":{"@actions/core":"^1.10.1","@actions/github":"^6.0.0","axios":"^1.6.7","humanize-duration":"^3.31.0","i18n-js":"^3.9.2","jsurl":"^0.1.5","lodash.get":"^4.4.2","markdown-table":"^2.0.0","mixpanel":"^0.18.0"},"devDependencies":{"@vercel/ncc":"^0.38.1","eslint":"^8.56.0","eslint-config-airbnb-base":"^15.0.0","eslint-plugin-import":"^2.29.1","eslint-plugin-jest":"^27.6.3","jest":"^29.7.0"},"funding":"https://github.com/sponsors/manuelmhtr","packageManager":"[email protected]"}');
module.exports = JSON.parse('{"name":"pull-request-stats","version":"2.14.0","description":"Github action to print relevant stats about Pull Request reviewers","main":"dist/index.js","type":"commonjs","scripts":{"build":"eslint src && ncc build src/index.js -o dist -a","test":"jest","lint":"eslint ./"},"keywords":[],"author":"Manuel de la Torre","license":"MIT","jest":{"testEnvironment":"node","testMatch":["**/?(*.)+(spec|test).[jt]s?(x)"]},"dependencies":{"@actions/core":"^1.10.1","@actions/github":"^6.0.0","axios":"^1.6.7","humanize-duration":"^3.31.0","i18n-js":"^3.9.2","jsurl":"^0.1.5","lodash.get":"^4.4.2","markdown-table":"^2.0.0","mixpanel":"^0.18.0"},"devDependencies":{"@vercel/ncc":"^0.38.1","eslint":"^8.56.0","eslint-config-airbnb-base":"^15.0.0","eslint-plugin-import":"^2.29.1","eslint-plugin-jest":"^27.6.3","jest":"^29.7.0"},"funding":"https://github.com/sponsors/manuelmhtr","packageManager":"[email protected]"}');

/***/ }),

Expand All @@ -48056,7 +48079,7 @@ module.exports = JSON.parse('{"slack":{"logs":{"notConfigured":"Slack integratio
/***/ ((module) => {

"use strict";
module.exports = JSON.parse('{"title":"Pull reviewers stats","icon":"https://s3.amazonaws.com/manuelmhtr.assets/flowwer/logo/logo-1024px.png","subtitle":{"one":"Stats of the last day for {{sources}}","other":"Stats of the last {{count}} days for {{sources}}"},"sources":{"separator":", ","fullList":"{{firsts}} and {{last}}","andOthers":"{{firsts}} and {{count}} others"},"columns":{"avatar":"","username":"User","timeToReview":"Time to review","totalReviews":"Total reviews","totalComments":"Total comments"}}');
module.exports = JSON.parse('{"title":"Pull reviewers stats","icon":"https://s3.amazonaws.com/manuelmhtr.assets/flowwer/logo/logo-1024px.png","subtitle":{"one":"Stats of the last day for {{sources}}","other":"Stats of the last {{count}} days for {{sources}}"},"sources":{"separator":", ","fullList":"{{firsts}} and {{last}}","andOthers":"{{firsts}} and {{count}} others"},"columns":{"avatar":"","username":"User","timeToReview":"Time to review","totalReviews":"Total reviews","totalComments":"Total comments"},"footer":"<sup>⚡️ [Pull request stats](https://bit.ly/pull-request-stats)</sup>"}');

/***/ })

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pull-request-stats",
"version": "2.13.0",
"version": "2.14.0",
"description": "Github action to print relevant stats about Pull Request reviewers",
"main": "dist/index.js",
"type": "commonjs",
Expand Down
32 changes: 19 additions & 13 deletions src/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const run = async (params) => {

if (alreadyPublished(pullRequest)) {
core.info('Skipping execution because stats are published already');
return;
return null;
}

const pulls = await getPulls({
Expand All @@ -65,7 +65,7 @@ const run = async (params) => {
core.debug('Stats table built successfully');

const content = buildComment({
table, periodLength, org, repos,
table, periodLength, org, repos, isSponsor: params.isSponsor,
});
core.debug(`Commit content built successfully: ${content}`);

Expand All @@ -77,15 +77,21 @@ const run = async (params) => {
await core.setOutput('resultsMd', content);
await core.setOutput('resultsJson', whParams);

if (!pullRequestId) return;
await postComment({
octokit,
content,
publishAs,
pullRequestId,
currentBody: pullRequest.body,
});
core.debug('Posted comment successfully');
if (pullRequestId) {
await postComment({
octokit,
content,
publishAs,
pullRequestId,
currentBody: pullRequest.body,
});
core.debug('Posted comment successfully');
}

return {
reviewers,
pullRequest,
};
};

module.exports = async (params) => {
Expand All @@ -99,8 +105,8 @@ module.exports = async (params) => {

try {
telemetry.start(params);
await run({ ...params, isSponsor, octokit });
telemetry.success();
const results = await run({ ...params, isSponsor, octokit });
telemetry.success(results);
} catch (error) {
telemetry.error(error);
throw error;
Expand Down
6 changes: 6 additions & 0 deletions src/fetchers/fetchPullRequestById/__tests__/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const input = {
id: 'PR_kwDODiVEWs455SUz',
url: 'https://github.com/zenfi/api/pull/493',
number: 493,
author: {
login: 'author1',
},
comments: {
nodes: [
{
Expand All @@ -28,6 +31,9 @@ const expectedOutput = {
id: 'PR_kwDODiVEWs455SUz',
url: 'https://github.com/zenfi/api/pull/493',
number: 493,
author: {
login: 'author1',
},
comments: [
{
author: {
Expand Down
3 changes: 3 additions & 0 deletions src/fetchers/fetchPullRequestById/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const PR_BY_ID_QUERY = `
url
body
number
author {
login
}
comments(last: 100) {
nodes {
author {
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locales/en-US/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"timeToReview": "Time to review",
"totalReviews": "Total reviews",
"totalComments": "Total comments"
}
},
"footer": "<sup>⚡️ [Pull request stats](https://bit.ly/pull-request-stats)</sup>"
}
25 changes: 22 additions & 3 deletions src/interactors/__tests__/buildComment.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const { t } = require('../../i18n');
const buildComment = require('../buildComment');
const { getRepoName } = require('../../utils');

const TABLE_MOCK = 'TABLE';
const ORG = 'org';
const REPO1 = 'org/repo1';
const REPO2 = 'org/repo2';
const FOOTER = t('table.footer');

const linkOrg = (org) => `[${org}](https://github.com/${org})`;

Expand All @@ -18,7 +20,7 @@ describe('Interactors | .buildComment', () => {
const message = `Stats of the last day for ${linkOrg(ORG)}:`;

it('builds the message in singular', () => {
const expected = `${title}\n${message}\n${TABLE_MOCK}`;
const expected = `${title}\n${message}\n${TABLE_MOCK}\n${FOOTER}`;
const response = buildComment({ periodLength, table: TABLE_MOCK, org: ORG });
expect(response).toEqual(expected);
});
Expand All @@ -29,7 +31,7 @@ describe('Interactors | .buildComment', () => {
const message = `Stats of the last 365 days for ${linkOrg(ORG)}:`;

it('builds the message in singular', () => {
const expected = `${title}\n${message}\n${TABLE_MOCK}`;
const expected = `${title}\n${message}\n${TABLE_MOCK}\n${FOOTER}`;
const response = buildComment({ periodLength, table: TABLE_MOCK, org: ORG });
expect(response).toEqual(expected);
});
Expand All @@ -41,9 +43,26 @@ describe('Interactors | .buildComment', () => {
const message = `Stats of the last day for ${linkRepo(REPO1)} and ${linkRepo(REPO2)}:`;

it('builds the message in singular', () => {
const expected = `${title}\n${message}\n${TABLE_MOCK}`;
const expected = `${title}\n${message}\n${TABLE_MOCK}\n${FOOTER}`;
const response = buildComment({ periodLength, table: TABLE_MOCK, repos });
expect(response).toEqual(expected);
});
});

describe('when is a sponsor', () => {
const isSponsor = true;
const periodLength = 1;
const message = `Stats of the last day for ${linkOrg(ORG)}:`;

it('removes the footer', () => {
const expected = `${title}\n${message}\n${TABLE_MOCK}`;
const response = buildComment({
isSponsor,
periodLength,
org: ORG,
table: TABLE_MOCK,
});
expect(response).toEqual(expected);
});
});
});
4 changes: 3 additions & 1 deletion src/interactors/buildComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ module.exports = ({
table,
org,
repos,
isSponsor,
periodLength,
}) => {
const sources = buildSources({ buildGithubLink, org, repos });
const message = t('table.subtitle', { sources, count: periodLength });
return `## ${t('table.title')}\n${message}:\n${table}`;
const footer = isSponsor ? '' : `\n${t('table.footer')}`;
return `## ${t('table.title')}\n${message}:\n${table}${footer}`;
};
4 changes: 3 additions & 1 deletion src/services/telemetry/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ describe('Telemetry', () => {

describe('.success', () => {
const getTelemetry = () => new Telemetry({ core, telemetry: true });
const results = { result1: 'RESULT1', result2: 'RESULT2' };

it('calls .sendSuccess with the correct parameters', () => {
const telemetry = getTelemetry();
telemetry.success();
telemetry.success(results);
expect(sendSuccess).toHaveBeenCalledWith(expect.objectContaining({
timeMs: expect.any(Number),
tracker: TRACKER,
...results,
}));
});
});
Expand Down
Loading

0 comments on commit 5d06691

Please sign in to comment.