This commit is contained in:
Tatyana Kostromskaya
2023-10-04 09:30:46 +00:00
parent c25ba9aa99
commit 71bc34b2d5
10 changed files with 725 additions and 431 deletions

View File

@@ -1,6 +1,5 @@
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";
@@ -18,7 +17,7 @@ describe('@actions/github', () => {
beforeAll(async () => {
// Start proxy server
proxyServer = proxy()
proxyServer = createProxy()
await new Promise<void>(resolve => {
const port = Number(proxyUrl.split(':')[2])
proxyServer.listen(port, () => resolve())
@@ -50,22 +49,7 @@ describe('@actions/github', () => {
return
}
const myFetch: typeof undiciFetch = (url, opts) => {
return undiciFetch(url, {
...opts,
dispatcher: new ProxyAgent({
uri: proxyUrl,
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
}),
});
};
const octokit = getOctokit(token, {
request: {
fetch: myFetch
}
})
const octokit = getOctokit(token)
const branch = await octokit.rest.repos.getBranch({
owner: 'actions',
@@ -82,22 +66,18 @@ describe('@actions/github', () => {
return
}
process.env['https_proxy'] = proxyUrl
const myFetch: typeof undiciFetch = (url, opts) => {
return undiciFetch(url, {
...opts,
dispatcher: new ProxyAgent({
uri: proxyUrl,
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
}),
});
};
// const myFetch: typeof undiciFetch = (url, opts) => {
// return undiciFetch(url, {
// ...opts,
// dispatcher: new ProxyAgent({
// uri: proxyUrl,
// keepAliveTimeout: 10,
// keepAliveMaxTimeout: 10,
// }),
// });
// };
const octokit = getOctokit(token, {
request: {
fetch: myFetch
}
})
const octokit = getOctokit(token)
const repository = await octokit.graphql(
'{repository(owner:"actions", name:"toolkit"){name}}'

View File

@@ -1,5 +1,5 @@
import * as http from 'http'
import proxy from 'proxy'
import { createProxy } from 'proxy'
import {getOctokit} from '../src/github'
import {GitHub, getOctokitOptions} from '../src/utils'
@@ -12,7 +12,7 @@ describe('@actions/github', () => {
beforeAll(async () => {
// Start proxy server
proxyServer = proxy()
proxyServer = createProxy()
await new Promise<void>(resolve => {
const port = Number(proxyUrl.split(':')[2])
proxyServer.listen(port, () => resolve())