Skip to content

Commit 6289e11

Browse files
svozzadreamorosi
andauthored
chore(ci): convert the scripts in .github/scripts to ESM (#5640)
Co-authored-by: Andrea Amorosi <dreamorosi@gmail.com>
1 parent 68ebc7c commit 6289e11

4 files changed

Lines changed: 6 additions & 10 deletions

File tree

.github/scripts/package.json

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

.github/scripts/release_patch_package_json.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*
99
* The file will be restored to its original state after the release is complete.
1010
*/
11-
const { readFileSync, writeFileSync } = require('node:fs');
12-
const { join, resolve } = require('node:path');
11+
import { readFileSync, writeFileSync } from 'node:fs';
12+
import { join, resolve } from 'node:path';
1313

1414
if (process.argv.length < 3) {
1515
console.error('Usage: node release_patch_package_json.js <package_path>\n');

.github/scripts/report_e2e_sweep.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,4 @@ const reportE2eSweep = async ({ github, context, core, report }) => {
9696
core.info(`Updated incident issue #${incident.number}`);
9797
};
9898

99-
module.exports = reportE2eSweep;
100-
module.exports.formatReport = formatReport;
99+
export { formatReport, reportE2eSweep as default };

.github/workflows/sweep-stale-e2e-stacks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ jobs:
112112
env:
113113
REPORT_JSON: ${{ steps.report.outputs.report }}
114114
run: |
115-
node <<'NODE' >> "$GITHUB_STEP_SUMMARY"
116-
const { formatReport } = require('./.github/scripts/report_e2e_sweep.js');
115+
node --input-type=module <<'NODE' >> "$GITHUB_STEP_SUMMARY"
116+
import { formatReport } from './.github/scripts/report_e2e_sweep.js';
117117
const report = JSON.parse(process.env.REPORT_JSON);
118118
const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
119119
console.log(formatReport({ report, runUrl }));
@@ -141,7 +141,7 @@ jobs:
141141
with:
142142
github-token: ${{ secrets.GITHUB_TOKEN }}
143143
script: |
144-
const report_e2e_sweep = require('./.github/scripts/report_e2e_sweep.js')
144+
const { default: report_e2e_sweep } = await import('${{ github.workspace }}/.github/scripts/report_e2e_sweep.js')
145145
await report_e2e_sweep({github, context, core, report: JSON.parse(process.env.REPORT_JSON)})
146146
- name: Fail after unsuccessful cleanup
147147
if: always() && (needs.sweep.outputs.sweep_outcome != 'success' || steps.notification.outcome != 'success')

0 commit comments

Comments
 (0)