Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1d10912

Browse files
authored
ci: fix stale closer action review sort bug (anuraghazra#2201)
This commit makes sure the PR staleness is checked by the latest review thatis done.
1 parentbb56e3b commit1d10912

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

‎scripts/close-stale-theme-prs.js‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,28 @@ import github from "@actions/github";
99
import{RequestError}from"@octokit/request-error";
1010
import{getGithubToken,getRepoInfo}from"./helpers.js";
1111

12-
// Script parameters
1312
constCLOSING_COMMENT=`
1413
\rThis PR has been automatically closed due to inactivity. Please feel free to reopen it if you need to continue working on it.\
1514
\rThank you for your contributions.
1615
`;
16+
constREVIEWER="github-actions[bot]";
17+
18+
/**
19+
* Retrieve the review user.
20+
*@returns {string} review user.
21+
*/
22+
constgetReviewer=()=>{
23+
returnprocess.env.REVIEWER ?process.env.REVIEWER :REVIEWER;
24+
};
1725

1826
/**
1927
* Fetch open PRs from a given repository.
2028
*@param user The user name of the repository owner.
2129
*@param repo The name of the repository.
30+
*@param reviewer The reviewer to filter by.
2231
*@returns The open PRs.
2332
*/
24-
exportconstfetchOpenPRs=async(octokit,user,repo)=>{
33+
exportconstfetchOpenPRs=async(octokit,user,repo,reviewer)=>{
2534
constopenPRs=[];
2635
lethasNextPage=true;
2736
letendCursor;
@@ -49,9 +58,9 @@ export const fetchOpenPRs = async (octokit, user, repo) => {
4958
name
5059
}
5160
}
52-
reviews(first:1, states: CHANGES_REQUESTED, author: "github-actions[bot]") {
61+
reviews(first:100, states: CHANGES_REQUESTED, author: "${reviewer}") {
5362
nodes {
54-
updatedAt
63+
submittedAt
5564
}
5665
}
5766
}
@@ -99,11 +108,13 @@ const isStale = (pullRequest, staleDays) => {
99108
pullRequest.commits.nodes[0].commit.pushedDate,
100109
);
101110
if(pullRequest.reviews.nodes[0]){
102-
constlastReviewDate=newDate(pullRequest.reviews.nodes[0].updatedAt);
111+
constlastReviewDate=newDate(
112+
pullRequest.reviews.nodes.sort((a,b)=>(a<b ?1 :-1))[0].submittedAt,
113+
);
103114
constlastUpdateDate=
104115
lastCommitDate>=lastReviewDate ?lastCommitDate :lastReviewDate;
105116
constnow=newDate();
106-
returnnow-lastUpdateDate>1000*60*60*24*staleDays;
117+
return(now-lastUpdateDate)/(1000*60*60*24)>=staleDays;
107118
}else{
108119
returnfalse;
109120
}
@@ -120,10 +131,11 @@ const run = async () => {
120131
debug("Creating octokit client...");
121132
constoctokit=github.getOctokit(getGithubToken());
122133
const{ owner, repo}=getRepoInfo(github.context);
134+
constreviewer=getReviewer();
123135

124136
// Retrieve all theme pull requests.
125137
debug("Retrieving all theme pull requests...");
126-
constprs=awaitfetchOpenPRs(octokit,owner,repo);
138+
constprs=awaitfetchOpenPRs(octokit,owner,repo,reviewer);
127139
constthemePRs=pullsWithLabel(prs,"themes");
128140
constinvalidThemePRs=pullsWithLabel(themePRs,"invalid");
129141
debug("Retrieving stale theme PRs...");

‎scripts/helpers.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import{getInput}from"@actions/core";
66

7-
// Script variables.
87
constOWNER="anuraghazra";
98
constREPO="github-readme-stats";
109

‎scripts/preview-theme.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { isValidHexColor } from "../src/common/utils.js";
1616
import{themes}from"../themes/index.js";
1717
import{getGithubToken,getRepoInfo}from"./helpers.js";
1818

19-
// Script variables.
2019
constCOMMENTER="github-actions[bot]";
2120

2221
constCOMMENT_TITLE="Automated Theme Preview";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp