Skip to content

Add workflow for github pages #760

Add workflow for github pages

Add workflow for github pages #760

Workflow file for this run

name: ci
on:
pull_request:
branches:
- "*"
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cargo-cache.outputs.cache-primary-key }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: arduino/setup-protoc@v2
- name: Restore Cargo Cache
id: cargo-cache
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
# We can do this now because we use specific verison and update with Dependabot
# but if we make the deps any less specifc, we'll have to fix
key: ${{ runner.os }}-deps-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/*.rs') }}
# start from the previous set of cached dependencies
restore-keys: |
${{ runner.os }}-deps-${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-deps-
- name: Check
run: cargo check --workspace --tests --examples --benches
- name: Build
run: cargo build --workspace --tests --examples --benches
# Always update the cache
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save Cargo Cache
uses: actions/cache/save@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ steps.cargo-cache.outputs.cache-primary-key }}
lint:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- uses: arduino/setup-protoc@v2
- name: Restore Check Deps
id: cache-build-deps-restore
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ needs.build.outputs.cache-key }}
- name: Format
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy -- -D warnings
test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: arduino/setup-protoc@v2
- name: Restore Check Deps
id: cache-build-deps-restore
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ needs.build.outputs.cache-key }}
- name: Run tests
run: cargo test --verbose
examples:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: arduino/setup-protoc@v2
- name: Restore Check Deps
id: cache-build-deps-restore
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ needs.build.outputs.cache-key }}
# benchmarks were not being done in --release mode, we can enable this again later
# - name: Run benchmark example
# run: RUST_BACKTRACE=1 cargo run --example benchmark -- --nbatch 100 --batch-size 1000
- name: Run rev example
run: RUST_BACKTRACE=1 cargo run --example rev
docs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: arduino/setup-protoc@v2
- name: Restore Check Deps
id: cache-build-deps-restore
uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ needs.build.outputs.cache-key }}
- run: RUSTDOCFLAGS="-D warnings" cargo doc --all --document-private-items --no-deps
- run: |
git clean -f docs
echo "<meta http-equiv=\"refresh\" content=\"0; url=firewood\">" > target/doc/index.html
echo "copying documentation to doc..."
cp -r target/doc ./docs