From a740a75c99230a775b69ddaeea6c11a7d63d1b46 Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Wed, 31 Jul 2024 18:55:16 -0700 Subject: [PATCH 01/10] build: include a source map in the packaged dist --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef5efff..182b9e0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "dist/index.js", "scripts": { "lint": "eslint .", - "build": "ncc build src/index.js -o dist --license licenses.txt", + "build": "ncc build src/index.js -o dist --license licenses.txt --source-map", "local": "act public --eventpath .github/workflows/local/event.json --secret-file .github/workflows/local/.env --platform ubuntu-latest=node:20-buster", "test:mocha": "mocha --config .mocharc.json test/*-test.js test/**/*-test.js", "test": "npm run lint && c8 npm run test:mocha" From 63d06689180eb5e3a022b21c484caae642b672eb Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Mon, 30 Sep 2024 14:12:22 -0700 Subject: [PATCH 02/10] fix: update return type for compile to await a promise --- src/health-score.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/health-score.js b/src/health-score.js index b5ac96c..b71ca1f 100644 --- a/src/health-score.js +++ b/src/health-score.js @@ -8,7 +8,7 @@ module.exports = { * @description Compiles the health score components * @param {import('@actions/core')} core `@actions/core` GitHub Actions core helper utility * @param {import('@actions/github')} github `@actions/github` GitHub Actions core helper utility - * @returns {import('./types').HealthScore} score Health score details object + * @returns {Promise} score Health score details object */ compile: async function compileScore(core, github) { // TODO: wire up action outputs From 0df838769695e8ab1ef9f7f3527c0252e1cbd035 Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Mon, 30 Sep 2024 14:12:54 -0700 Subject: [PATCH 03/10] feat: catch errors to set the action as failed on broken compilation --- src/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 76ac1b7..43d3a99 100644 --- a/src/index.js +++ b/src/index.js @@ -5,4 +5,8 @@ const hs = require('./health-score'); const startTime = new Date(); hs.compile(core, github) .then((score) => hs.report(startTime, core, github, score)) - .then(console.log); + .then(console.log) + .catch((err) => { + core.setFailed('Failed to check up on the health score'); + console.error(err); + }); From e0a89563dca56ba77d6e05717f99d65dcfadcfca Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Mon, 30 Sep 2024 14:19:08 -0700 Subject: [PATCH 04/10] temp: break the compilation step as a proof of concept --- src/health-score.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/health-score.js b/src/health-score.js index b71ca1f..208c14a 100644 --- a/src/health-score.js +++ b/src/health-score.js @@ -12,7 +12,7 @@ module.exports = { */ compile: async function compileScore(core, github) { // TODO: wire up action outputs - const extensionInput = core.getInput('extension'); + const extensionInput = core.getInpu('extension'); const includeInput = core.getInput('include'); const excludeInput = core.getInput('exclude'); From 282e9a1ba422c98a2d319ac01935f301e2921e27 Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Mon, 30 Sep 2024 14:22:07 -0700 Subject: [PATCH 05/10] temp(ci): remove unit testing of a broken build --- .github/workflows/main.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 352e677..e0bc885 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,13 +15,6 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - run: npm install - run: npm run build - - run: npm test - - name: Upload coverage to CodeCov - uses: codecov/codecov-action@v4.5.0 - with: - directory: ./coverage - token: ${{ secrets.CODECOV_TOKEN }} - slug: slackapi/slack-health-score health-score: needs: unit_tests From f0a02377f214c7375d4e5b572d64e8ce8744b172 Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Mon, 30 Sep 2024 14:23:43 -0700 Subject: [PATCH 06/10] ci: dispatch a testing workflow using a workflow dispatch input --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0bc885..b045211 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,7 @@ on: push: branches: - main + workflow_dispatch: jobs: unit_tests: From 6f7930a3739d9b90a1b7e5ee410ac9f31968095a Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Mon, 30 Sep 2024 14:25:32 -0700 Subject: [PATCH 07/10] revert: undo attempts at changing the workflow file of staging in a pr --- .github/workflows/main.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b045211..352e677 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,6 @@ on: push: branches: - main - workflow_dispatch: jobs: unit_tests: @@ -16,6 +15,13 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - run: npm install - run: npm run build + - run: npm test + - name: Upload coverage to CodeCov + uses: codecov/codecov-action@v4.5.0 + with: + directory: ./coverage + token: ${{ secrets.CODECOV_TOKEN }} + slug: slackapi/slack-health-score health-score: needs: unit_tests From 9b8e3ff707b3cf74908fe2fe5e123599b8c81dc9 Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Mon, 30 Sep 2024 14:28:28 -0700 Subject: [PATCH 08/10] temp: test that true is true using an assertion --- package.json | 2 +- test/temp.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/temp.js diff --git a/package.json b/package.json index d7e3867..5d688bb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "lint": "eslint .", "build": "ncc build src/index.js -o dist --license licenses.txt --source-map", "local": "act public --eventpath .github/workflows/local/event.json --secret-file .github/workflows/local/.env --platform ubuntu-latest=node:20-buster", - "test:mocha": "mocha --config .mocharc.json test/*-test.js test/**/*-test.js", + "test:mocha": "mocha --config .mocharc.json test/temp.js", "test": "npm run lint && c8 npm run test:mocha" }, "repository": { diff --git a/test/temp.js b/test/temp.js new file mode 100644 index 0000000..a050520 --- /dev/null +++ b/test/temp.js @@ -0,0 +1,7 @@ +const { assert } = require('chai'); + +describe('tests', () => { + it('asserts', async () => { + assert.isTrue(true); + }); +}); From 367522a19631842d07c58f90af13ce7eb280443f Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Mon, 30 Sep 2024 14:30:48 -0700 Subject: [PATCH 09/10] style: add surprise to the error message shown on action summary --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 43d3a99..ebdb806 100644 --- a/src/index.js +++ b/src/index.js @@ -7,6 +7,6 @@ hs.compile(core, github) .then((score) => hs.report(startTime, core, github, score)) .then(console.log) .catch((err) => { - core.setFailed('Failed to check up on the health score'); + core.setFailed('Failed to check up on the health score!'); console.error(err); }); From e8867ba0d1e2f29b39276c596d1a75cc7ea009ec Mon Sep 17 00:00:00 2001 From: "@zimeg" Date: Mon, 30 Sep 2024 14:41:54 -0700 Subject: [PATCH 10/10] revert: remove temp testing breakages before requesting review --- package.json | 2 +- src/health-score.js | 2 +- test/temp.js | 7 ------- 3 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 test/temp.js diff --git a/package.json b/package.json index 5d688bb..d7e3867 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "lint": "eslint .", "build": "ncc build src/index.js -o dist --license licenses.txt --source-map", "local": "act public --eventpath .github/workflows/local/event.json --secret-file .github/workflows/local/.env --platform ubuntu-latest=node:20-buster", - "test:mocha": "mocha --config .mocharc.json test/temp.js", + "test:mocha": "mocha --config .mocharc.json test/*-test.js test/**/*-test.js", "test": "npm run lint && c8 npm run test:mocha" }, "repository": { diff --git a/src/health-score.js b/src/health-score.js index 208c14a..b71ca1f 100644 --- a/src/health-score.js +++ b/src/health-score.js @@ -12,7 +12,7 @@ module.exports = { */ compile: async function compileScore(core, github) { // TODO: wire up action outputs - const extensionInput = core.getInpu('extension'); + const extensionInput = core.getInput('extension'); const includeInput = core.getInput('include'); const excludeInput = core.getInput('exclude'); diff --git a/test/temp.js b/test/temp.js deleted file mode 100644 index a050520..0000000 --- a/test/temp.js +++ /dev/null @@ -1,7 +0,0 @@ -const { assert } = require('chai'); - -describe('tests', () => { - it('asserts', async () => { - assert.isTrue(true); - }); -});