Skip to content

Commit

Permalink
Fix Travis build script
Browse files Browse the repository at this point in the history
  • Loading branch information
code-asher committed Jun 20, 2019
1 parent 9af553e commit b018502
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ before_install:
libsecret-1-dev; fi
- npm install -g [email protected]
script:
- scripts/build.sh
- scripts/build.bash
before_deploy:
- echo "$VERSION" "$TRAVIS_COMMIT"
- git config --local user.name "$USER_NAME"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY . .

# In the future, we can use https://github.com/yarnpkg/rfcs/pull/53 to make yarn use the node_modules
# directly which should be fast as it is slow because it populates its own cache every time.
RUN yarn && NODE_ENV=production yarn task build:server:binary
RUN yarn && yarn build

# We deploy with ubuntu so that devs have a familiar environment.
FROM ubuntu:18.04
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"postinstall": "yarn build:rules",
"build": "yarn task build",
"bundle": "yarn task bundle",
"package": "yarn task package",
"start": "npm-run-all --parallel watch build:run",
"watch": "yarn task build true",
"build:run": "cd ./out && node ./packages/server/src/cli # TODO: restart on change",
Expand Down
14 changes: 9 additions & 5 deletions scripts/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -euxo pipefail
function docker_build() {
local image="${1}" ; shift
local version="${1}" ; shift
local ci=${CI:-}

local containerId
containerId=$(docker create --network=host --rm -it -v "$(pwd)"/.cache:/src/.cache "${image}")
Expand All @@ -18,8 +19,9 @@ function docker_build() {
docker cp ./. "${containerId}":/src
docker_exec "cd /src && yarn"
docker_exec "cd /src && npm rebuild"
docker_exec "cd /src && NODE_ENV=production VERSION=${version} yarn task build:server:binary"
docker_exec "cd /src && yarn task package ${version}"
docker_exec "cd /src && VERSION=${version} CI=${ci} yarn build"
docker_exec "cd /src && yarn bundle"
docker_exec "cd /src && yarn package ${version}"
docker cp "${containerId}":/src/release/. ./release/

docker stop "${containerId}"
Expand All @@ -28,18 +30,20 @@ function docker_build() {
function main() {
local version=${VERSION:-}
local ostype=${OSTYPE:-}
local target=${TARGET:-}

if [[ -z "${version}" ]] ; then
>&2 echo "Must set VERSION environment variable"
exit 1
fi

if [[ "${ostype}" == "darwin"* ]]; then
NODE_ENV=production VERSION="${version}" yarn task build:server:binary
yarn task package "${version}"
VERSION="${version}" yarn build
yarn bundle
yarn package "${version}"
else
local image
if [[ "$TARGET" == "alpine" ]]; then
if [[ "${target}" == "alpine" ]]; then
image="codercom/nbin-alpine"
else
image="codercom/nbin-centos"
Expand Down
7 changes: 5 additions & 2 deletions scripts/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ register("build", async (runner, logger, shouldWatch: string) => {
const watch = shouldWatch === "true";

logger.info("Building", field("env", {
NODE_ENV: process.env.NODE_ENV,
VERSION: process.env.VERSION,
}), field("vscode", vscodeVersion), field("watch", watch));

Expand Down Expand Up @@ -153,7 +152,11 @@ const ensureInstalled = register("vscode:install", async (runner, logger) => {
}));
break;
case 404:
logger.info(`VS Code ${vscodeVersion} hasn't been packaged yet`);
const message = `VS Code ${vscodeVersion} hasn't been packaged yet`;
if (process.env.CI) {
return reject(new Error(message));
}
logger.warn(message);
clone().then(() => build()).catch(reject);
break;
default:
Expand Down

0 comments on commit b018502

Please sign in to comment.