Skip to content

Commit

Permalink
Contribute Rust template to engineering domains
Browse files Browse the repository at this point in the history
  • Loading branch information
emanguy authored and mikewolfd committed Apr 4, 2024
1 parent 667f85d commit 42cc407
Show file tree
Hide file tree
Showing 49 changed files with 8,588 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ The development practice has a suite of language-specific templates for developi
Here are the language templates that are currently available:

* [Go](https://github.com/FearlessSolutions/engineering-practice-domains/tree/main/practices/development/examples/go-microservice-monorepo)
* [Rust](https://github.com/FearlessSolutions/engineering-practice-domains/tree/main/practices/development/examples/rust-microservice-template)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[registries.crates-io]
protocol = "sparse"
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
version: 2.1

orbs:
rust: circleci/[email protected]

commands:
rust_build:
parameters:
cache_bust_version:
type: string
default: v1
steps:
- restore_cache:
keys:
- debug-compile
- run:
name: Build code
command: cargo build
- save_cache:
key: debug-compile-{{ checksum "Cargo.lock" }}-<< parameters.cache_bust_version >>
paths:
- target/debug
- ~/.cargo

jobs:
build-and-test:
docker:
- image: ghcr.io/emanguy/rust-ci:1.75-v1.1.0
- image: postgres:14-alpine
name: test-db
environment:
POSTGRES_PASSWORD: sample123
environment:
# This is needed for sqlx to verify queries
DATABASE_URL: "postgresql://postgres:sample123@test-db:5432"
# This is needed for the integration tests to actually connect to the database
TEST_DB_URL: "postgresql://postgres:sample123@test-db:5432"
DB_TABLE_URL: "postgresql://postgres:sample123@test-db:5432/postgres"
steps:
- checkout
- run:
name: Provision database
command: |
until psql -f postgres-scripts/postgres-setup.sql $DB_TABLE_URL
do
echo "Trying again in a few seconds..."
sleep 5
done
echo "Migrations complete!"
- rust_build
- run:
name: "Run tests"
command: cargo test --features integration_test

validate-quality:
docker:
- image: ghcr.io/emanguy/rust-ci:1.75-v1.1.0
environment:
SQLX_OFFLINE: "true"
steps:
- checkout
- rust/clippy:
flags: --tests --features integration_test -- -D warnings
- run:
name: "Validate formatting"
command: cargo fmt --check

workflows:
standard:
jobs:
- build-and-test
- validate-quality
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DATABASE_URL=postgres://postgres:[email protected]/postgres
TEST_DB_URL=postgres://postgres:[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
.idea

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 42cc407

Please sign in to comment.