check build status for all branches

This commit is contained in:
Zeke Sikelianos 2017-08-01 15:13:38 -07:00
Родитель f2dc36e95c
Коммит ff7dfe19e3
3 изменённых файлов: 94 добавлений и 39 удалений

Просмотреть файл

@ -2,15 +2,13 @@
const got = require('got')
const assert = require('assert')
const ghauth = require('ghauth')
const GitHub = require('github')
const query = process.argv.slice(2)[0]
require('colors')
const commit = process.argv[2]
assert(commit, `specify a commit SHA as the first argument`)
assert(commit.length === 40, `full 40-character SHA is required`)
const authOptions = {configName: 'libcc-check', note: 'electron/libcc-check'}
const url = 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
const platforms = [
'osx/x64',
'mas/x64',
@ -19,28 +17,56 @@ const platforms = [
'linux/ia32',
'linux/x64',
'linux/arm'
].sort()
]
const branches = []
async function fetch (platform, commit) {
const fullURL = `${url}/${platform}/${commit}/libchromiumcontent.zip`
ghauth(authOptions, function (err, authData) {
const github = new GitHub()
github.authenticate({type: 'token', token: authData.token})
github.repos.getBranches({owner: 'electron', repo: 'libchromiumcontent'})
.then(res => {
const assets = []
res.data.forEach(branch => {
platforms.forEach(platform => {
assets.push({
branch: branch.name,
commit: branch.commit.sha,
platform: platform,
url: `${url}/${platform}/${branch.commit.sha}/libchromiumcontent.zip`
})
})
})
return Promise.all(assets.map(asset => fetch(asset)))
})
.then((assets) => {
const matches = assets
.filter(asset => !query || JSON.stringify(asset).includes(query))
if (!matches.length) {
console.log(`No matches found for ${query}. Try again without a query.`)
}
matches.forEach((asset, i) => {
const status = asset.available ? '\u2713'.green : '\u2717'.red
// add space between branches
if (!query && i > 0 && asset.branch != assets[i-1].branch) console.log('')
console.log(`${status} ${asset.branch} - ${asset.commit} - ${asset.platform}`)
})
})
.catch(err => {
throw err
})
})
async function fetch (asset) {
try {
await got.head(fullURL)
return {platform, available: true}
await got.head(asset.url)
return Object.assign(asset, {available: true})
} catch (error) {
return {platform, available: false}
return Object.assign(asset, {available: false})
}
}
function logResult ({platform, available}) {
if (available) {
console.log(`${'\u2713'.green} ${platform}`)
} else {
console.log(`${'\u2717'.red} ${platform}`)
}
}
Promise.all(platforms.map((platform) => {
return fetch(platform, commit)
})).then((platforms) => {
platforms.forEach(logResult)
})
}

Просмотреть файл

@ -9,6 +9,8 @@
"license": "MIT",
"dependencies": {
"colors": "^1.1.2",
"ghauth": "^3.2.1",
"github": "^9.2.0",
"got": "^7.1.0"
}
}
}

Просмотреть файл

@ -2,6 +2,8 @@
A little tool for checking up on [libchromiumcontent](https://github.com/electron/libchromiumcontent) builds.
It checks all open branches and displays the status of compiled assets for each.
## Installation
```sh
@ -10,20 +12,45 @@ npm i -g electron/libcc-check
## Usage
Pass the SHA you're interested in to find out if it's been successfully
compiled for all targets:
To see status for all remote branches, run the command with no arguments.
```
libcc-check 7a9d4a1c9c265468dd54005f6c1920b2cc2c8ec3
✓ linux/arm
✓ linux/ia32
✓ linux/x64
✓ mas/x64
✓ osx/x64
✓ win/ia32
✓ win/x64
libcc-check
```
The first time you run the CLI, you'll be asked to authenticate with your GitHub
account. The token is stored in your home directory so this will only happen
once.
You can also filter by a specific commit SHA:
```
libcc-check ebaf0cac1543c32b6a7a567aad95ca051d3a0607
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - osx/x64
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - mas/x64
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - win/ia32
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - win/x64
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - linux/ia32
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - linux/x64
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - linux/arm
```
Or by branch name:
```
libcc-check upgrade-to-chromium-59
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - osx/x64
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - mas/x64
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - win/ia32
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - win/x64
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - linux/ia32
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - linux/x64
✓ upgrade-to-chromium-59 - ebaf0cac1543c32b6a7a567aad95ca051d3a0607 - linux/arm
```
You could also just `libcc-check | grep foo`, but then you'd lose the colored
output.
## License
MIT
MIT