Skip to content

Commit

Permalink
Merge pull request #322 from 0xPolygonMiden/bitwalker/rust-toolchain
Browse files Browse the repository at this point in the history
chore: update rust toolchain and rework ci workflows
  • Loading branch information
bitwalker authored Sep 16, 2024
2 parents e3623ba + f0f56ac commit dfc7f84
Show file tree
Hide file tree
Showing 53 changed files with 5,455 additions and 5,384 deletions.
41 changes: 16 additions & 25 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,26 @@ on:
push:
branches:
- main
- develop
- next

jobs:
deploy:
publish_docs:
name: publish docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: 'latest'
- name: Install mdbook-katex
uses: actions-rs/cargo@v1
with:
command: install
args: mdbook-katex
- name: Install mdbook-linkcheck
uses: actions-rs/cargo@v1
with:
command: install
args: mdbook-linkcheck
- name: Build miden book
run: mdbook build docs/
- uses: actions/checkout@v4
- name: Install Rust
run: |
rustup update --no-self-update
rustc --version
- name: Install cargo-make
run: |
cargo install cargo-make --force
- name: Build
run: |
cargo make docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/book/html
publish_dir: ./target/docs/site
206 changes: 113 additions & 93 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,132 +4,152 @@ on:
push:
branches:
- main
- next
paths-ignore:
- "*.md"
- "*.txt"
- "docs"
pull_request:
paths-ignore:
- "*.md"

env:
CARGO_MAKE_TOOLCHAIN: nightly-2024-05-07
- "*.txt"
- "docs"

jobs:
compiler:
lint:
name: lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
override: true
run: |
rustup update --no-self-update
rustc --version
- name: Cache Cargo
uses: actions/cache@v2
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.CARGO_MAKE_TOOLCHAIN }}
# Use a common cache for the basic compilation/formatter/clippy checks
shared-key: ${{ github.workflow }}-shared
save-if: ${{ github.ref == 'refs/heads/next' }}
- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-make
- name: Build
uses: actions-rs/cargo@v1
with:
command: make
args: build
- name: Test
uses: actions-rs/cargo@v1
with:
command: make
args: test -E 'not package(cargo-miden)'
run: |
if ! cargo make --version 2>/dev/null; then
cargo install cargo-make --force
fi
- name: Clippy
run: |
cargo make clippy
cargo_miden_test_clean_env:
# Run cargo-miden test in the clean env to simulate user's first run.
# To test the installation of the required dependencies (e.g. rust-src, wasm target, etc.)
name: cargo-miden tests
check_format:
name: check formatting
runs-on: ubuntu-latest

# Run this job after the linter, so the cache is hot
needs: [lint]
# But run this check even if the lint check failed
if: ${{ always() }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
override: true
run: |
rustup update --no-self-update
rustc --version
- name: Cache Cargo
uses: actions/cache@v2
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.CARGO_MAKE_TOOLCHAIN }}
# Use a common cache for the basic compilation/formatter/clippy checks
shared-key: ${{ github.workflow }}-shared
# But do not save this cache, just use it
save-if: false
- name: Install cargo-make
uses: actions-rs/cargo@v1
run: |
if ! cargo make --version 2>/dev/null; then
cargo install cargo-make --force
fi
- name: Check Formatting
run: |
cargo make check-format
unit_tests:
name: midenc unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: |
rustup update --no-self-update
rustc --version
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
command: install
args: cargo-make
# NOTE: We use a different cache for the tests, so they can be run in parallel, but we
# also share the cache for the tests for efficiency
shared-key: ${{ github.workflow }}-shared-tests
save-if: ${{ github.ref == 'refs/heads/next' }}
- name: Install cargo-make
run: |
if ! cargo make --version 2>/dev/null; then
cargo install cargo-make --force
fi
- name: Check
# We run `cargo check` to verify that the workspace compiles correctly before attempting
# to execute the tests from each crate. This produces easier to read output if a compilation
# error occurs
run: |
cargo make check --tests
- name: Test
uses: actions-rs/cargo@v1
with:
command: make
args: test -E 'package(cargo-miden)'
run: |
cargo make test -E 'not (package(miden-integration-tests) or package(cargo-miden))'
clippy:
name: clippy
midenc_integration_tests:
name: midenc integration tests
runs-on: ubuntu-latest
# We only want to run the integration tests if the unit tests pass, and that has the added
# benefit that we can re-use the cache from the unit test job for all integration tests
needs: [unit_tests]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
override: true
run: |
rustup update --no-self-update
rustc --version
- name: Cache Cargo
uses: actions/cache@v2
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.CARGO_MAKE_TOOLCHAIN }}
shared-key: ${{ github.workflow }}-shared-tests
# Do not persist the cache, leave that to the unit tests, we just use the cache here
save-if: false
- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-make
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: make
args: clippy
run: |
if ! cargo make --version 2>/dev/null; then
cargo install cargo-make --force
fi
- name: Test
run: |
cargo make test -E 'package(miden-integration-tests)'
rustfmt:
name: rustfmt
cargo_miden_integration_tests:
name: cargo-miden integration tests
runs-on: ubuntu-latest
# We only want to run the integration tests if the unit tests pass, and that has the added
# benefit that we can re-use the cache from the unit test job for all integration tests
needs: [unit_tests]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
override: true
run: |
rustup update --no-self-update
rustc --version
- name: Cache Cargo
uses: actions/cache@v2
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.CARGO_MAKE_TOOLCHAIN }}
shared-key: ${{ github.workflow }}-shared-tests
# Do not persist the cache, leave that to the unit tests, we just use the cache here
save-if: false
- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-make
- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: make
args: check-format
run: |
if ! cargo make --version 2>/dev/null; then
cargo install cargo-make --force
fi
- name: Test
run: |
cargo make test -E 'package(cargo-miden)'
50 changes: 22 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Runs `release-plz release` only after the release PR (starts with `release-plz-`)
# is merged to the next branch. See `release_always = false` in `release-plz.toml`
# Runs `release-plz release` only after the release PR (starts with `release-plz-`)
# is merged to the next branch. See `release_always = false` in `release-plz.toml`
# Publishes any unpublished crates when.
# Does nothing if all crates are already published (i.e. have their versions on crates.io).
# Does not create/update release PRs.
# The crate version bumping and changelog generation is done via the `release-plz update` CLI command.
# Then manually create a release PR(starts with `release-plz-`) with the proposed changes and
# Then manually create a release PR(starts with `release-plz-`) with the proposed changes and
# when the PR is merged this action will publish the crates.
# See CONTRIBUTING.md for more details.

Expand All @@ -15,33 +15,27 @@ on:
branches:
- next

env:
CARGO_MAKE_TOOLCHAIN: nightly-2024-05-07

jobs:
release-plz:
name: release-plz
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
override: true
- name: Cache Cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ github.workflow }}-${{ github.job }}-toolchain-${{ env.CARGO_MAKE_TOOLCHAIN }}
- name: Publish Miden compiler crates
uses: MarcoIeni/release-plz-action@v0.5
with:
# Only run the `release` command that publishes any unpublished crates.
command: release
# `manifest_path` is omitted because it defaults to the root directory
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- uses: actions/checkout@v4
- name: Install Rust
run: |
rustup update --no-self-update
rustc --version
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/next' }}
- name: Publish
uses: MarcoIeni/release-plz-action@v0.5
with:
# Only run the `release` command that publishes any unpublished crates.
command: release
# `manifest_path` is omitted because it defaults to the root directory
# manifest_path: "..."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Loading

0 comments on commit dfc7f84

Please sign in to comment.