Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
330 lines (305 sloc) 10.3 KB
# CircleCI 2.0
version: 2
# Reusable definitions shared between Linux and macOS
defs:
release-filters: &release-filters
branches:
only:
- /^prerelease-(patch|minor)-.*/
tags:
only:
- /^v\d+\.\d+\.\d+/
cache:
cache-node_modules: &cache-node_modules
key: node_modules-{{ arch }}-{{ checksum "yarn.lock" }}
paths:
- node_modules
restore-node_modules: &restore-node_modules
keys:
- node_modules-{{ arch }}-{{ checksum "yarn.lock" }}
# if cache for exact version of `yarn.lock` is not present then
# load any most recent one
- node_modules-{{ arch }}
machines:
docker-custom-nodejs: &docker-custom-nodejs
- image: xodio/cci-node:10-v2
steps:
step-install-arduino-cli-on-mac: &step-install-arduino-cli-on-mac
name: Install arduino-cli
command: |
curl -s --create-dirs -o "$HOME/arduino-cli.zip" "http://downloads.arduino.cc/PR/arduino-cli/arduino-cli-25-PR91-osx.zip" \
&& unzip "$HOME/arduino-cli.zip" -d "$HOME" \
&& mv "$HOME/arduino-cli-25-PR91-osx" "$HOME/arduino-cli" \
&& cp "$HOME/arduino-cli" "./packages/xod-client-electron/arduino-cli" \
&& mkdir "/tmp/arduino-cli" \
&& cp "$HOME/arduino-cli" "/tmp/arduino-cli/arduino-cli"
step-install-arduino-cli-on-linux: &step-install-arduino-cli-on-linux
name: Install arduino-cli
command: |
curl -s --create-dirs -o "$HOME/arduino-cli.tar.bz2" "http://downloads.arduino.cc/PR/arduino-cli/arduino-cli-25-PR91-linux64.tar.bz2" \
&& tar xvjf "$HOME/arduino-cli.tar.bz2" -C "$HOME" \
&& mv "$HOME/arduino-cli-25-PR91-linux64" "$HOME/arduino-cli" \
&& cp "$HOME/arduino-cli" "./packages/xod-client-electron/arduino-cli" \
&& mkdir "/tmp/arduino-cli" \
&& cp "$HOME/arduino-cli" "/tmp/arduino-cli/arduino-cli"
step-install: &step-install
name: Install Node modules
# to always instal some essential tools(electron-builder etc)
command: NODE_ENV=development yarn install --force
step-bump-version: &step-bump-version
name: Bump version
command: |
if [[ $CIRCLE_BRANCH =~ ^prerelease-(patch|minor)- ]]; then
yarn lerna publish --skip-git --skip-npm --canary --cd-version ${BASH_REMATCH[1]} --yes
fi
step-build: &step-build
name: Build
command: yarn build
step-verify-git-clean: &step-verify-git-clean
name: Verify that previous step made no side-effects
command: ./tools/verify-git-clean.sh
step-build-electron: &step-build-electron
name: Build electron IDE app
command: yarn build:electron
step-lint: &step-lint
name: Lint
# run prettier on md files separately because of https://github.com/prettier/eslint-plugin-prettier/issues/67
command: yarn lint && yarn prettier-md-check
step-test: &step-test
name: Unit tests
command: yarn test
step-test-func: &step-test-func
name: Functional tests
command: yarn test-func
step-dist-electron: &step-dist-electron
name: Build electron IDE distro
command: yarn dist:electron
no_output_timeout: 30m
jobs:
#--------------------------------------------------------------------
# Verify jobs
#--------------------------------------------------------------------
verify-linux:
docker: *docker-custom-nodejs
environment:
DISPLAY: ":99.0"
XOD_ARDUINO_CLI: /tmp/arduino-cli/arduino-cli
steps:
- run:
name: Running X virtual framebuffer
command: Xvfb :99 -screen 0 1280x1024x24
background: true
- checkout
- restore_cache: *restore-node_modules
- run: *step-install
- run: *step-install-arduino-cli-on-linux
- save_cache: *cache-node_modules
- run: *step-build
- run: *step-verify-git-clean
- run: *step-lint
- run: *step-test
- run: *step-test-func
- run: *step-verify-git-clean
verify-macos:
macos:
xcode: "10.0.0"
environment:
YARN_CACHE_FOLDER: /tmp/yarn-cache
XOD_ARDUINO_CLI: /tmp/arduino-cli/arduino-cli
steps:
- checkout
- restore_cache: *restore-node_modules
- run: *step-install-arduino-cli-on-mac
- run: *step-install
- save_cache: *cache-node_modules
- run: *step-build
- run: *step-verify-git-clean
- run: *step-lint
- run: *step-test
- run: *step-test-func
- run: *step-verify-git-clean
test-cpp:
docker: *docker-custom-nodejs
environment:
XOD_OUTPUT: /tmp/tabtests-cpp
steps:
- checkout
- restore_cache: *restore-node_modules
- run: *step-install
- run:
name: Build CLI
command: yarn build:cli
- run:
name: Generate tabtests
command: |
ls -d workspace/__lib__/xod/* workspace/test/* | xargs -n 1 \
yarn xodc tabtest --no-build | cat
- run:
name: Build tabtests
command: make -C $XOD_OUTPUT
- run:
name: Run tabtests
command: make -C $XOD_OUTPUT test
#--------------------------------------------------------------------
# Distro jobs
#--------------------------------------------------------------------
dist-linux:
docker: *docker-custom-nodejs
environment:
NODE_ENV: production
XOD_ARDUINO_CLI: /tmp/arduino-cli/arduino-cli
steps:
- checkout
- restore_cache: *restore-node_modules
- run: *step-install-arduino-cli-on-linux
- run: *step-install
- run: *step-bump-version
- run: *step-build-electron
- run: *step-dist-electron
- run:
name: Store version tag
command: |
PKG=./packages/xod-client-electron
QUERY="console.log('v' + require('$PKG/package.json').version)"
node -e "$QUERY" > $PKG/dist/TAG
echo "Tag set to: $PKG/dist/TAG"
- persist_to_workspace:
root: packages/xod-client-electron/dist
paths:
- TAG
- latest-linux.yml
- "*.deb"
- "*.rpm"
dist-macos:
macos:
xcode: "10.0.0"
environment:
NODE_ENV: production
XOD_ARDUINO_CLI: /tmp/arduino-cli/arduino-cli
steps:
- checkout
- restore_cache: *restore-node_modules
- run: *step-install-arduino-cli-on-mac
- run: *step-install
- run: *step-bump-version
- run: *step-build-electron
- run: *step-dist-electron
- persist_to_workspace:
root: packages/xod-client-electron/dist
paths:
- latest-mac.yml
- "*.dmg"
- "*.zip"
#--------------------------------------------------------------------
# Upload distros job
#--------------------------------------------------------------------
upload-distros:
docker:
- image: google/cloud-sdk:alpine
steps:
- attach_workspace:
at: dist
- run:
name: Authenticate GCloud
command: |
echo "$GOOGLE_CLOUD_STORAGE_CONFIG" | base64 -d > /tmp/gsc.json
gcloud auth activate-service-account --key-file /tmp/gsc.json
- run:
name: Upload to Google Cloud Storage
command: |
TAG=$(cat dist/TAG)
GS_PATH=gs://releases.xod.io/$TAG
echo "Uploading with tag: $TAG"
gsutil -m cp -a public-read dist/* $GS_PATH
# Adjust metadata to give proper filenames for download
# (otherwise they are dirname%3Ffilename where %3F is a slash)
ls dist -1 | xargs -n 1 -I {} \
gsutil setmeta -h 'Content-Disposition: attachment; filename="{}"' $GS_PATH/{}
#--------------------------------------------------------------------
# Docker image building jobs
#--------------------------------------------------------------------
dockerize-ide:
docker: *docker-custom-nodejs
environment:
NODE_ENV: production
IMAGE_NAME: "xodio/site-ide"
PKG: "./packages/xod-client-browser"
steps:
- checkout
- restore_cache: *restore-node_modules
- run: *step-install
- run: *step-bump-version
- run:
name: Querying version tag
command: |
mkdir $PKG/image
QUERY="console.log(require('$PKG/package.json').version)"
TAG=$(node -e "$QUERY")
IMAGE_TAG="$IMAGE_NAME:$TAG"
echo "Tag set to: $TAG"
echo $IMAGE_TAG > $PKG/image/IMAGE_TAG
- run:
name: Build browser IDE app
command: yarn build:browser
- setup_remote_docker
- run:
name: Build docker image
command: yarn dockerize:browser --tag $(cat $PKG/image/IMAGE_TAG)
- run:
name: Tar docker image
command: |
docker image save \
--output $PKG/image/site-ide.tar \
$(cat $PKG/image/IMAGE_TAG)
- persist_to_workspace:
root: packages/xod-client-browser/image
paths:
- "IMAGE_TAG"
- "*.tar"
#--------------------------------------------------------------------
# Docker push
#--------------------------------------------------------------------
push-docker-images:
docker:
- image: docker
steps:
- attach_workspace:
at: image
- setup_remote_docker
- run:
name: Untar docker image
command: docker image load --input image/site-ide.tar
- run:
name: Push docker image
command: |
docker login -u xodbot -p $DOCKER_PASS
docker push $(cat image/IMAGE_TAG)
#==============================================================================
#
# Workflows
#
#==============================================================================
workflows:
version: 2
branch:
jobs:
- verify-linux
- verify-macos
- test-cpp
- dockerize-ide:
filters: *release-filters
- push-docker-images:
filters: *release-filters
requires: [ dockerize-ide, verify-linux, test-cpp ]
- dist-linux:
filters: *release-filters
- dist-macos:
filters: *release-filters
- upload-distros:
filters: *release-filters
requires:
- verify-linux
- verify-macos
- test-cpp
- dist-linux
- dist-macos