Skip to content

Commit 951edf9

Browse files
authored
build: update @actions dependencies to versions with esm support (#547)
1 parent 3345d5a commit 951edf9

12 files changed

Lines changed: 178 additions & 210 deletions

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
},
3535
"homepage": "https://docs.slack.dev/tools/slack-github-action/",
3636
"dependencies": {
37-
"@actions/core": "^2.0.1",
38-
"@actions/github": "^7.0.0",
37+
"@actions/core": "^3.0.0",
38+
"@actions/github": "^9.0.0",
3939
"@slack/logger": "^4.0.0",
4040
"@slack/web-api": "^7.13.0",
4141
"axios": "^1.13.4",

src/config.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import core from "@actions/core";
21
import webapi from "@slack/web-api";
32
import axios from "axios";
43
import Content from "./content.js";
@@ -94,7 +93,7 @@ export default class Config {
9493
* kept for later use.
9594
*
9695
* @constructor
97-
* @param {core} core - GitHub Actions core utilities.
96+
* @param {import("@actions/core")} core - GitHub Actions core utilities.
9897
*/
9998
constructor(core) {
10099
this.axios = axios;
@@ -132,18 +131,18 @@ export default class Config {
132131
*/
133132
mask() {
134133
if (this.inputs.token) {
135-
core.debug("Setting the provided token as a secret variable.");
136-
core.setSecret(this.inputs.token);
134+
this.core.debug("Setting the provided token as a secret variable.");
135+
this.core.setSecret(this.inputs.token);
137136
}
138137
if (this.inputs.webhook) {
139-
core.debug("Setting the provided webhook as a secret variable.");
140-
core.setSecret(this.inputs.webhook);
138+
this.core.debug("Setting the provided webhook as a secret variable.");
139+
this.core.setSecret(this.inputs.webhook);
141140
}
142141
}
143142

144143
/**
145144
* Confirm the configurations are correct enough to continue.
146-
* @param {core} core - GitHub Actions core utilities.
145+
* @param {import("@actions/core")} core - GitHub Actions core utilities.
147146
*/
148147
validate(core) {
149148
switch (this.inputs.retries.trim().toUpperCase()) {

src/content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "node:fs";
22
import path from "node:path";
3-
import github from "@actions/github";
3+
import * as github from "@actions/github";
44
import { flatten } from "flat";
55
import yaml from "js-yaml";
66
import markup from "markup-js";

src/errors.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import core from "@actions/core";
2-
31
/**
42
* @typedef Cause
53
* @property {Error[]} [values] - Caught exceptions.
@@ -15,7 +13,7 @@ export default class SlackError extends Error {
1513
*/
1614

1715
/**
18-
* @param {core} _core - GitHub Actions core utilities.
16+
* @param {import("@actions/core")} _core - GitHub Actions core utilities.
1917
* @param {any} error - The error message to throw.
2018
* @param {Options} options - configurations of erroring.
2119
*/

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import core from "@actions/core";
1+
import * as core from "@actions/core";
22
import send from "./send.js";
33

44
/**

src/send.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import core from "@actions/core";
21
import Client from "./client.js";
32
import Config from "./config.js";
43
import SlackError from "./errors.js";
54
import Webhook from "./webhook.js";
65

76
/**
87
* Orchestrate the action job happenings from inputs to logic to outputs.
9-
* @param {core} core - GitHub Actions core utilities.
8+
* @param {import("@actions/core")} core - GitHub Actions core utilities.
109
* @throws if an error happens but might not cause the job to fail.
1110
*/
1211
export default async function send(core) {

test/client.spec.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import assert from "node:assert";
22
import { beforeEach, describe, it } from "node:test";
3-
import core from "@actions/core";
43
import webapi from "@slack/web-api";
54
import errors from "@slack/web-api/dist/errors.js";
65
import sinon from "sinon";
@@ -22,7 +21,7 @@ describe("client", () => {
2221
* @type {Config}
2322
*/
2423
const config = {
25-
core: core,
24+
core: mocks.core,
2625
inputs: {
2726
token: "xoxb-example",
2827
},
@@ -44,7 +43,7 @@ describe("client", () => {
4443
* @type {Config}
4544
*/
4645
const config = {
47-
core: core,
46+
core: mocks.core,
4847
inputs: {
4948
method: "chat.postMessage",
5049
},
@@ -79,8 +78,8 @@ describe("client", () => {
7978
timestamp: "1234567890.000000",
8079
},
8180
},
82-
core: core,
83-
logger: new Logger(core).logger,
81+
core: mocks.core,
82+
logger: new Logger(mocks.core).logger,
8483
inputs: {
8584
method: "pins.add",
8685
token: "xoxb-example-002",
@@ -124,8 +123,8 @@ describe("client", () => {
124123
stream: false,
125124
},
126125
},
127-
core: core,
128-
logger: new Logger(core).logger,
126+
core: mocks.core,
127+
logger: new Logger(mocks.core).logger,
129128
inputs: {
130129
api: "http://localhost:11434/api/",
131130
method: "generate",

test/content.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import assert from "node:assert";
22
import path from "node:path";
33
import { beforeEach, describe, it } from "node:test";
4-
import core from "@actions/core";
54
import { YAMLException } from "js-yaml";
65
import Config from "../src/config.js";
76
import Content from "../src/content.js";
@@ -270,7 +269,7 @@ describe("content", () => {
270269
* @type {Config}
271270
*/
272271
const config = {
273-
core: core,
272+
core: mocks.core,
274273
inputs: {
275274
payloadFilePath: "unknown.json",
276275
},
@@ -534,7 +533,7 @@ describe("content", () => {
534533
* @type {Config}
535534
*/
536535
const config = {
537-
core: core,
536+
core: mocks.core,
538537
inputs: {
539538
payload: "LGTM",
540539
},

test/index.spec.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import fs from "node:fs";
2-
import core from "@actions/core";
32
import webapi from "@slack/web-api";
43
import axios, { AxiosError } from "axios";
54
import sinon from "sinon";
@@ -45,7 +44,18 @@ export class Mock {
4544
this.sandbox = sinon.createSandbox();
4645
this.axios = this.sandbox.stub(axios);
4746
this.calls = this.sandbox.stub(webapi.WebClient.prototype, "apiCall");
48-
this.core = this.sandbox.stub(core);
47+
this.core = {
48+
debug: this.sandbox.stub(),
49+
error: this.sandbox.stub(),
50+
getInput: this.sandbox.stub(),
51+
getBooleanInput: this.sandbox.stub(),
52+
info: this.sandbox.stub(),
53+
isDebug: this.sandbox.stub(),
54+
setFailed: this.sandbox.stub(),
55+
setOutput: this.sandbox.stub(),
56+
setSecret: this.sandbox.stub(),
57+
warning: this.sandbox.stub(),
58+
};
4959
this.fs = this.sandbox.stub(fs);
5060
this.webapi = {
5161
WebClient: function () {
@@ -65,7 +75,16 @@ export class Mock {
6575
this.sandbox.reset();
6676
this.axios.post.resetHistory();
6777
this.calls.resetHistory();
78+
this.core.debug.reset();
79+
this.core.error.reset();
6880
this.core.getInput.reset();
81+
this.core.getBooleanInput.reset();
82+
this.core.info.reset();
83+
this.core.isDebug.reset();
84+
this.core.setFailed.reset();
85+
this.core.setOutput.reset();
86+
this.core.setSecret.reset();
87+
this.core.warning.reset();
6988
this.webapi = {
7089
WebClient: function () {
7190
this.apiCall = () => ({

0 commit comments

Comments
 (0)