add rust cache #225
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust build | |
on: [push, pull_request] | |
env: | |
CARGO_TERM_COLOR: always | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
fmt: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
components: rustfmt | |
- name: Check rust formatting (rustfmt) | |
run: cargo fmt --all -- --check | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Cache Cargo Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
cargo-${{ runner.os }}- | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
profile: minimal | |
- name: Install protc | |
run: sudo apt install -y protobuf-compiler libprotobuf-dev | |
- name: Install Mercurial | |
run: sudo apt-get install -y mercurial | |
- name: Set up IgH repo | |
run: | | |
hg clone http://hg.code.sf.net/p/etherlabmaster/code ethercat-hg | |
cd ethercat-hg | |
hg update stable-1.5 | |
./bootstrap | |
./configure --disable-8139too | |
- name: Build | |
run: ETHERCAT_PATH=$(pwd)/ethercat-hg RUST_BACKTRACE=full cargo build --release | |
- name: Build Docs | |
run: | | |
ETHERCAT_PATH=$(pwd)/ethercat-hg RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --no-deps --workspace --lib | |
ETHERCAT_PATH=$(pwd)/ethercat-hg RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --no-deps --package python_client | |
mv target/doc docs/api | |
- name: Upload Rust Docs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rust-docs | |
path: docs/api | |
retention-days: 1 # Keep for 5 days | |
docs: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download Rust Docs | |
uses: actions/download-artifact@v4 | |
with: | |
name: rust-docs | |
path: docs/api | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install MkDocs and dependencies | |
run: | | |
cd docs | |
pip install -r requirements.txt | |
- name: Build MkDocs site | |
run: | | |
mkdocs build --site-dir site | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: site | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: docs | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |