Skip to content

Commit

Permalink
Start FileUpdater container, add it to host network, and use intern…
Browse files Browse the repository at this point in the history
…al endpoint in test
  • Loading branch information
Nish Sinha committed Jul 22, 2021
1 parent 4952b02 commit 4414c7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions __tests__/updater-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ describe('Updater', () => {
jobID: 1,
jobToken: 'xxx',
credentialsToken: 'yyy',
dependabotAPI: 'http://localhost'
dependabotAPI: 'http://host.docker.internal:3001'
}
}
const updater = new Updater(docker, mockDependabotAPI)

beforeAll(() => {
updater.pullImage()
})

afterEach(() => {
docker.listContainers(function (err, containers) {
if (!containers) return
Expand Down Expand Up @@ -54,8 +58,6 @@ describe('Updater', () => {
}
]
})

await updater.pullImage()
await updater.runUpdater()
})
})
12 changes: 12 additions & 0 deletions src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ export class Updater {
files: FetchedFiles
): Promise<void> {
core.info(`running update ${details.id} ${files}`)
const container = await this.createContainer(details, 'update_files')
const containerInput: FileUpdaterInput = {
base_commit_sha: files.base_commit_sha,
base64_dependency_files: files.base64_dependency_files,
dependency_files: files.dependency_files,
job: details
}
await this.storeContainerInput(container, containerInput)
await this.runContainer(container)
}

private async createContainer(
Expand Down Expand Up @@ -170,6 +179,9 @@ export class Updater {
})
container.modem.demuxStream(stream, process.stdout, process.stderr)

const network = this.docker.getNetwork('host')
network.connect({Container: container}, (err, data) => core.info(err))

await container.wait()
} finally {
await container.remove()
Expand Down

0 comments on commit 4414c7c

Please sign in to comment.