Skip to content

Commit

Permalink
Merge pull request #311 from systemaccounting/310-types-crate-unit-tests
Browse files Browse the repository at this point in the history
310 rust types crate unit tests
  • Loading branch information
mxfactorial authored Nov 2, 2023
2 parents fc7a277 + 53c27be commit d4ad74f
Show file tree
Hide file tree
Showing 16 changed files with 620 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM mcr.microsoft.com/devcontainers/universal:2
ARG TF_VERSION=1.2.7
ARG MIGRATE_VERSION=4.15.2
ARG WATCH_VERSION=8.4.0
ARG TARPAULIN_VERSION=0.27.1

RUN go install github.com/99designs/gqlgen@latest && \
go install github.com/golang/mock/mockgen@latest && \
Expand All @@ -20,6 +21,10 @@ RUN go install github.com/99designs/gqlgen@latest && \
tar -xf cargo-watch-v${WATCH_VERSION}-x86_64-unknown-linux-gnu.tar.xz && \
sudo mv cargo-watch-v${WATCH_VERSION}-x86_64-unknown-linux-gnu/cargo-watch /usr/local/bin && \
rm -rf cargo-watch-v${WATCH_VERSION}-x86_64-unknown-linux-gnu* && \
wget https://github.com/xd009642/tarpaulin/releases/download/${TARPAULIN_VERSION}/cargo-tarpaulin-x86_64-unknown-linux-gnu.tar.gz && \
tar -xf cargo-tarpaulin-x86_64-unknown-linux-gnu.tar.gz && \
sudo mv cargo-tarpaulin /usr/local/bin && \
rm -rf cargo-tarpaulin* && \
npm install -g eslint && \
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - && \
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/dev-crates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: dev-crates

on:
push:
paths:
- 'crates/**'
branches-ignore:
- 'master'

jobs:
test:
name: crates
runs-on: ubuntu-latest
container:
image: xd009642/tarpaulin:develop-nightly
options: --security-opt seccomp=unconfined
env:
CI: true
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rustfmt
- uses: taiki-e/install-action@nextest
- name: crates/types lint
run: |
cargo fmt -- --check
cargo clippy -- -Dwarnings
working-directory: crates/types
- name: crates/types unit tests and coverage report
run: cargo tarpaulin --fail-under 95
working-directory: crates/types
10 changes: 5 additions & 5 deletions .github/workflows/dev-rule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
test:
name: rule
runs-on: ubuntu-latest
container:
image: xd009642/tarpaulin:develop-nightly
options: --security-opt seccomp=unconfined
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
CI: true
steps:
- uses: actions/checkout@v3
Expand All @@ -28,5 +28,5 @@ jobs:
run: |
cargo fmt -- --check
cargo clippy -- -Dwarnings
- name: unit tests
run: cargo test
- name: unit tests and coverage
run: cargo tarpaulin
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ migrations/dumps/*.sql

# rust
/target/
**/*.profraw

# vscode
test/thunder-tests/thunderActivity.json
108 changes: 96 additions & 12 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"

members = [
"services/rule",
Expand Down
21 changes: 15 additions & 6 deletions crates/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ edition = "2021"
[dependencies]
chrono = "0.4.23"
postgres-protocol = "0.6.4"
postgres-types = {version = "0.2.4", features = ["derive", "array-impls", "with-chrono-0_4"]}
serde = {version = "1.0.152", features = [ "derive" ]}
postgres-types = { version = "0.2.4", features = [
"derive",
"array-impls",
"with-chrono-0_4",
] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
serde_with = {version = "2.2.0", features = ["chrono_0_4"]}
strum = {version = "0.24.1", features = ["derive"]}
serde_with = { version = "2.2.0", features = ["chrono_0_4"] }
strum = { version = "0.24.1", features = ["derive"] }
strum_macros = "0.24.3"
tokio-postgres = {version = "0.7.7", features = ["with-chrono-0_4"]}
async-trait = "0.1.73"
tokio-postgres = { version = "0.7.7", features = ["with-chrono-0_4"] }
async-trait = "0.1.73"

[dev-dependencies]
bytes = "1.0"
time = { version = "0.3.30", features = ["formatting", "parsing"]}
serde_assert = "0.5.0"
Loading

0 comments on commit d4ad74f

Please sign in to comment.