Skip to content

Commit

Permalink
no cmake, no protoc, no problems (#256)
Browse files Browse the repository at this point in the history
* Simplify setup and build by removing reliance on `cmake` and `protoc`
* [Fixes `Cargo.lock` issue](https://trunk-io.slack.com/archives/C02CMS4TFUJ/p1734464030801369) seen in `context-ruby`
* Fix running Clippy
* Fix running `rust-analyzer`
* Fix `cargo check` lints
* Fix imports of dependencies with inconsistent versions
  • Loading branch information
dfrankland authored Dec 30, 2024
1 parent 107654f commit 9dfffcf
Show file tree
Hide file tree
Showing 19 changed files with 265 additions and 324 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ use_trunk.io() {
}

use trunk.io

# Needed by `rust-analyzer`. Hash should be the same for all platforms.
export RUST_SRC_PATH="$HOME/.cache/trunk/tools/rust-src/2024-05-01-d4daa7f4db5f9d74e00218df573de113/rust-src-nightly/rust-src/lib/rustlib/src/rust/library"
10 changes: 0 additions & 10 deletions .github/actions/setup_rust_cargo/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ runs:
with:
targets: wasm32-unknown-unknown

- name: Install protoc
shell: bash
run: |
if [ -f /opt/homebrew/bin/brew ]; then
/opt/homebrew/bin/brew install protobuf
elif [ -f /usr/bin/apt ]; then
sudo /usr/bin/apt update
sudo /usr/bin/apt install -y protobuf-compiler
fi
- uses: actions/cache@v4
with:
path: |
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/pyo3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ jobs:
/usr/bin/apt update
/usr/bin/apt install -y pkg-config libssl-dev unzip
fi
if [ "$(uname -m)" == "aarch64" ]; then
curl -L https://github.com/protocolbuffers/protobuf/releases/download/v29.1/protoc-29.1-linux-aarch_64.zip -o protoc.zip
unzip protoc.zip
export PROTOC=$(pwd)/bin/protoc
else
curl -L https://github.com/protocolbuffers/protobuf/releases/download/v29.1/protoc-29.1-linux-x86_64.zip -o protoc.zip
unzip protoc.zip
export PROTOC=$(pwd)/bin/protoc
fi
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
Expand Down
79 changes: 55 additions & 24 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ runtimes:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- rust@2024-05-01
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
Expand All @@ -24,15 +24,15 @@ lint:
- [email protected]
- [email protected]
- [email protected]
- clippy@1.81.0
- clippy@2024-05-01
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- rustfmt@1.81.0
- rustfmt@2024-05-01
- [email protected]
- [email protected]
- [email protected]
Expand All @@ -48,9 +48,43 @@ lint:
run: pyright -p context-py --outputjson
target: .
batch: false
- name: clippy
runtime: rust
environment:
- name: PATH
list: ["${runtime}", "${env.PATH}"]
commands:
- name: lint
run:
cargo clippy --message-format json --locked --all-targets --all-features --
--cap-lints=warn --no-deps
output: clippy
target: ${parent_with(Cargo.toml)}
success_codes: [0, 101, 383]
run_from: ${target_directory}
disable_upstream: true
- name: rustfmt
runtime: rust
commands:
- name: format
output: rewrite
read_output_from: stdout
stdin: true
success_codes: [0]
cache_results: false # sometimes caches an empty file for some reason
in_place: false
batch: false
run: rustfmt --edition=2021
ignore:
- linters: [ALL]
paths:
# Ignore generated files
- target/**
- "**/target/**"
actions:
definitions:
- id: generate-pyi
runtime: rust
description: Generate Python stubs
# Don't use hermetic runtime so we can use nightly cargo
run: |
Expand All @@ -63,36 +97,33 @@ actions:
- trunk-fmt-pre-commit
- trunk-upgrade-available
downloads:
- name: protoc
- name: rust
downloads:
- os:
linux: linux
macos: osx
macos: apple-darwin
linux: unknown-linux-gnu
cpu:
x86_64: x86_64
arm_64: aarch_64
url: https://github.com/protocolbuffers/protobuf/releases/download/v${version}/protoc-${version}-${os}-${cpu}.zip
- os:
windows: windows
cpu:
x86_64: x86_64
url: https://github.com/protocolbuffers/protobuf/releases/download/v29.1/protoc-29.1-win64.zip
arm_64: aarch64
url: https://static.rust-lang.org/dist/${version}/rust-nightly-${cpu}-${os}.tar.gz
strip_components: 2
- name: rust-src
downloads:
- url: https://static.rust-lang.org/dist/${version}/rust-src-nightly.tar.xz
tools:
definitions:
- name: protoc
download: protoc
known_good_version: 29.1
shims: [protoc]
environment:
- name: PATH
list: ["${tool}/bin"]
health_checks:
- command: protoc --version
parse_regex: libprotoc (\d+\.\d+)
- name: rust-src
download: rust-src
known_good_version: 2024-05-01
shims: [rust-src]
runtimes:
- ruby
- node
- rust
enabled:
- [email protected]
- [email protected]
- [email protected]
# Update `RUST_SRC_PATH` path to `rust-src` if this is updated
# IfChange
- rust-src@2024-05-01
# ThenChange .envrc
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ These are instructions for building, running, and testing the Rust CLI locally.
## Prerequisites

- Install a nightly version of Cargo using [rustup](https://doc.rust-lang.org/cargo/getting-started/installation.html)
- Install [protoc](https://grpc.io/docs/protoc-installation/)
- Run `trunk tools install`

### Optional Prerequisites
Expand Down
Loading

0 comments on commit 9dfffcf

Please sign in to comment.