Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-paulo-parity committed Sep 17, 2021
1 parent 00b0656 commit 6ebc87d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
28 changes: 14 additions & 14 deletions bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const prepareBranch = async function (
const repositoryPath = path.join(gitDirectory, repo)

var { url } = await getPushDomain()
await runner.run(
runner.run(
`mkdir -p ${gitDirectory}; git clone ${url}/${owner}/${repo} ${repositoryPath}`,
)

Expand All @@ -62,36 +62,36 @@ const prepareBranch = async function (
return errorResult(`Failed to enter directory ${repositoryPath}`, error)
}

var { error, stderr } = await runner.run("git add . && git reset --hard HEAD")
var { error, stderr } = runner.run("git add . && git reset --hard HEAD")
if (error) return errorResult(stderr)

var { error, stdout, stderr } = await runner.run("git rev-parse HEAD")
var { error, stdout, stderr } = runner.run("git rev-parse HEAD")
if (error) return errorResult(stderr)
const detachedHead = stdout.trim()

// Check out to the detached head so that any branch can be deleted
var { error, stderr } = await runner.run(`git checkout ${detachedHead}`)
var { error, stderr } = runner.run(`git checkout ${detachedHead}`)
if (error) return errorResult(stderr)

// Recreate PR remote
await runner.run("git remote remove pr")
runner.run("git remote remove pr")
var { url } = await getPushDomain()
var { error, stderr } = await runner.run(
var { error, stderr } = runner.run(
`git remote add pr ${url}/${contributor}/${repo}.git`,
)
if (error)
return errorResult(`Failed to add remote reference to ${owner}/${repo}`)

// Fetch and recreate the PR's branch
await runner.run(`git branch -D ${branch}`)
var { error, stderr } = await runner.run(
runner.run(`git branch -D ${branch}`)
var { error, stderr } = runner.run(
`git fetch pr ${branch} && git checkout --track pr/${branch}`,
`Checking out ${branch}...`,
)
if (error) return errorResult(stderr)

// Fetch and merge master
var { error, stderr } = await runner.run(
var { error, stderr } = runner.run(
`git pull origin ${baseBranch}`,
`Merging branch ${baseBranch}`,
)
Expand Down Expand Up @@ -120,7 +120,7 @@ function benchBranch(runner, config) {
var error = await prepareBranch(config, { runner })
if (error) return error

var { stderr, error, stdout } = await runner.run(
var { stderr, error, stdout } = runner.run(
benchCommand,
`Benching branch ${config.branch}...`,
)
Expand Down Expand Up @@ -450,7 +450,7 @@ function benchmarkRuntime(runner, config) {
if (error) return error

const outputFile = benchCommand.match(/--output(?:=|\s+)(".+?"|\S+)/)[1]
var { stdout, stderr, error } = await runner.run(
var { stdout, stderr, error } = runner.run(
benchCommand,
`Running for branch ${config.branch}, ${
outputFile ? `outputFile: ${outputFile}` : ""
Expand All @@ -462,7 +462,7 @@ function benchmarkRuntime(runner, config) {

let extraInfo = ""

var { stdout: gitStatus, stderr: gitStatusError } = await runner.run(
var { stdout: gitStatus, stderr: gitStatusError } = runner.run(
"git status --short",
)
runner.log(`Git status after execution: ${gitStatus || gitStatusError}`)
Expand All @@ -475,7 +475,7 @@ function benchmarkRuntime(runner, config) {
})
} else {
try {
var last = await runner.run(
var last = runner.run(
`git add ${outputFile} && git commit -m "${benchCommand}"`,
)
if (last.error) {
Expand All @@ -487,7 +487,7 @@ function benchmarkRuntime(runner, config) {
} else {
const target = `${config.contributor}/${config.repo}`
const { url, token } = await config.getPushDomain()
var last = await runner.run(
var last = runner.run(
`git remote set-url pr ${url}/${target}.git && git push pr HEAD`,
`Pushing ${outputFile} to ${config.branch}`,
)
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports = (app) => {
stdout: toolchain,
error,
stderr,
} = await runner.run("rustup show active-toolchain --verbose")
} = runner.run("rustup show active-toolchain --verbose")
if (error) {
const msg = "ERROR: Failed to query the currently active Rust toolchain"
if (process.env.DEBUG) {
Expand Down
14 changes: 1 addition & 13 deletions runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Runner {
this.log = app.log
}

async run(cmd, title) {
run(cmd, title) {
let stdout = "",
stderr = "",
error = false
Expand All @@ -28,8 +28,6 @@ class Runner {
this.log({ title, msg: `Running task on directory ${process.cwd()}` })
}

await writeFileAsync(runnerOutput, "")

// The command is ran asynchronously so that the bot can still handle
// requests while it's busy running some benchmark. Previously we favored
// running the command synchronously so that there was less risk of having
Expand All @@ -49,16 +47,6 @@ class Runner {
stdout = result.stdout
} catch (err) {
error = true
try {
if (await existsAsync(runnerOutput)) {
stderr = (await readFileAsync(runnerOutput)).toString()
}
} catch (stderrReadError) {
this.logFatalError(
stderrReadError,
"Failed to read stderr from command",
)
}
this.logFatalError(err, "Caught exception in command execution")
}

Expand Down

0 comments on commit 6ebc87d

Please sign in to comment.