Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@as-cii
Created July 5, 2017 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save as-cii/70344191e8618de74593d97b90c758f1 to your computer and use it in GitHub Desktop.
Save as-cii/70344191e8618de74593d97b90c758f1 to your computer and use it in GitHub Desktop.
#!/bin/sh
echo "Downloading latest Atom master build..."
mkdir atom
artifact_url=$(script/last-atom-master-artifact-url.js)
curl -s -L $artifact_url \
-H 'Accept: application/octet-stream' \
-o "atom.zip"
unzip -q atom.zip -d atom
export ATOM_APP_NAME="Atom.app"
export ATOM_SCRIPT_NAME="atom.sh"
export ATOM_SCRIPT_PATH="./atom/${ATOM_APP_NAME}/Contents/Resources/app/atom.sh"
export ATOM_PATH="./atom"
export APM_SCRIPT_PATH="./atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/node_modules/.bin/apm"
export NPM_SCRIPT_PATH="./atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/node_modules/.bin/npm"
export PATH="${PATH}:${TRAVIS_BUILD_DIR}/atom/${ATOM_APP_NAME}/Contents/Resources/app/apm/node_modules/.bin"
echo "Using Atom version:"
"${ATOM_SCRIPT_PATH}" -v
echo "Using APM version:"
"${APM_SCRIPT_PATH}" -v
echo "Using Node version:"
node --version
echo "Using NPM version:"
npm --version
echo "Downloading package dependencies..."
"${APM_SCRIPT_PATH}" install
echo "Running specs..."
"${ATOM_SCRIPT_PATH}" --test test
#!/usr/bin/env node
const https = require('https')
printLastAtomMasterArtifactURL()
async function printLastAtomMasterArtifactURL () {
const recentBuilds = await get('/api/v1.1/project/github/atom/atom/tree/master')
const mostRecentBuild = recentBuilds[0]
const successfulBuildNumber = (mostRecentBuild.outcome === 'success')
? mostRecentBuild.build_num
: mostRecentBuild.previous_successful_build.build_num
const artifacts = await get(`/api/v1.1/project/github/atom/atom/${successfulBuildNumber}/artifacts`)
const atomZipArtifact = artifacts.find((a) => a.path.endsWith('atom-mac.zip'))
console.log(atomZipArtifact.url)
}
function get (path) {
return new Promise((resolve, reject) => {
const request = https.get({host: 'circleci.com', path, headers: {'Accept': 'application/json'}}, (response) => {
let body = ''
response.on('data', (d) => { body += d })
response.on('end', () => {
resolve(JSON.parse(body))
})
})
request.on('error', reject)
request.end()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment