Skip to content
Closed
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
28 changes: 19 additions & 9 deletions __tests__/proxy-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ integration('ProxyBuilder', () => {
const jobId = 1
const jobToken = 'xxxyyyzzzz'
const dependabotApiUrl = 'http://localhost:9000'
const packageManager = 'npm_and_yarn'
const credentials: Credential[] = [
{
type: 'git_source',
Expand All @@ -38,7 +39,8 @@ integration('ProxyBuilder', () => {
jobId,
jobToken,
dependabotApiUrl,
credentials
credentials,
packageManager
)
await proxy.container.start()
await proxy.waitUntilReady()
Expand Down Expand Up @@ -96,7 +98,8 @@ integration('ProxyBuilder', () => {
jobId,
jobToken,
dependabotApiUrl,
credentials
credentials,
packageManager
)
await proxy.container.start()

Expand Down Expand Up @@ -128,7 +131,8 @@ integration('ProxyBuilder', () => {
jobId,
jobToken,
dependabotApiUrl,
credentials
credentials,
packageManager
)
await proxy.container.start()

Expand All @@ -154,7 +158,8 @@ integration('ProxyBuilder', () => {
jobId,
jobToken,
dependabotApiUrl,
credentials
credentials,
packageManager
)
await proxy.container.start()

Expand All @@ -173,7 +178,8 @@ integration('ProxyBuilder', () => {
jobId,
jobToken,
dependabotApiUrl,
credentials
credentials,
packageManager
)
await proxy.container.start()

Expand All @@ -193,7 +199,8 @@ integration('ProxyBuilder', () => {
jobId,
jobToken,
dependabotApiUrl,
credentials
credentials,
packageManager
)
await proxy.container.start()

Expand All @@ -219,7 +226,8 @@ integration('ProxyBuilder', () => {
jobId,
jobToken,
dependabotApiUrl,
credentials
credentials,
packageManager
)
await proxy.container.start()

Expand All @@ -244,7 +252,8 @@ integration('ProxyBuilder', () => {
jobId,
jobToken,
dependabotApiUrl,
credentials
credentials,
packageManager
)
await proxy.container.start()

Expand All @@ -270,7 +279,8 @@ integration('ProxyBuilder', () => {
jobId,
jobToken,
dependabotApiUrl,
credentials
credentials,
packageManager
)
await proxy.container.start()

Expand Down
15 changes: 14 additions & 1 deletion __tests__/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ async function buildProxyWithStopError(
1,
'job-token',
'https://dependabot-api.example.com',
credentials
credentials,
'npm_and_yarn'
)

return {
Expand Down Expand Up @@ -196,6 +197,18 @@ describe('Proxy environment', () => {
})
)
})

it('sets the PACKAGE_MANAGER env variable on the proxy container', async () => {
const {createContainer} = await buildProxyWithStopError(
alreadyStoppedError()
)

expect(createContainer).toHaveBeenCalledWith(
expect.objectContaining({
Env: expect.arrayContaining(['PACKAGE_MANAGER=npm_and_yarn'])
})
)
})
})

describe('Proxy readiness', () => {
Expand Down
9 changes: 6 additions & 3 deletions __tests__/updater-builder-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ integration('UpdaterBuilder', () => {
1,
jobToken,
dependabotApiUrl,
credentials
credentials,
details['package-manager']
)
await proxy.container.start()
const input = {job: details}
Expand Down Expand Up @@ -83,7 +84,8 @@ integration('UpdaterBuilder', () => {
1,
jobToken,
dependabotApiUrl,
credentials
credentials,
details['package-manager']
)
await proxy.container.start()
const input = {job: details}
Expand Down Expand Up @@ -120,7 +122,8 @@ integration('UpdaterBuilder', () => {
1,
jobToken,
dependabotApiUrl,
credentials
credentials,
details['package-manager']
)
await proxy.container.start()
const input = {job: details}
Expand Down
3 changes: 2 additions & 1 deletion __tests__/updater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ describe('Updater', () => {
mockApiClient.params.jobId,
'job-token',
mockApiClient.params.dependabotApiUrl,
credentials
credentials,
mockJobDetails['package-manager']
)
})
})
Expand Down
11 changes: 7 additions & 4 deletions dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export class ProxyBuilder {
jobId: number,
jobToken: string,
dependabotApiUrl: string,
credentials: Credential[]
credentials: Credential[],
packageManager: string
): Promise<Proxy> {
const name = `dependabot-job-${jobId}-proxy`
const config = this.buildProxyConfig(credentials)
Expand All @@ -81,7 +82,8 @@ export class ProxyBuilder {
name,
externalNetwork,
internalNetwork,
internalNetworkName
internalNetworkName,
packageManager
)

await ContainerService.storeInput(
Expand Down Expand Up @@ -281,7 +283,8 @@ export class ProxyBuilder {
containerName: string,
externalNetwork: Network,
internalNetwork: Network,
internalNetworkName: string
internalNetworkName: string,
packageManager: string
): Promise<Container> {
const container = await this.docker.createContainer({
Image: this.proxyImage,
Expand All @@ -296,6 +299,7 @@ export class ProxyBuilder {
`no_proxy=${process.env.no_proxy || process.env.NO_PROXY || ''}`,
`JOB_ID=${jobId}`,
`JOB_TOKEN=${jobToken}`,
`PACKAGE_MANAGER=${packageManager}`,
'PROXY_CACHE=true',
`DEPENDABOT_API_URL=${dependabotApiUrl}`,
`ACTIONS_ID_TOKEN_REQUEST_TOKEN=${process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN || ''}`,
Expand Down
3 changes: 2 additions & 1 deletion src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export class Updater {
this.apiClient.params.jobId,
this.apiClient.getJobToken(),
this.apiClient.params.dependabotApiUrl,
this.credentials
this.credentials,
this.details['package-manager']
)
await proxy.container.start()

Expand Down
Loading