Skip to content

Commit fd5d074

Browse files
zimegClaude
andcommitted
build(deps): bump @actions/core to 3.0.0 and @actions/github to 9.0.0
This PR resolves #143 and #144 by updating the dependencies to their ESM-only versions. Changes include: - Add "type": "module" to package.json for ESM support - Convert all source files from CommonJS to ESM imports/exports - Convert all test files to use node:test instead of mocha/sinon/chai - Remove unused mocha, sinon, and chai devDependencies - Remove obsolete .mocharc.json and test/.eslintrc.js configs The @actions/core and @actions/github packages are now ESM-only as of versions 3.0.0 and 9.0.0 respectively. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent af32f47 commit fd5d074

File tree

17 files changed

+1528
-1711
lines changed

17 files changed

+1528
-1711
lines changed

.mocharc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

package-lock.json

Lines changed: 1164 additions & 1153 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
"name": "slack-health-score",
33
"version": "0.1.1",
44
"description": "A rough health score reporter",
5+
"type": "module",
56
"main": "dist/index.js",
67
"scripts": {
78
"build": "ncc build src/index.js -o dist --license licenses.txt --source-map",
89
"lint": "biome check .",
910
"lint:fix": "biome check --write .",
1011
"local": "act public --eventpath .github/workflows/local/event.json --secret-file .github/workflows/local/.env --platform ubuntu-latest=node:20-buster",
11-
"test": "npm run lint && c8 npm run test:mocha",
12-
"test:mocha": "mocha --config .mocharc.json test/*-test.js test/**/*-test.js"
12+
"test": "npm run lint && c8 npm run test:node",
13+
"test:node": "node --test test/*-test.js test/**/*-test.js"
1314
},
1415
"repository": {
1516
"type": "git",
@@ -33,16 +34,13 @@
3334
},
3435
"homepage": "https://github.com/slackapi/slack-health-score#readme",
3536
"dependencies": {
36-
"@actions/core": "^2.0.1",
37-
"@actions/github": "^6.0.1",
37+
"@actions/core": "^3.0.0",
38+
"@actions/github": "^9.0.0",
3839
"@api/codecov": "file:.api/apis/codecov"
3940
},
4041
"devDependencies": {
4142
"@biomejs/biome": "2.3.13",
4243
"@vercel/ncc": "^0.38.4",
43-
"c8": "^10.1.3",
44-
"chai": "^6.2.2",
45-
"mocha": "^11.7.5",
46-
"sinon": "^21.0.1"
44+
"c8": "^10.1.3"
4745
}
4846
}

src/get-sha.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @param {import('@actions/github')} github `@actions/github` GitHub Actions core helper utility
44
* @returns {string} SHA of the commit being inspected, regardless of underlying GitHub event
55
*/
6-
module.exports = function getCommitSHA(core, github) {
6+
export default function getCommitSHA(core, github) {
77
// Get GitHub-event-relevant contextual details, like commit SHA
88
const ctx = github.context;
99
core.debug(
@@ -29,4 +29,4 @@ module.exports = function getCommitSHA(core, github) {
2929
}
3030
core.info(`Using SHA: ${sha}`);
3131
return sha;
32-
};
32+
}

src/health-score.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const findProblematicComments = require('./score_components/find-problematic-comments');
2-
const retrieveCodeCoverage = require('./score_components/coverage');
3-
const reportStatus = require('./report');
4-
const { parseYamlArray } = require('./helpers/helper-functions');
1+
import { parseYamlArray } from './helpers/helper-functions.js';
2+
import reportStatus from './report.js';
3+
import retrieveCodeCoverage from './score_components/coverage.js';
4+
import findProblematicComments from './score_components/find-problematic-comments.js';
55

6-
module.exports = {
6+
const hs = {
77
/**
88
* @description Compiles the health score components
99
* @param {import('@actions/core')} core `@actions/core` GitHub Actions core helper utility
1010
* @param {import('@actions/github')} github `@actions/github` GitHub Actions core helper utility
11-
* @returns {Promise<import('./types').HealthScore>} score Health score details object
11+
* @returns {Promise<import('./types.js').HealthScore>} score Health score details object
1212
*/
1313
compile: async function compileScore(core, github) {
1414
// TODO: wire up action outputs
@@ -21,13 +21,13 @@ module.exports = {
2121
const excludes = parseYamlArray(excludeInput);
2222

2323
let com = '';
24-
const misses = await module.exports.coverage(core, github); // uncovered LoC
24+
const misses = await hs.coverage(core, github); // uncovered LoC
2525
if (extensions.length === 0) {
2626
core.error('Extensions not specified');
2727
} else {
2828
if (includes.length === 0)
2929
core.warning('Directories to be included not specified');
30-
com = module.exports.grep(core, extensions, includes, excludes); // to-do et al comments
30+
com = hs.grep(core, extensions, includes, excludes); // to-do et al comments
3131
}
3232
return {
3333
comments: com,
@@ -38,3 +38,5 @@ module.exports = {
3838
coverage: retrieveCodeCoverage,
3939
report: reportStatus,
4040
};
41+
42+
export default hs;

src/helpers/helper-functions.js

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
1-
module.exports = {
2-
/**
3-
*
4-
* @param input
5-
* @returns []
6-
*/
7-
parseYamlArray(input) {
8-
if (!input) {
9-
return [];
10-
}
11-
const arr = input.trim().replace(/\[|\]/g, '');
1+
/**
2+
*
3+
* @param input
4+
* @returns []
5+
*/
6+
export function parseYamlArray(input) {
7+
if (!input) {
8+
return [];
9+
}
10+
const arr = input.trim().replace(/\[|\]/g, '');
1211

13-
return arr
14-
.split(/,\s*|\n/)
15-
.map((item) => item.trim().replace(/^- */, ''))
16-
.filter(Boolean)
17-
.map((item) => {
18-
if (
19-
(item.startsWith('"') && item.endsWith('"')) ||
20-
(item.startsWith("'") && item.endsWith("'"))
21-
) {
22-
return item.slice(1, -1);
23-
}
24-
return item;
25-
});
26-
},
27-
/**
28-
*
29-
* @param comments
30-
* @returns []
31-
*/
32-
getAnnotations(comments) {
33-
return comments.map((c) => ({
34-
path: c.path,
35-
start_line: c.line_no ? c.line_no : 1,
36-
end_line: c.line_no ? c.line_no : 1,
37-
annotation_level: 'warning',
38-
message: c.commentType
39-
? `Problematic comment ("${c.commentType}") identified`
40-
: 'Problematic comment ("TODO", "HACK", "FIXME") identified',
41-
}));
42-
},
43-
};
12+
return arr
13+
.split(/,\s*|\n/)
14+
.map((item) => item.trim().replace(/^- */, ''))
15+
.filter(Boolean)
16+
.map((item) => {
17+
if (
18+
(item.startsWith('"') && item.endsWith('"')) ||
19+
(item.startsWith("'") && item.endsWith("'"))
20+
) {
21+
return item.slice(1, -1);
22+
}
23+
return item;
24+
});
25+
}
26+
27+
/**
28+
*
29+
* @param comments
30+
* @returns []
31+
*/
32+
export function getAnnotations(comments) {
33+
return comments.map((c) => ({
34+
path: c.path,
35+
start_line: c.line_no ? c.line_no : 1,
36+
end_line: c.line_no ? c.line_no : 1,
37+
annotation_level: 'warning',
38+
message: c.commentType
39+
? `Problematic comment ("${c.commentType}") identified`
40+
: 'Problematic comment ("TODO", "HACK", "FIXME") identified',
41+
}));
42+
}

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const core = require('@actions/core');
2-
const github = require('@actions/github');
3-
const hs = require('./health-score');
1+
import * as core from '@actions/core';
2+
import * as github from '@actions/github';
3+
import hs from './health-score.js';
44

55
const startTime = new Date();
66
hs.compile(core, github)

src/report.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const getSHA = require('./get-sha');
2-
const { getAnnotations } = require('./helpers/helper-functions');
1+
import getSHA from './get-sha.js';
2+
import { getAnnotations } from './helpers/helper-functions.js';
33

44
const UNCOVERED_LINE_PENALTY = 1;
55
const PROBLEMATIC_COMMENT_PENALTY = 100;
@@ -8,10 +8,10 @@ const PROBLEMATIC_COMMENT_PENALTY = 100;
88
* @param {Date} startTime the JavaScript Date of the start of this action's run
99
* @param {import('@actions/core')} core `@actions/core` GitHub Actions core helper utility
1010
* @param {import('@actions/github')} github `@actions/github` GitHub Actions core helper utility
11-
* @param {import('./types').HealthScore} score The health score to be reported
11+
* @param {import('./types.js').HealthScore} score The health score to be reported
1212
* @returns {Promise<number>} Total calculated health score
1313
*/
14-
module.exports = async function reportStatus(startTime, core, github, score) {
14+
export default async function reportStatus(startTime, core, github, score) {
1515
const gh = core.getInput('github_token');
1616
if (!gh) {
1717
core.warning(
@@ -69,4 +69,4 @@ According to [the code coverage for this project](https://app.codecov.io/gh/${ct
6969
core.error('Octokit checks creation call failed');
7070
}
7171
return points;
72-
};
72+
}

src/score_components/coverage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const codecov = require('@api/codecov');
2-
const getSHA = require('../get-sha');
1+
import codecov from '@api/codecov';
2+
import getSHA from '../get-sha.js';
33

44
/**
55
* @description Compiles the health score components
66
* @param {import('@actions/core')} core `@actions/core` GitHub Actions core helper utility
77
* @param {import('@actions/github')} github `@actions/github` GitHub Actions core helper utility
88
* @returns {Promise<number>} Number of uncovered lines of code, or 0 in the case of no codecov token specified
99
*/
10-
module.exports = async function retrieveCodeCoverage(core, github) {
10+
export default async function retrieveCodeCoverage(core, github) {
1111
// See if we can get a coverage overview for this commit from codecov
1212
const codecovToken = core.getInput('codecov_token');
1313
const maxAttempts =
@@ -74,7 +74,7 @@ module.exports = async function retrieveCodeCoverage(core, github) {
7474
core.info('No codecov token provided, skipping coverage retrieval.');
7575
}
7676
return misses;
77-
};
77+
}
7878

7979
function sleep(ms) {
8080
return new Promise((res) => {

src/score_components/find-problematic-comments.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const fs = require('node:fs');
2-
const child_process = require('node:child_process');
1+
import child_process from 'node:child_process';
2+
import fs from 'node:fs';
33

44
const CommentType = Object.freeze({
55
TODO: 'TODO',
66
FIXME: 'FIXME',
77
HACK: 'HACK',
88
});
99

10-
module.exports = function grepForProblematicComments(
10+
export default function grepForProblematicComments(
1111
core,
1212
ext,
1313
include,
@@ -77,7 +77,7 @@ module.exports = function grepForProblematicComments(
7777
};
7878
});
7979
return result;
80-
};
80+
}
8181

8282
/**
8383
* Get the comment type.

0 commit comments

Comments
 (0)