Skip to content

CI

CI #534

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- master
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
schedule:
# Runs every Thursday at 20:23 GMT to avoid bit rot
- cron: "20 23 * * 4"
release:
types:
- edited
- published
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/cached-toolchain
id: toolchain
with:
toolchain: 'stable'
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target
key: test-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-toolchain-${{ steps.toolchain.outputs.cachekey }}
restore-keys: |
test-${{ runner.os }}-cargo-
- run: cargo test --all-features
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable, beta, nightly]
steps:
- uses: actions/checkout@v1
- uses: ./.github/actions/cached-toolchain
id: toolchain
with:
toolchain: ${{matrix.rust}}
- uses: actions/cache/restore@v3 # fetched cargo cache
id: cache-cargo-install-restore
with:
path: |
~/.cargo
key: build-tools-${{matrix.rust}}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-toolchain-${{ steps.toolchain.outputs.cachekey }}
restore-keys: |
build-tools-${{matrix.rust}}-${{ runner.os }}-cargo-
- name: Install wasm-pack
run:
cargo install --git https://github.com/mre/wasm-pack.git --branch first-class-bins
- name: Print wasm-pack version
run: wasm-pack --version
- name: Install trunk
run:
cargo install --locked trunk@0.17.2 # latest on 2023.07.24
- name: Print trunk version
run: trunk --version
- uses: actions/cache/save@v3 # saves cargo cache
with:
path: |
~/.cargo
key: ${{ steps.cache-cargo-install-restore.outputs.cache-primary-key }}
- uses: actions/cache@v3 # fetched cargo cache
id: cache-cargo-restore
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target
key: build-${{matrix.rust}}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-toolchain-${{ steps.toolchain.outputs.cachekey }}
restore-keys: |
build-${{matrix.rust}}-${{ runner.os }}-cargo-
- name: cargo fetch
run: cargo fetch --locked
- if: matrix.rust == 'stable'
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
- name: Build and install tinysearch
run: cargo install --force --path . --features=bin
continue-on-error: ${{ matrix.rust == 'nightly' }}
- name: Build WASM package from test index
run: RUST_LOG=debug tinysearch --engine-version 'path= "'$PWD'"' fixtures/index.json
continue-on-error: ${{ matrix.rust == 'nightly' }}
- name: Build examples
run:
for example in `ls -1 examples`; do
(cd "examples/$example" && trunk build index.html) || exit 1;
done
continue-on-error: ${{ matrix.rust == 'nightly' }}
- name: Audit for Security Vulnerabilities
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docs
uses: actions-rs/cargo@v1
with:
command: doc
args: --all-features --no-deps
publish:
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: Publish (dry run)
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
command: publish
args: --dry-run
- name: Publish
if: startsWith(github.ref, 'refs/tags/')
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
command: publish
- name: Create Github release for Linux, Windows, and macOS
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
prerelease: true
files: target/release/tinysearch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}