-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lint, build, and test commands to
justfile
, add fmt and clippy …
…to CI workflow (#59) ## Problem @haruska had some good feedback around adding explicit `build`, `test`, and `lint` commands to the `justfile` in the repo. Currently there are only commands for dealing with code generation which is a little confusing. Additionally, we haven't run `cargo fmt` and `cargo clippy` on the codebase yet, and have nothing enforcing its use. ## Solution - Refactor`justfile`: move all code generation under `gen-*` commands, add `build`, `test`, `lint`, and `update` commands to the file. - Update `ci.yaml` workflow to support both fmt and clippy. Reject if running either leads to issues. - Code changes for fmt and clippy. **Note:** At the moment I've added `#![allow(clippy::enum_variant_names)]` and `#![allow(clippy::empty_docs)]` to the `src/openapi/mod.rs` file. There were some clippy issues in the generated code, and since we still need to refactor the entire generation flow in this repo, I just stuck the allow tags on top for now. ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [X] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan Make sure CI passes.
- Loading branch information
1 parent
2415031
commit 2ccc8c1
Showing
39 changed files
with
466 additions
and
409 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,55 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: {} | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: {} | ||
pull_request: {} | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
rust: [stable] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: hecrj/setup-rust-action@v2 | ||
with: | ||
rust-version: ${{ matrix.rust }} | ||
- name: Install protoc | ||
uses: arduino/setup-protoc@v3 | ||
- name: Build SDK | ||
run: cargo build | ||
- name: Build documentation | ||
run: cargo doc --no-deps | ||
- name: Run tests | ||
env: | ||
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} | ||
SERVERLESS_INDEX_NAME: ${{ secrets.SERVERLESS_INDEX_NAME }} | ||
POD_INDEX_NAME: ${{ secrets.POD_INDEX_NAME }} | ||
COLLECTION_NAME: ${{ secrets.COLLECTION_NAME }} | ||
run: cargo test --verbose | ||
test: | ||
name: Test | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
rust: [stable] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: hecrj/setup-rust-action@v2 | ||
with: | ||
rust-version: ${{ matrix.rust }} | ||
- name: Install protoc | ||
uses: arduino/setup-protoc@v3 | ||
- name: Build SDK | ||
run: cargo build | ||
- name: Build documentation | ||
run: cargo doc --no-deps | ||
- name: Run tests | ||
env: | ||
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} | ||
SERVERLESS_INDEX_NAME: ${{ secrets.SERVERLESS_INDEX_NAME }} | ||
POD_INDEX_NAME: ${{ secrets.POD_INDEX_NAME }} | ||
COLLECTION_NAME: ${{ secrets.COLLECTION_NAME }} | ||
run: cargo test --verbose | ||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
components: rustfmt | ||
- name: Enforce formatting | ||
run: cargo fmt --check | ||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
components: clippy | ||
- name: Run clippy | ||
run: cargo clippy -- -D warnings |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
api_version := "2024-07" | ||
|
||
# Generate version file | ||
generate-version: | ||
echo "/// Pinecone API version\npub const API_VERSION: &str = \"{{api_version}}\";" > src/version.rs | ||
# Lint files and run tests with optional specific test cases | ||
test *tests: lint | ||
# Runs the specified tests, or all tests if none specified | ||
cargo test {{tests}} --verbose | ||
|
||
# Update git submodules recursively | ||
update: | ||
git submodule update --init --recursive | ||
|
||
# Run linting tools (cargo fmt and clippy) | ||
lint: | ||
cargo fmt && cargo clippy | ||
|
||
# Build the OpenAPI and Protobuf definitions in `codegen/apis` | ||
build-apis: | ||
# Run cargo build | ||
build: | ||
cargo build | ||
|
||
# Build the OpenAPI and Protobuf definitions in the `codegen/apis` submodule | ||
gen-build-submodule-apis: | ||
cd codegen/apis && just build | ||
|
||
# Generate the control plane OpenAPI code based on the yaml files in `codegen/apis/_build` | ||
build-openapi: build-apis generate-version | ||
gen-openapi: gen-build-submodule-apis gen-version_file | ||
./codegen/build-oas.sh {{api_version}} | ||
|
||
# Generate the data plane protobuf code based on the yaml files in `codegen/apis/_build` | ||
build-proto: build-apis generate-version | ||
gen-proto: gen-build-submodule-apis gen-version_file | ||
./codegen/build-proto.sh {{api_version}} | ||
|
||
# Generate all OpenAPI and protobuf code | ||
build-client: build-apis generate-version | ||
gen-client: gen-build-submodule-apis gen-version_file | ||
./codegen/build-oas.sh {{api_version}} | ||
./codegen/build-proto.sh {{api_version}} | ||
|
||
# Generate version file | ||
gen-version_file: | ||
echo "/// Pinecone API version\npub const API_VERSION: &str = \"{{api_version}}\";" > src/version.rs |
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
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
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
Oops, something went wrong.