Skip to content

Commit 0b7f644

Browse files
committed
test macos db tests
1 parent 6e9188f commit 0b7f644

File tree

3 files changed

+102
-3
lines changed

3 files changed

+102
-3
lines changed

.github/workflows/build_test.yml

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Testing Mac os runner docker
2+
3+
on:
4+
[push]
5+
jobs:
6+
build-macos:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
arch: [x64]
11+
os: [macos-latest]
12+
python-version: ["3.10", "3.11", "3.12"]
13+
defaults:
14+
run:
15+
shell: bash
16+
name: build - Python ${{ matrix.python-version }} (${{ matrix.arch }} ${{ matrix.os }})
17+
runs-on: ${{ matrix.os }}
18+
env:
19+
BUILD_MODE: debug
20+
RUST_BACKTRACE: 1
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
- name: Setup Docker on macOS
26+
uses: douglascamata/setup-docker-macos-action@v1-alpha
27+
28+
- name: Get Rust version from rust-toolchain.toml
29+
id: rust-version
30+
run: |
31+
version=$(awk -F\" '/version/ {print $2}' nautilus_core/rust-toolchain.toml)
32+
echo "Rust toolchain version $version"
33+
echo "RUST_VERSION=$version" >> $GITHUB_ENV
34+
working-directory: ${{ github.workspace }}
35+
36+
# Work around as actions-rust-lang does not seem to work on macOS yet
37+
- name: Set up Rust tool-chain (macOS) stable
38+
uses: actions-rs/toolchain@v1
39+
with:
40+
toolchain: ${{ env.RUST_VERSION }}
41+
override: true
42+
components: rustfmt, clippy
43+
44+
- name: Set up Python environment
45+
uses: actions/setup-python@v5
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
49+
- name: Get Python version
50+
run: |
51+
version=$(python -c "import sys; print('.'.join(map(str, sys.version_info[:3])))")
52+
echo "PYTHON_VERSION=$version" >> $GITHUB_ENV
53+
54+
- name: Get Poetry version from poetry-version
55+
run: |
56+
version=$(cat poetry-version)
57+
echo "POETRY_VERSION=$version" >> $GITHUB_ENV
58+
59+
- name: Install Poetry
60+
uses: snok/install-poetry@v1
61+
with:
62+
version: ${{ env.POETRY_VERSION }}
63+
64+
- name: Install build dependencies
65+
run: python -m pip install --upgrade pip setuptools wheel pre-commit msgspec
66+
67+
- name: Setup cached pre-commit
68+
id: cached-pre-commit
69+
uses: actions/cache@v4
70+
with:
71+
path: ~/.cache/pre-commit
72+
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
73+
74+
- name: Set poetry cache-dir
75+
run: echo "POETRY_CACHE_DIR=$(poetry config cache-dir)" >> $GITHUB_ENV
76+
77+
- name: Poetry cache
78+
id: cached-poetry
79+
uses: actions/cache@v4
80+
with:
81+
path: ${{ env.POETRY_CACHE_DIR }}
82+
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-poetry-${{ hashFiles('**/poetry.lock') }}
83+
84+
- name: Run pre-commit
85+
run: |
86+
# pre-commit run --hook-stage manual gitlint-ci
87+
pre-commit run --all-files
88+
89+
- name: Run services
90+
run: make start-services
91+
92+
- name: Run nautilus_core cargo tests (macOS)
93+
run: |
94+
cargo install cargo-nextest
95+
make cargo-test
96+
97+
- name: Run tests (macOS)
98+
run: |
99+
make pytest
100+
make test-examples

nautilus_core/infrastructure/tests/test_cache_database_postgres.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ pub async fn get_pg_cache_database() -> anyhow::Result<PostgresCacheDatabase> {
5757
}
5858

5959
#[cfg(test)]
60-
#[cfg(target_os = "linux")] // Databases only supported on Linux
61-
mod tests {
60+
#[cfg(any(target_os = "linux", target_os = "macos"))]
6261
use std::time::Duration;
6362

6463
use nautilus_model::{

tests/integration_tests/infrastructure/test_cache_database_postgres.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# - A Postgres service listening on the default port 5432
4242

4343
pytestmark = pytest.mark.skipif(
44-
sys.platform != "linux",
44+
sys.platform not in ["linux", "darwin"],
4545
reason="databases only supported on Linux",
4646
)
4747

0 commit comments

Comments
 (0)