Skip to content

[8.18] Switch validate-pr to ESM (#3774) #3777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions .github/validate-pr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,37 @@

/* global argv, path, cd */

'use strict'
import { dirname } from 'path'
import { fileURLToPath } from 'url'
import 'zx/globals'
import assert from 'assert'
import * as core from '@actions/core'
import { copyFile } from 'fs/promises'
import * as github from '@actions/github'
import specification from '../../output/schema/schema.json' assert { type: 'json' }
import { run as getReport } from '../../../clients-flight-recorder/scripts/types-validator/index.js'
import {
getNamespace,
getName
} from '../../../clients-flight-recorder/scripts/types-validator/utils.js'

const __dirname = dirname(fileURLToPath(import.meta.url))

require('zx/globals')
const assert = require('assert')
const core = require('@actions/core')
const { copyFile } = require('fs/promises')
const github = require('@actions/github')
const octokit = github.getOctokit(argv.token)
const specification = require('../../output/schema/schema.json')
const getReport = require('../../../clients-flight-recorder/scripts/types-validator')
const { getNamespace, getName } = require('../../../clients-flight-recorder/scripts/types-validator/utils')

const privateNames = ['_global']
const tick = '`'
const tsValidationPath = path.join(__dirname, '..', '..', '..', 'clients-flight-recorder', 'scripts', 'types-validator')

async function run () {
const tsValidationPath = path.join(
__dirname,
'..',
'..',
'..',
'clients-flight-recorder',
'scripts',
'types-validator'
)

async function run() {
await copyFile(
path.join(__dirname, '..', '..', 'output', 'typescript', 'types.ts'),
path.join(tsValidationPath, 'types.ts')
Expand All @@ -53,14 +67,20 @@ async function run () {
per_page: 100
})
if (data.length > 0) {
files.push(...data.map(entry => entry.filename))
files.push(
...data
.filter((entry) => entry.status !== 'deleted')
.map((entry) => entry.filename)
)
page += 1
} else {
break
}
}

const specFiles = files.filter(file => file.includes('specification') && !file.includes('compiler/test'))
const specFiles = files.filter(
(file) => file.includes('specification') && !file.includes('compiler/test')
)
const table = []

cd(tsValidationPath)
Expand Down Expand Up @@ -163,7 +183,7 @@ function generateResponse (r) {
return `${r.passingResponse}/${r.totalResponse}`
}

run().catch(err => {
run().catch((err) => {
core.error(err)
process.exit(1)
})
3 changes: 2 additions & 1 deletion .github/validate-pr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "validate-pr",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"exports": "./index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down