Skip to content

Add unit tests #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/ci-executors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: executors Tests

on:
push:
branches: [main]
paths:
- "executors/**"
- "aa-types/**"
- "core/**"
- "aa-core/**"
- "twmq/**"
pull_request:
branches: [main]
paths:
- "executors/**"
- "aa-types/**"
- "core/**"
- "aa-core/**"
- "twmq/**"
workflow_dispatch: # Allow manual triggering for testing (optional)

env:
CARGO_TERM_COLOR: always

jobs:
test:
runs-on: ubuntu-latest

services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Give GitHub Actions access to @thirdweb-dev/vault
uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd #@v0.9.1
with:
ssh-private-key: ${{ secrets.VAULT_REPO_DEPLOY_KEY }}

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #checkout@v4

- name: Install CI dependencies
uses: taiki-e/install-action@ab3728c7ba6948b9b429627f4d55a68842b27f18
with:
tool: cargo-nextest

- name: Cache
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-executors-${{ hashFiles('**/Cargo.lock') }}

- name: Build
run: cargo build -p engine-executors --verbose

- name: Run tests
run: cargo nextest run -p engine-executors --profile ci

- name: Test Report
uses: dorny/test-reporter@6e6a65b7a0bd2c9197df7d0ae36ac5cee784230c # @v2
if: success() || failure() # run this step even if previous step failed
with:
name: Executors Tests # Name of the check run which will be created
path: target/nextest/ci/junit.xml # Path to test results
reporter: java-junit # Format of test results
83 changes: 83 additions & 0 deletions .github/workflows/coverage-executors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: executors Coverage

on:
push:
branches: [main]
paths:
- "executors/**"
- "aa-types/**"
- "core/**"
- "aa-core/**"
- "twmq/**"
pull_request:
branches: [main]
paths:
- "executors/**"
- "aa-types/**"
- "core/**"
- "aa-core/**"
- "twmq/**"
workflow_dispatch: # Allow manual triggering for testing (optional)

env:
CARGO_TERM_COLOR: always

jobs:
coverage:
runs-on: ubuntu-latest

services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Give GitHub Actions access to @thirdweb-dev/vault
uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd #@v0.9.1
with:
ssh-private-key: ${{ secrets.VAULT_REPO_DEPLOY_KEY }}

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #checkout@v4

- name: Install CI dependencies
uses: taiki-e/install-action@ab3728c7ba6948b9b429627f4d55a68842b27f18
with:
tool: cargo-tarpaulin

- name: Cache
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-tarpaulin-executors-${{ hashFiles('**/Cargo.lock') }}

# Run coverage with tarpaulin
- name: Run coverage
run: cargo tarpaulin -p engine-executors --skip-clean --out Xml --out Html --output-dir coverage --exclude-files "aa-core/*" --exclude-files "core/*" --exclude-files "server/*" --exclude-files "thirdweb-core/*" --exclude-files "twmq/*"

# Archive coverage reports as artifacts
- name: Archive code coverage results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # @4.6.2
with:
name: executors-code-coverage-report
path: coverage/

- name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # @v1.3.0
with:
filename: coverage/cobertura.xml
format: markdown
output: both

- name: Add Coverage Summary to Job Summary
# This step reads the generated markdown file and appends it to the
# special GITHUB_STEP_SUMMARY file, which populates the job summary page.
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
9 changes: 9 additions & 0 deletions executors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ engine-aa-core = { version = "0.1.0", path = "../aa-core" }
rand = "0.9.1"
uuid = { version = "1.17.0", features = ["v4"] }
chrono = "0.4.41"

[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
mockall = "0.14.0"
wiremock = "0.6.2"
redis = { version = "0.27.5", features = ["tokio-comp"] }
testcontainers = "0.23.1"
testcontainers-modules = { version = "0.11.4", features = ["redis"] }
tracing-test = "0.2.5"
Loading
Loading