From 0b47e36f88f4a823aff86734bd8340d094cf6251 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Sun, 7 Jan 2024 08:48:22 +1100 Subject: [PATCH] Update build workflow --- .github/workflows/build.yml | 116 +++++++++++++++++++++++++++++------- 1 file changed, 96 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c3a66e1201e..172c4c8ea7cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,21 +36,11 @@ jobs: working-directory: ${{ github.workspace }} - name: Set up Rust tool-chain (Linux, Windows) stable - if: (runner.os == 'Linux') || (runner.os == 'Windows') uses: actions-rust-lang/setup-rust-toolchain@v1.5 with: toolchain: ${{ env.RUST_VERSION }} components: rustfmt, clippy - # Work around as actions-rust-lang does not seem to work on macOS yet - - name: Set up Rust tool-chain (macOS) stable - if: runner.os == 'macOS' - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_VERSION }} - override: true - components: rustfmt, clippy - - name: Set up Python environment uses: actions/setup-python@v4 with: @@ -97,26 +87,20 @@ jobs: # pre-commit run --hook-stage manual gitlint-ci pre-commit run --all-files - - name: Install Redis (macOS) - if: runner.os == 'macOS' - run: | - brew install redis - redis-server --daemonize yes - - name: Install Redis (Linux) if: runner.os == 'Linux' run: | sudo apt-get install redis-server redis-server --daemonize yes - - name: Run nautilus_core cargo tests (Linux, macOS) - if: (runner.os == 'Linux') || (runner.os == 'macOS') + - name: Run nautilus_core cargo tests (Linux) + if: runner.os == 'Linux' run: | cargo install cargo-nextest make cargo-test - - name: Run tests (Linux, macOS) - if: (runner.os == 'Linux') || (runner.os == 'macOS') + - name: Run tests (Linux) + if: runner.os == 'Linux' run: | make pytest make test-examples @@ -129,3 +113,95 @@ jobs: poetry run pytest --ignore=tests/performance_tests --new-first --failed-first env: PARALLEL_BUILD: false + + build-macos: + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/nightly' + strategy: + fail-fast: false + matrix: + arch: [x64] + os: [macos-latest] + python-version: ["3.10", "3.11", "3.12"] + defaults: + run: + shell: bash + name: build - Python ${{ matrix.python-version }} (${{ matrix.arch }} ${{ matrix.os }}) + runs-on: ${{ matrix.os }} + env: + BUILD_MODE: debug + RUST_BACKTRACE: 1 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Get Rust version from rust-toolchain.toml + id: rust-version + run: | + version=$(awk -F\" '/version/ {print $2}' nautilus_core/rust-toolchain.toml) + echo "Rust toolchain version $version" + echo "RUST_VERSION=$version" >> $GITHUB_ENV + working-directory: ${{ github.workspace }} + + # Work around as actions-rust-lang does not seem to work on macOS yet + - name: Set up Rust tool-chain (macOS) stable + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_VERSION }} + override: true + components: rustfmt, clippy + + - name: Set up Python environment + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Get Poetry version from poetry-version + run: | + version=$(cat poetry-version) + echo "POETRY_VERSION=$version" >> $GITHUB_ENV + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: ${{ env.POETRY_VERSION }} + + - name: Install build dependencies + run: python -m pip install --upgrade pip setuptools wheel pre-commit msgspec + + - name: Setup cached pre-commit + id: cached-pre-commit + uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: ${{ runner.os }}-${{ matrix.python-version }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Set poetry cache-dir + run: echo "POETRY_CACHE_DIR=$(poetry config cache-dir)" >> $GITHUB_ENV + + - name: Poetry cache + id: cached-poetry + uses: actions/cache@v3 + with: + path: ${{ env.POETRY_CACHE_DIR }} + key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }} + + - name: Run pre-commit + run: | + # pre-commit run --hook-stage manual gitlint-ci + pre-commit run --all-files + + - name: Install Redis (macOS) + run: | + brew install redis + redis-server --daemonize yes + + - name: Run nautilus_core cargo tests (macOS) + run: | + cargo install cargo-nextest + make cargo-test + + - name: Run tests (macOS) + run: | + make pytest + make test-examples