Run cargo check in CI in stable rust and msrv of the crate #123
Workflow file for this run
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: Development CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: {} | |
concurrency: | |
# on main, group = workflow-run_id | |
# on PR, group = workflow-PR_number | |
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number }} | |
cancel-in-progress: true | |
jobs: | |
ci: | |
runs-on: ${{ matrix.runner }} | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
matrix: | |
runner: [ubuntu-latest, macos-latest] | |
permissions: | |
contents: read | |
checks: write | |
steps: | |
############ Setup ############ | |
- name: Repo checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Rust toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: 1.77.0 | |
components: clippy | |
cache-workspaces: | |
./ | |
executorch-sys | |
examples/hello_world_add | |
examples/hello_world_add_no_std | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
cache: pip | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Python requirements | |
run: pip install -r scripts/requirements.txt | |
############ Install executorch deps ############ | |
- name: Cache Cpp ExecuTorch compiled libraries | |
id: cache-executorch-cpp-libs | |
uses: actions/cache@v4 | |
with: | |
path: executorch-sys/third-party/executorch/cmake-out | |
key: cache-executorch-cpp-libs-${{ runner.OS }}-${{ hashFiles('scripts/setup_dev.py') }} | |
- name: Setup dev env, install executorch and its deps | |
if: steps.cache-executorch-cpp-libs.outputs.cache-hit != 'true' | |
run: python scripts/setup_dev.py --skip-executorch-python | |
############ Build ############ | |
- name: Build executorch-sys | |
run: cargo build | |
working-directory: executorch-sys | |
- name: Build executorch | |
run: cargo build | |
working-directory: . | |
############ Linters ############ | |
- name: Clippy executorch-sys | |
uses: auguwu/clippy-action@1.4.0 | |
with: | |
working-directory: executorch-sys | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Clippy executorch | |
uses: auguwu/clippy-action@1.4.0 | |
with: | |
working-directory: . | |
token: ${{ secrets.GITHUB_TOKEN }} | |
############ Tests ############ | |
- name: Test executorch-sys | |
run: cargo test --all-features | |
working-directory: executorch-sys | |
- name: Test executorch | |
run: cargo test --all-features | |
working-directory: . | |
############ Examples ############ | |
- name: Run 'hello world add' example | |
# python export_model.py | |
run: cargo run | |
working-directory: examples/hello_world_add | |
- name: Run 'hello world add no_std' example | |
# python export_model.py | |
run: cargo run | |
working-directory: examples/hello_world_add_no_std | |
rust-version-check-clippy: | |
# check that we can build using different rust versions: | |
# - the minimal rust version that is specified by this crate | |
# - the latest stable version | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
rust-version: ["msrv", "stable"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Determine Rust version | |
id: rust-version | |
run: | | |
if [ "${{ matrix.rust-version }}" = "stable" ]; then | |
rust_version="stable" | |
else | |
cargo install toml-cli | |
rust_version=$(toml get Cargo.toml package.rust-version --raw) | |
fi | |
echo "Rust version: '$rust_version'" | |
echo "rust_version=$rust_version" >> "$GITHUB_OUTPUT" | |
- name: Install Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: ${{ steps.rust-version.outputs.rust_version }} | |
components: clippy | |
cache-workspaces: | |
./ | |
executorch-sys | |
examples/hello_world_add | |
examples/hello_world_add_no_std | |
- name: cargo check executorch | |
run: cargo check | |
working-directory: . | |
- name: cargo clippy executorch | |
uses: auguwu/clippy-action@1.4.0 | |
with: | |
working-directory: . | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: cargo check executorch-sys | |
run: cargo check | |
working-directory: executorch-sys | |
- name: cargo clippy executorch-sys | |
uses: auguwu/clippy-action@1.4.0 | |
with: | |
working-directory: executorch-sys | |
token: ${{ secrets.GITHUB_TOKEN }} |