2019-10-11 22:47:31 +00:00
|
|
|
version: 2.1
|
|
|
|
description: Ruffle - Flash Player emulator written in Rust
|
|
|
|
orbs:
|
|
|
|
win: circleci/windows@1.0.0
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
# General testing, linux + web build
|
|
|
|
build:
|
|
|
|
docker:
|
|
|
|
- image: circleci/rust:1.37
|
|
|
|
steps:
|
|
|
|
# Git checkout
|
|
|
|
- checkout
|
|
|
|
|
|
|
|
# Restore cached assets (cargo registry)
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- v1-cargo-cache-linux-{{ .Revision }}
|
|
|
|
- v1-cargo-cache-linux-
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
- run:
|
|
|
|
name: Setup
|
|
|
|
command: |
|
|
|
|
rustup toolchain install stable
|
|
|
|
rustup run stable rustc --version --verbose
|
|
|
|
rustup component add --toolchain stable clippy
|
|
|
|
rustup run stable cargo clippy --version
|
|
|
|
rustup component add --toolchain stable rustfmt
|
|
|
|
rustup run stable cargo fmt --version
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get -y install libasound2-dev # Required for cpal crate on Linux
|
|
|
|
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
|
|
|
|
sudo apt-get install -y nodejs
|
|
|
|
mkdir workspace
|
|
|
|
|
|
|
|
# Run tests
|
|
|
|
- run:
|
|
|
|
name: Tests
|
|
|
|
command: |
|
|
|
|
rustup run stable cargo test --package=ruffle_core
|
|
|
|
|
|
|
|
# Run cargo clippy and fmt
|
|
|
|
- run:
|
|
|
|
name: Clippy + Format
|
|
|
|
command: |
|
|
|
|
rustup run stable cargo clippy --all --tests -- -D warnings
|
|
|
|
rustup run stable cargo fmt --all -- --check
|
|
|
|
|
|
|
|
# Build the linux binary
|
|
|
|
- run:
|
|
|
|
name: Linux Build
|
|
|
|
command: |
|
|
|
|
rustup run stable cargo build --package ruffle_desktop --release
|
|
|
|
mkdir linux
|
|
|
|
cp target/release/ruffle_desktop linux/ruffle
|
|
|
|
cp README.md LICENSE_APACHE LICENSE_MIT linux
|
|
|
|
cd linux
|
|
|
|
tar -czvf ../workspace/linux.tar.gz *
|
|
|
|
|
|
|
|
# Build the wasm binary
|
|
|
|
- run:
|
|
|
|
name: Web Build
|
|
|
|
command: |
|
|
|
|
cd web/demo
|
|
|
|
npm install
|
|
|
|
npm run build -- --mode=production
|
|
|
|
cd ../..
|
|
|
|
mkdir -p workspace/web-demo
|
|
|
|
cp web/demo/dist/* workspace/web-demo
|
|
|
|
|
|
|
|
# Build the web extension
|
|
|
|
- run:
|
|
|
|
name: Extension Build
|
|
|
|
command: |
|
|
|
|
cd web/extension
|
|
|
|
npm install
|
|
|
|
wasm-pack build --release --target=no-modules --out-dir=extension/build/dist ..
|
|
|
|
npx webpack
|
|
|
|
cd build
|
|
|
|
cp ../../../README.md .
|
|
|
|
cp ../../../LICENSE_APACHE .
|
|
|
|
cp ../../../LICENSE_MIT .
|
|
|
|
zip -r extension.zip .
|
|
|
|
cd ../../..
|
|
|
|
cp web/extension/build/extension.zip workspace
|
|
|
|
|
|
|
|
# Save cached assets
|
|
|
|
- save_cache:
|
|
|
|
key: v1-cargo-cache-linux-{{ .Revision }}
|
|
|
|
paths:
|
|
|
|
- "/usr/local/cargo/registry"
|
|
|
|
- "./target"
|
|
|
|
|
|
|
|
# Persist build artifacts for deploy job
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: workspace
|
|
|
|
paths:
|
|
|
|
- linux.tar.gz
|
|
|
|
- extension.zip
|
|
|
|
- web-demo
|
|
|
|
|
|
|
|
# OSX Build
|
|
|
|
build_osx:
|
|
|
|
macos:
|
|
|
|
xcode: "9.3.0"
|
|
|
|
steps:
|
|
|
|
# Git checkout
|
|
|
|
- checkout
|
|
|
|
|
|
|
|
# Restore cached assets (cargo registry)
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- v1-cargo-cache-osx-{{ .Revision }}
|
|
|
|
- v1-cargo-cache-osx-
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
- run:
|
|
|
|
name: Setup
|
|
|
|
command: |
|
|
|
|
# Install rustup
|
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
|
|
source $HOME/.cargo/env
|
|
|
|
|
|
|
|
# Install stable rust toolchain
|
|
|
|
rustup toolchain install stable
|
|
|
|
rustup run stable rustc --version --verbose
|
|
|
|
rustup run stable cargo --version --verbose
|
|
|
|
|
|
|
|
mkdir workspace
|
|
|
|
|
|
|
|
# Build the OSX binary
|
|
|
|
- run:
|
|
|
|
name: OSX Build
|
|
|
|
command: |
|
|
|
|
source $HOME/.cargo/env
|
|
|
|
rustup run stable cargo build --package ruffle_desktop --release
|
|
|
|
mkdir osx
|
|
|
|
cp target/release/ruffle_desktop osx/ruffle
|
|
|
|
cp README.md LICENSE_APACHE LICENSE_MIT osx
|
|
|
|
cd osx
|
|
|
|
tar -czvf ../workspace/osx.tar.gz *
|
|
|
|
|
|
|
|
# Save cached assets
|
|
|
|
- save_cache:
|
|
|
|
key: v1-cargo-cache-osx-{{ .Revision }}
|
|
|
|
paths:
|
|
|
|
- "~/.cargo/registry"
|
|
|
|
- "./target"
|
|
|
|
|
|
|
|
# Persist build artifacts for deploy job
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: workspace
|
|
|
|
paths:
|
|
|
|
- osx.tar.gz
|
|
|
|
|
|
|
|
# Windows build
|
|
|
|
build_windows:
|
|
|
|
executor:
|
|
|
|
name: win/vs2019
|
|
|
|
shell: powershell.exe
|
|
|
|
steps:
|
|
|
|
# Git checkout
|
|
|
|
- checkout
|
|
|
|
|
|
|
|
# Restore cached assets (cargo registry)
|
|
|
|
- restore_cache:
|
|
|
|
keys:
|
|
|
|
- v1-cargo-cache-windows-{{ .Revision }}
|
|
|
|
- v1-cargo-cache-windows-
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
- run:
|
|
|
|
name: Install dependencies
|
|
|
|
command: |
|
|
|
|
# Install rustup
|
|
|
|
$client = new-object System.Net.WebClient
|
|
|
|
$client.DownloadFile('https://win.rustup.rs', "$pwd\rustup-init.exe")
|
|
|
|
.\rustup-init.exe -y
|
|
|
|
|
|
|
|
mkdir workspace
|
|
|
|
|
|
|
|
# Build the Windows binary
|
|
|
|
- run:
|
|
|
|
name: Windows Build
|
|
|
|
command: |
|
|
|
|
# This is necessary because otherwise cargo fails when trying to use git?
|
|
|
|
mkdir .cargo
|
|
|
|
Add-Content .cargo\config "[net]`ngit-fetch-with-cli = true"
|
|
|
|
|
|
|
|
rustup run stable rustc --version --verbose
|
|
|
|
rustup run stable cargo --version --verbose
|
|
|
|
rustup run stable cargo build --package ruffle_desktop --release
|
|
|
|
mkdir windows
|
|
|
|
copy target\release\ruffle_desktop.exe windows\ruffle.exe
|
|
|
|
copy README.md windows
|
|
|
|
copy LICENSE_APACHE windows
|
|
|
|
copy LICENSE_MIT windows\
|
|
|
|
|
|
|
|
# Have to turn off progress bar or CI explodes?!
|
|
|
|
$progressPreference = 'silentlyContinue'
|
|
|
|
Compress-Archive -Path windows\* -CompressionLevel Optimal -DestinationPath workspace\windows.zip
|
|
|
|
|
|
|
|
# Save cached assets
|
|
|
|
- save_cache:
|
|
|
|
key: v1-cargo-cache-windows-{{ .Revision }}
|
|
|
|
paths:
|
|
|
|
- c:\users\circleci\.cargo\registry
|
|
|
|
- target
|
|
|
|
|
|
|
|
# Persist build artifacts for deploy job
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: workspace
|
|
|
|
paths:
|
|
|
|
- windows.zip
|
|
|
|
|
|
|
|
# Upload builds to S3
|
|
|
|
deploy:
|
|
|
|
docker:
|
|
|
|
- image: circleci/python:3.7-stretch
|
|
|
|
steps:
|
|
|
|
# Access build artifacts in workspace
|
|
|
|
- attach_workspace:
|
|
|
|
at: workspace
|
|
|
|
|
|
|
|
# Set environment variables for nightly build name
|
|
|
|
- run:
|
|
|
|
name: Environment vars
|
|
|
|
command: |
|
|
|
|
echo 'export SHORT_GIT_HASH=$(echo $CIRCLE_SHA1 | cut -c -7)' >> $BASH_ENV
|
|
|
|
echo 'export BUILD_ID=$(date +"%Y-%m-%d")_${SHORT_GIT_HASH}' >> $BASH_ENV
|
|
|
|
echo 'export NUM_BUILDS=27' >> $BASH_ENV
|
|
|
|
|
|
|
|
# Install AWS CLI
|
|
|
|
- run:
|
|
|
|
name: Install awscli
|
|
|
|
command: sudo pip install awscli
|
|
|
|
|
|
|
|
- run:
|
|
|
|
name: Sync with S3
|
|
|
|
command: |
|
|
|
|
mkdir -p builds
|
|
|
|
aws s3 sync s3://ruffle-rs/builds builds
|
|
|
|
|
|
|
|
- run:
|
|
|
|
name: Check if stale build
|
|
|
|
command: |
|
|
|
|
# Check if files exist with this Git commit ID.
|
|
|
|
# If so, this isn't a new commit, so cancel the deployment.
|
|
|
|
if ls builds/linux/*${SHORT_GIT_HASH}.tar.gz 1> /dev/null 2>&1; then
|
|
|
|
echo "No new commits; cancelling deploy"
|
|
|
|
circleci-agent step halt
|
|
|
|
fi
|
|
|
|
|
|
|
|
- run:
|
|
|
|
name: Deploy to S3
|
|
|
|
command: |
|
|
|
|
rm -f builds/web-demo/*.wasm
|
|
|
|
rm -f builds/web-demo/*.js
|
|
|
|
rm -f builds/web-demo/*.html
|
|
|
|
mkdir -p builds/linux
|
|
|
|
cp -f workspace/linux.tar.gz builds/linux/ruffle_linux_latest.tar.gz
|
|
|
|
cp -f workspace/linux.tar.gz builds/linux/ruffle_linux_${BUILD_ID}.tar.gz
|
|
|
|
mkdir -p builds/osx
|
|
|
|
cp -f workspace/osx.tar.gz builds/osx/ruffle_osx_latest.tar.gz
|
|
|
|
cp -f workspace/osx.tar.gz builds/osx/ruffle_osx_${BUILD_ID}.tar.gz
|
|
|
|
mkdir -p builds/windows
|
|
|
|
cp -f workspace/windows.zip builds/windows/ruffle_windows_latest.zip
|
|
|
|
cp -f workspace/windows.zip builds/windows/ruffle_windows_${BUILD_ID}.zip
|
|
|
|
mkdir -p builds/extension
|
|
|
|
cp -f workspace/extension.zip builds/extension/ruffle_extension_latest.zip
|
|
|
|
cp -f workspace/extension.zip builds/extension/ruffle_extension_${BUILD_ID}.zip
|
|
|
|
|
|
|
|
# Only keep a certain # of builds.
|
|
|
|
ls -1t builds/linux/* | tail -n +${NUM_BUILDS} | xargs rm -f
|
|
|
|
ls -1t builds/osx/* | tail -n +${NUM_BUILDS} | xargs rm -f
|
|
|
|
ls -1t builds/windows/* | tail -n +${NUM_BUILDS} | xargs rm -f
|
|
|
|
ls -1t builds/extension/* | tail -n +${NUM_BUILDS} | xargs rm -f
|
|
|
|
|
|
|
|
# Copy over web demo.
|
|
|
|
cp -rf workspace/web-demo builds
|
|
|
|
|
|
|
|
# Upload to S3.
|
|
|
|
# S3 currently gives .wasm files the wrong MIME type, so have to upload that separately.
|
|
|
|
aws s3 sync builds s3://ruffle-rs/builds --acl public-read --exclude '*.wasm' --delete
|
|
|
|
aws s3 sync builds s3://ruffle-rs/builds --acl public-read --exclude '*' --include '*.wasm' --delete --content-type 'application/wasm'
|
|
|
|
|
|
|
|
# By default, S3 serves
|
|
|
|
|
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
|
|
|
|
# Basic linux build on each push or pull request to the repo
|
|
|
|
commit_build:
|
|
|
|
jobs:
|
|
|
|
- build
|
|
|
|
|
|
|
|
# Nightly builds
|
|
|
|
nightly_build:
|
|
|
|
triggers:
|
|
|
|
- schedule:
|
|
|
|
cron: "0 0 * * *"
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- master
|
|
|
|
jobs:
|
|
|
|
- build
|
|
|
|
- build_osx
|
|
|
|
- build_windows
|
|
|
|
- deploy:
|
|
|
|
requires:
|
|
|
|
- build
|
|
|
|
- build_osx
|
|
|
|
- build_windows
|