From 0c5f57c31b70eaa6c653b03c8034a795ad7835b5 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Tue, 12 Dec 2023 12:55:15 +0100 Subject: [PATCH] Validate PR changes to make sure there are no changes missing (#165) * Create pr-check.yml * Use correct npm commands * Adress issues from linting * CI step to fill the node_modules needed for the compile * Fix check * Add message when things are good --- .github/workflows/pr-check.yml | 36 ++++++++++++++++++++++++++++++++++ dist/index.js | 2 +- src/index.ts | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pr-check.yml diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml new file mode 100644 index 0000000..c470d01 --- /dev/null +++ b/.github/workflows/pr-check.yml @@ -0,0 +1,36 @@ +# check incoming pr's and make sure that +# - the code builds +# - the dist folder does not need updating +name: PR Check + +on: + push: + + pull_request: + +jobs: + build-and-check-dist: + name: Run build and check dist folder + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + with: + node-version: '20' + + - name: Compile with NPM + run: | + npm ci + npm run compile + npm run package + + - name: Check if there are changes that where not in the commit + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Found changes to commit after building. Here is the output from `git status`:" + git status + + exit 1 + else + echo "No changes found after compiling. PR is good for a review." + fi diff --git a/dist/index.js b/dist/index.js index 81ce109..e40ebbb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -35066,7 +35066,7 @@ async function getPrFilesWithBlobSize(pullRequestNumber) { : data; const prFilesWithBlobSize = await Promise.all(files // Cannot get blobs for files without sha (e.g. happens when only changing a permission bit on the file) or without blob_url (e.g. submodules) - .filter(file => file.sha != null && file.blob_url != null) + .filter(file => file.sha !== null && file.blob_url !== null) .map(async (file) => { const { filename, sha, patch } = file; const { data: blob } = await octokit.rest.git.getBlob({ diff --git a/src/index.ts b/src/index.ts index e39418b..f0b2a00 100644 --- a/src/index.ts +++ b/src/index.ts @@ -200,7 +200,7 @@ async function getPrFilesWithBlobSize(pullRequestNumber: number) { const prFilesWithBlobSize = await Promise.all( files // Cannot get blobs for files without sha (e.g. happens when only changing a permission bit on the file) or without blob_url (e.g. submodules) - .filter(file => file.sha != null && file.blob_url != null) + .filter(file => file.sha !== null && file.blob_url !== null) .map(async file => { const {filename, sha, patch} = file; const {data: blob} = await octokit.rest.git.getBlob({