name: ci
on: [push, pull_request]
jobs:
skip-commit:
name: Conditionally skip ci
runs-on: ubuntu-latest
steps:
- if: "contains(github.event.head_commit.message, '[skip-ci]')
|| contains(github.event.head_commit.message, '[skip ci]')
|| contains(github.event.head_commit.message, '[ci-skip]')
|| contains(github.event.head_commit.message, '[ci skip]')"
run: exit 78
linux-cache-tools:
name: Cache tools
needs: [skip-commit]
runs-on: ubuntu-latest
env:
RUST_TOOLCHAIN: 1.40.0
RUSTC_WRAPPER: tools/bin/sccache
steps:
- uses: actions/checkout@v1
- name: Prepare for restoring caches
run: |
rm -rf /home/runner/.rustup
rm -rf /home/runner/.cargo/git
rm -rf /home/runner/.cargo/registry
- name: Restore /home/runner/tools/bin
id: cache-tools-bin
uses: actions/cache@v1
with:
path: tools/bin
key: tools-bin-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('**/Cargo.lock') }}
- name: Install sccache and wasm-pack
if: steps.cache-tools-bin.outputs.cache-hit != 'true'
run: |
mkdir -p tools/bin
curl -L https://github.com/mozilla/sccache/releases/download/0.2.12/sccache-0.2.12-x86_64-unknown-linux-musl.tar.gz | tar zxf - --overwrite --strip-components=1 -C tools/bin
curl -L https://github.com/rustwasm/wasm-pack/releases/download/v0.8.1/wasm-pack-v0.8.1-x86_64-unknown-linux-musl.tar.gz | tar zxf - --overwrite --strip-components=1 -C tools/bin
- name: Restore /home/runner/.rustup
if: "steps.cache-tools-bin.outputs.cache-hit != 'true'"
id: cache-rustup
uses: actions/cache@v1
with:
path: /home/runner/.rustup
key: rustup-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('rust-toolchain') }}
- name: Install rust toolchain
if: "steps.cache-tools-bin.outputs.cache-hit != 'true'
&& steps.cache-rustup .outputs.cache-hit != 'true'"
run: |
rustup set profile minimal
rustup toolchain install $RUST_TOOLCHAIN --component clippy rustfmt
- name: Restore /home/runner/.cache/sccache
if: "steps.cache-tools-bin.outputs.cache-hit != 'true'"
uses: actions/cache@v1
with:
path: /home/runner/.cache/sccache
key: sccache-[linux-cache-tools]-${{ runner.OS }}-s${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/.cargo/git
if: "steps.cache-tools-bin.outputs.cache-hit != 'true'"
id: cache-cargo-git
uses: actions/cache@v1
with:
path: /home/runner/.cargo/git
key: cargo-git-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/.cargo/registry
id: cache-cargo-registry
if: "steps.cache-tools-bin.outputs.cache-hit != 'true'"
uses: actions/cache@v1
with:
path: /home/runner/.cargo/registry
key: cargo-registry-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo fetch
if: " steps.cache-tools-bin .outputs.cache-hit != 'true'
&& (steps.cache-cargo-git .outputs.cache-hit != 'true'
|| steps.cache-cargo-registry.outputs.cache-hit != 'true')"
run: cargo fetch
- name: Install cargo-audit
if: "steps.cache-tools-bin.outputs.cache-hit != 'true'"
run: cargo install --root tools --force cargo-audit
linux-cargo-audit:
name: Run cargo audit
needs: [skip-commit, linux-cache-tools]
runs-on: ubuntu-latest
env:
RUST_TOOLCHAIN: 1.40.0
RUSTC_WRAPPER: tools/bin/sccache
steps:
- uses: actions/checkout@v1
- name: Restore /home/runner/tools/bin
uses: actions/cache@v1
with:
path: tools/bin
key: tools-bin-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('**/Cargo.lock') }}
- run: tools/bin/cargo-audit audit
linux-cargo-clippy:
name: Run cargo clippy
needs: [skip-commit, linux-cache-tools]
runs-on: ubuntu-latest
env:
RUST_TOOLCHAIN: 1.40.0
RUSTC_WRAPPER: tools/bin/sccache
steps:
- uses: actions/checkout@v1
- name: Prepare for restoring caches
run: |
rm -rf /home/runner/.rustup
rm -rf /home/runner/.cargo/git
rm -rf /home/runner/.cargo/registry
- name: Restore /home/runner/.rustup
uses: actions/cache@v1
with:
path: /home/runner/.rustup
key: rustup-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('rust-toolchain') }}
- name: Restore /home/runner/.cache/sccache
uses: actions/cache@v1
with:
path: /home/runner/.cache/sccache
key: sccache-[linux-cargo-clippy]-${{ runner.OS }}-s${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/tools/bin
uses: actions/cache@v1
with:
path: tools/bin
key: tools-bin-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/.cargo/git
uses: actions/cache@v1
with:
path: /home/runner/.cargo/git
key: cargo-git-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/.cargo/registry
uses: actions/cache@v1
with:
path: /home/runner/.cargo/registry
key: cargo-registry-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Restore ./target
uses: actions/cache@v1
with:
path: target
key: cargo-build-target-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --frozen --all-features --all-targets -- -D warnings
linux-cargo-docs:
name: Run cargo docs
needs: [skip-commit, linux-cache-tools]
runs-on: ubuntu-latest
env:
RUST_TOOLCHAIN: 1.40.0
RUSTC_WRAPPER: tools/bin/sccache
steps:
- uses: actions/checkout@v1
- name: Prepare for restoring caches
run: |
rm -rf /home/runner/.rustup
rm -rf /home/runner/.cargo/git
rm -rf /home/runner/.cargo/registry
- name: Restore /home/runner/.rustup
uses: actions/cache@v1
with:
path: /home/runner/.rustup
key: rustup-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('rust-toolchain') }}
- name: Restore /home/runner/.cache/sccache
uses: actions/cache@v1
with:
path: /home/runner/.cache/sccache
key: sccache-[linux-cargo-docs]-${{ runner.OS }}-s${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/tools/bin
uses: actions/cache@v1
with:
path: tools/bin
key: tools-bin-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/.cargo/git
uses: actions/cache@v1
with:
path: /home/runner/.cargo/git
key: cargo-git-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/.cargo/registry
uses: actions/cache@v1
with:
path: /home/runner/.cargo/registry
key: cargo-registry-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Restore ./target
uses: actions/cache@v1
with:
path: target
key: cargo-build-target-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo doc
uses: actions-rs/cargo@v1
with:
command: doc
args: --frozen --all-features --no-deps --package electron-sys
- env:
PERSONAL_TOKEN: ${{ secrets.ACTIONS_GH_PAGES_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./target/doc
SCRIPT_MODE: true
run: wget -qO - https://raw.githubusercontent.com/interfaces-rs/actions-gh-pages/v2.5.1/entrypoint.sh | bash -
linux-cargo-fmt:
name: Run cargo fmt
needs: [skip-commit, linux-cache-tools]
runs-on: ubuntu-latest
env:
RUST_TOOLCHAIN: nightly
steps:
- uses: actions/checkout@v1
- name: Prepare for restoring caches
run: |
rm -rf /home/runner/.rustup
- name: Restore /home/runner/.rustup
id: cache-rustup
uses: actions/cache@v1
with:
path: /home/runner/.rustup
key: rustup-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('rust-toolchain') }}
- name: Install rust toolchain
if: steps.cache-rustup.outputs.cache-hit != 'true'
run: |
rustup set profile minimal
rustup toolchain install $RUST_TOOLCHAIN --component rustfmt
- name: Run cargo fmt
run: cargo "+$RUST_TOOLCHAIN" fmt --all -- --check
linux-cargo-test:
name: Run cargo test
needs: [skip-commit, linux-cache-tools]
runs-on: ubuntu-latest
env:
RUST_TOOLCHAIN: 1.40.0
RUSTC_WRAPPER: tools/bin/sccache
steps:
- uses: actions/checkout@v1
- name: Prepare for restoring caches
run: |
rm -rf /home/runner/.rustup
rm -rf /home/runner/.cargo/git
rm -rf /home/runner/.cargo/registry
- name: Restore /home/runner/.rustup
uses: actions/cache@v1
with:
path: /home/runner/.rustup
key: rustup-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('rust-toolchain') }}
- name: Restore /home/runner/.cache/sccache
uses: actions/cache@v1
with:
path: /home/runner/.cache/sccache
key: sccache-[linux-cargo-test]-${{ runner.OS }}-s${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/tools/bin
uses: actions/cache@v1
with:
path: tools/bin
key: tools-bin-${{ runner.OS }}-[${{ env.RUST_TOOLCHAIN }}]-${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/.cargo/git
uses: actions/cache@v1
with:
path: /home/runner/.cargo/git
key: cargo-git-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Restore /home/runner/.cargo/registry
uses: actions/cache@v1
with:
path: /home/runner/.cargo/registry
key: cargo-registry-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Restore ./target
uses: actions/cache@v1
with:
path: target
key: cargo-build-target-${{ runner.OS }}-${{ hashFiles('**/Cargo.lock') }}
- name: Configure node
uses: actions/setup-node@v1
with:
node-version: "13.x"
- run: npm ci
- run: tools/bin/wasm-pack test --node -- --frozen --all-features --all-targets