Skip to content

Commit

Permalink
Add Rust checks to Makefile and CircleCI
Browse files Browse the repository at this point in the history
These lint and test solely the Rust code (no Python). The following
tools are enabled:

* rustfmt: code formatting (like black)
* clippy: linting (like flake8+pylint+mypy)
* cargo test: Rust test suite

Running maturin to verify the Python integration will happen in the next
commit, when it's hooked into the development environment.

Refs #6814.
  • Loading branch information
legoktm committed Jun 2, 2023
1 parent c0401df commit 40d0efe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ jobs:
DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-focal-py3:${fromtag:-latest}" securedrop/bin/dev-shell \
bash -c "/opt/venvs/securedrop-app-code/bin/pip3 install --require-hashes -r requirements/python3/develop-requirements.txt && make -C .. lint"
rust:
# Keep version in sync with rust-toolchain.toml
docker:
- image: rust:1.69.0
steps:
- checkout
- run:
name: Install dependencies
command: |
apt-get update && apt-get install make --yes
rustup component add rustfmt
rustup component add clippy
- run:
name: Lint and test Rust code
command: |
make rust-lint
make rust-test
app-tests:
machine:
image: ubuntu-2004:202010-01
Expand Down Expand Up @@ -357,6 +375,10 @@ workflows:
context:
- circleci-slack
<<: *slack-fail-post-step
- rust:
context:
- circleci-slack
<<: *slack-fail-post-step
- app-tests:
filters:
branches:
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ html-lint: ## Validate HTML in web application template files.
securedrop/source_templates/*.html securedrop/journalist_templates/*.html
@echo

.PHONY: rust-lint
rust-lint: ## Lint Rust code
@echo "███ Linting Rust code..."
cargo fmt --check
cargo clippy

.PHONY: shellcheck
shellcheck: ## Lint shell scripts.
@echo "███ Linting shell scripts..."
Expand Down Expand Up @@ -282,6 +288,11 @@ test: ## Run the test suite in a Docker container.
.PHONY: test-focal
test-focal: test

.PHONY: rust-test
rust-test:
@echo "███ Running Rust tests..."
cargo test

.PHONY: validate-test-html
validate-test-html:
@echo "███ Validating HTML source from $(shell find securedrop/tests/functional/pageslayout/html -name "*.html" | wc -l | xargs echo -n) page-layout test(s)"
Expand Down

0 comments on commit 40d0efe

Please sign in to comment.