Merge branch 'main' into takost/addfetchmethod

This commit is contained in:
Tatyana Kostromskaya
2023-09-28 11:07:01 +00:00
12 changed files with 337 additions and 449 deletions

View File

@@ -1,5 +1,6 @@
import * as http from 'http'
import * as https from 'https'
import proxy from 'proxy'
import { ProxyServer, createProxy } from "proxy";
import { ProxyAgent, fetch as undiciFetch } from "undici";
@@ -8,7 +9,7 @@ const proxyUrl = 'http://127.0.0.1:8081'
const originalProxyUrl = process.env['https_proxy']
process.env['https_proxy'] = proxyUrl
// eslint-disable-next-line import/first
import { getOctokit } from '../src/github'
import {getOctokit} from '../src/github'
describe('@actions/github', () => {
let proxyConnects: string[]
@@ -17,13 +18,12 @@ describe('@actions/github', () => {
beforeAll(async () => {
// Start proxy server
proxyServer = createProxy()
proxyServer = proxy()
await new Promise<void>(resolve => {
const port = Number(proxyUrl.split(':')[2])
proxyServer.listen(port, () => resolve())
})
proxyServer.on('connect', req => {
console.log("Connect to proxy server")
proxyConnects.push(req.url ?? '')
})
})
@@ -102,7 +102,7 @@ describe('@actions/github', () => {
const repository = await octokit.graphql(
'{repository(owner:"actions", name:"toolkit"){name}}'
)
expect(repository).toEqual({ repository: { name: 'toolkit' } })
expect(repository).toEqual({repository: {name: 'toolkit'}})
expect(proxyConnects).toEqual(['api.github.com:443'])
})

View File

@@ -1,5 +1,5 @@
import * as http from 'http'
import { createProxy } from 'proxy'
import proxy from 'proxy'
import {getOctokit} from '../src/github'
import {GitHub, getOctokitOptions} from '../src/utils'
@@ -12,10 +12,10 @@ describe('@actions/github', () => {
beforeAll(async () => {
// Start proxy server
proxyServer = createProxy()
await new Promise(resolve => {
proxyServer = proxy()
await new Promise<void>(resolve => {
const port = Number(proxyUrl.split(':')[2])
proxyServer.listen(port, () => resolve(null))
proxyServer.listen(port, () => resolve())
})
proxyServer.on('connect', req => {
proxyConnects.push(req.url ?? '')
@@ -29,8 +29,8 @@ describe('@actions/github', () => {
afterAll(async () => {
// Stop proxy server
await new Promise(resolve => {
proxyServer.once('close', () => resolve(null))
await new Promise<void>(resolve => {
proxyServer.once('close', () => resolve())
proxyServer.close()
})

View File

@@ -1,4 +1,4 @@
declare module 'proxy1' {
declare module 'proxy' {
import * as http from 'http'
function internal(): http.Server
export = internal

File diff suppressed because it is too large Load Diff

View File

@@ -38,14 +38,12 @@
"url": "https://github.com/actions/toolkit/issues"
},
"dependencies": {
"@actions/http-client": "^2.1.1",
"@octokit/core": "^4.2.4",
"@octokit/plugin-paginate-rest": "^6.1.2",
"@octokit/plugin-rest-endpoint-methods": "^7.2.3",
"undici": "^5.25.1"
"@actions/http-client": "^2.0.1",
"@octokit/core": "^3.6.0",
"@octokit/plugin-paginate-rest": "^2.17.0",
"@octokit/plugin-rest-endpoint-methods": "^5.13.0"
},
"devDependencies": {
"@types/proxy": "^1.0.1",
"proxy": "^2.1.1"
"proxy": "^1.0.2"
}
}
}