Skip to content

Commit

Permalink
ci(workflows): log on changelog/tests needed (aws#5506)
Browse files Browse the repository at this point in the history
## Problem
we can't run the change/test action from a fork :(

## Solution
Just log the information instead

---

<!--- REMINDER: Ensure that your PR meets the guidelines in
CONTRIBUTING.md -->

License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
  • Loading branch information
jpinkney-aws authored Aug 27, 2024
1 parent 24c55fe commit 648c809
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

const { parsePRTitle, hasPath, dedupComment } = require('./utils')
const { parsePRTitle, hasPath } = require('./utils')

const testFilesMessage =
'This pull request modifies files in src/ but no tests were added/updated. Confirm whether tests should be added or ensure the PR description explains why tests are not required.'
Expand All @@ -21,7 +21,6 @@ module.exports = async ({ github, context }) => {
const owner = context.repo.owner
const repo = context.repo.repo
const author = context.payload.pull_request.head.repo.owner.login
const pullRequestId = context.payload.pull_request.number

const response = await github.rest.repos.compareCommitsWithBasehead({
owner,
Expand All @@ -38,19 +37,13 @@ module.exports = async ({ github, context }) => {
return
}

// Check for prior comments on the PR
const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number: pullRequestId,
})

if (shouldAddTestFileMessage) {
await dedupComment({ github, comments, owner, repo, pullRequestId, message: testFilesMessage })
// We can't really block on this one, since its valid to make a change in src/ without adding tests :( console.error(testFilesMessage)
}

if (shouldAddChangelogMessage) {
await dedupComment({ github, comments, owner, repo, pullRequestId, message: changelogMessage })
console.error(changelogMessage)
process.exit(1)
}
}

Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@ function parsePRTitle(title) {
}
}

/**
* Create a comment on a PR if one does not already exist
*/
async function dedupComment({ github, pullRequestId, owner, repo, comments, message }) {
if (comments.data.some((comment) => comment.body.includes(message))) {
return
}

await github.rest.issues.createComment({
issue_number: pullRequestId,
owner,
repo,
body: message,
})
}

/*
* Check if path is included in at least one of the filename paths
*/
Expand All @@ -50,6 +34,5 @@ function hasPath(filenames, path) {

module.exports = {
parsePRTitle,
dedupComment,
hasPath,
}

0 comments on commit 648c809

Please sign in to comment.