Skip to content

Commit

Permalink
techdebt: address upgrades & warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MorrisonCole committed Sep 11, 2020
1 parent f806961 commit 0e4d242
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
lib/
dist/
node_modules/
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
lib/
dist/
node_modules/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ COPY . .

RUN npm install --production

ENTRYPOINT ["node", "/lib/main.js"]
ENTRYPOINT ["node", "/dist/main.js"]
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
pr-lint:
runs-on: ubuntu-latest
steps:
- uses: morrisoncole/[email protected].2
- uses: morrisoncole/[email protected].3
with:
title-regex: "#EX-[0-9]+"
on-failed-regex-comment:
Expand All @@ -32,6 +32,14 @@ jobs:
## Changelog
### v1.2.3
Internal refactoring only:
- Upgrade dependencies
- Move from `lib` to `dist`
- Address ESLint warnings

### v1.2.2

- Fixes [#92](https://github.com/MorrisonCole/pr-lint-action/issues/92)
Expand All @@ -44,21 +52,21 @@ jobs:

Internal refactoring only:

- Update dependencies
- Upgrade dependencies
- Configure ESLint & Prettier

### v1.1.0

- Replaced status checks with an automatic bot review. If the PR title fails to
match the regex, the bot will request changes. Once the title is edited to
match it, the bot will dismiss its review.
- Updated all dependencies.
match it, the bot will dismiss its review
- Upgrade dependencies

### v1.0.0

- Initial release. This version uses action status checks but suffers from
[#5](https://github.com/MorrisonCole/pr-lint-action/issues/5) since the GitHub
actions API treats different hook types as separate checks by default.
actions API treats different hook types as separate checks by default

## FAQ

Expand All @@ -79,7 +87,7 @@ being.

`yarn build`

Building outputs to `lib/main.js`.
Building outputs to `dist/main.js`.

## Related Reading

Expand Down
6 changes: 3 additions & 3 deletions lib/main.js → dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ async function run() {
const onFailedRegexComment = core
.getInput("on-failed-regex-comment")
.replace("%regex%", titleRegex.source);
core.debug(`Title Regex: ${titleRegex}`);
core.debug(`Title Regex: ${titleRegex.source}`);
core.debug(`Title: ${title}`);
const titleMatchesRegex = titleRegex.test(title);
if (!titleMatchesRegex) {
githubClient.pulls.createReview({
void githubClient.pulls.createReview({
owner: pr.owner,
repo: pr.repo,
pull_number: pr.number,
Expand All @@ -52,7 +52,7 @@ async function run() {
});
reviews.data.forEach((review) => {
if (review.user.login == "github-actions[bot]") {
githubClient.pulls.dismissReview({
void githubClient.pulls.dismissReview({
owner: pr.owner,
repo: pr.repo,
pull_number: pr.number,
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pr-lint-action",
"version": "1.1.1",
"description": "A GitHub Action to ensure that your PR title matches a given regex.",
"main": "lib/main.js",
"main": "dist/main.js",
"scripts": {
"build": "tsc",
"lint:eslint": "eslint . --ext .ts",
Expand All @@ -26,10 +26,7 @@
"homepage": "https://github.com/MorrisonCole/pr-lint-action#readme",
"dependencies": {
"@actions/core": "1.2.5",
"@actions/exec": "1.0.4",
"@actions/github": "4.0.0",
"@actions/io": "1.0.2",
"@actions/tool-cache": "1.6.0"
"@actions/github": "4.0.0"
},
"devDependencies": {
"@types/node": "12.12.57",
Expand Down
10 changes: 5 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/camelcase */
import { getOctokit } from "@actions/github/lib/github";
import * as core from "@actions/core";
import * as github from "@actions/github";
Expand All @@ -11,18 +10,19 @@ async function run(): Promise<void> {
const pr = githubContext.issue;

const titleRegex = new RegExp(core.getInput("title-regex"));
const title: string = githubContext.payload.pull_request?.title ?? "";
const title: string =
(githubContext.payload.pull_request?.title as string) ?? "";

const onFailedRegexComment = core
.getInput("on-failed-regex-comment")
.replace("%regex%", titleRegex.source);

core.debug(`Title Regex: ${titleRegex}`);
core.debug(`Title Regex: ${titleRegex.source}`);
core.debug(`Title: ${title}`);

const titleMatchesRegex: boolean = titleRegex.test(title);
if (!titleMatchesRegex) {
githubClient.pulls.createReview({
void githubClient.pulls.createReview({
owner: pr.owner,
repo: pr.repo,
pull_number: pr.number,
Expand All @@ -38,7 +38,7 @@ async function run(): Promise<void> {

reviews.data.forEach((review) => {
if (review.user.login == "github-actions[bot]") {
githubClient.pulls.dismissReview({
void githubClient.pulls.dismissReview({
owner: pr.owner,
repo: pr.repo,
pull_number: pr.number,
Expand Down
12 changes: 4 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@
"compilerOptions": {
"allowJs": false,
"esModuleInterop": true,
"lib": [
"ES2020"
],
"lib": ["ES2020"],
"module": "CommonJS",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./lib",
"outDir": "dist",
"removeComments": true,
"rootDir": "./src",
"strict": true,
"target": "ES2020"
},
"exclude": [
"node_modules"
]
}
"exclude": ["node_modules"]
}
39 changes: 0 additions & 39 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.5.tgz#fa57bf8c07a38191e243beb9ea9d8368c1cb02c8"
integrity sha512-mwpoNjHSWWh0IiALdDEQi3tru124JKn0yVNziIBzTME8QRv7thwoghVuT1jBRjFvdtoHsqD58IRHy1nf86paRg==

"@actions/core@^1.2.3":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.4.tgz#96179dbf9f8d951dd74b40a0dbd5c22555d186ab"
integrity sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg==

"@actions/[email protected]", "@actions/exec@^1.0.0":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.0.4.tgz#99d75310e62e59fc37d2ee6dcff6d4bffadd3a5d"
integrity sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==
dependencies:
"@actions/io" "^1.0.1"

"@actions/[email protected]":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@actions/github/-/github-4.0.0.tgz#d520483151a2bf5d2dc9cd0f20f9ac3a2e458816"
Expand All @@ -36,23 +24,6 @@
dependencies:
tunnel "0.0.6"

"@actions/[email protected]", "@actions/io@^1.0.1":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.0.2.tgz#2f614b6e69ce14d191180451eb38e6576a6e6b27"
integrity sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg==

"@actions/[email protected]":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@actions/tool-cache/-/tool-cache-1.6.0.tgz#5b425db2d642df65dd0d6bcec0d84dcdbca3f80d"
integrity sha512-+fyEBImPD3m5I0o6DflCO0NHY180LPoX8Lo6y4Iez+V17kO8kfkH0VHxb8mUdmD6hn9dWA9Ch1JA20fXoIYUeQ==
dependencies:
"@actions/core" "^1.2.3"
"@actions/exec" "^1.0.0"
"@actions/http-client" "^1.0.8"
"@actions/io" "^1.0.1"
semver "^6.1.0"
uuid "^3.3.2"

"@babel/code-frame@^7.0.0":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e"
Expand Down Expand Up @@ -1119,11 +1090,6 @@ semver@^5.5.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==

semver@^6.1.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.2.1, semver@^7.3.2:
version "7.3.2"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938"
Expand Down Expand Up @@ -1299,11 +1265,6 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

uuid@^3.3.2:
version "3.4.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

v8-compile-cache@^2.0.3:
version "2.1.0"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e"
Expand Down

0 comments on commit 0e4d242

Please sign in to comment.