diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b0f82d..a8792f4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,33 +2,12 @@ name: tests on: [push, pull_request] -env: - REGISTRY: ghcr.io/commaai - BUILD: docker buildx build --pull --load --cache-to type=inline --cache-from $REGISTRY/rednose:latest -t rednose -f Dockerfile . - RUN: docker run rednose bash -c - jobs: test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build docker image - run: eval ${{ env.BUILD }} - - name: Static analysis - run: ${{ env.RUN }} "git init && git add -A && pre-commit run --all" - - name: Unit Tests - run: ${{ env.RUN }} "pytest" - - docker_push: - name: docker push - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/rednose' + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Build Docker image - run: eval ${{ env.BUILD }} - - name: Push to dockerhub - run: | - docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} - docker tag rednose ${{ env.REGISTRY }}/rednose:latest - docker push ${{ env.REGISTRY }}/rednose:latest + - uses: actions/checkout@v7 + - run: ./test.sh diff --git a/.gitignore b/.gitignore index bf2b50d..5d38445 100644 --- a/.gitignore +++ b/.gitignore @@ -120,6 +120,7 @@ celerybeat.pid # Environments .env .venv +uv.lock env/ venv/ ENV/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index a28e00d..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,21 +0,0 @@ -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 - hooks: - - id: check-ast - - id: check-json - - id: check-xml - - id: check-yaml - - id: check-merge-conflict - - id: check-symlinks - - id: check-executables-have-shebangs - - id: check-shebang-scripts-are-executable -- repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.20.2 - hooks: - - id: mypy - additional_dependencies: ['numpy'] -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.2 - hooks: - - id: ruff diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 659435b..0000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM ubuntu:24.04 - -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y clang wget git autoconf libtool curl make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl python3-pip python3-dev - -WORKDIR /project - -ENV PYTHONPATH=/project - -COPY . . -RUN rm -rf .git -RUN pip3 install --break-system-packages --no-cache-dir '.[dev]' -RUN scons -c && scons -j$(nproc) diff --git a/SConstruct b/SConstruct index 50f5f78..7b8fa4e 100644 --- a/SConstruct +++ b/SConstruct @@ -1,4 +1,5 @@ import os +import platform import subprocess import sysconfig import numpy as np @@ -45,7 +46,7 @@ envCython = env.Clone() envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-cpp", "-Wno-shadow", "-Wno-deprecated-declarations"] envCython["LIBS"] = [] -if arch == "Darwin": +if platform.system() == "Darwin": envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"] elif arch == "aarch64": envCython["LINKFLAGS"] = ["-shared"] diff --git a/pyproject.toml b/pyproject.toml index be5ce3e..0c76d2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ dev = [ "pytest", "pytest-xdist", "ruff", - "pre-commit", + "mypy", ] [build-system] diff --git a/rednose/helpers/sympy_helpers.py b/rednose/helpers/sympy_helpers.py index 7f8813e..ca12130 100644 --- a/rednose/helpers/sympy_helpers.py +++ b/rednose/helpers/sympy_helpers.py @@ -145,7 +145,7 @@ def sympy_into_c(sympy_functions, global_vars=None): # add the output arguments for a in r.arguments: - if type(a) == codegen.OutputArgument: + if type(a) is codegen.OutputArgument: nargs.append(a) # assert len(r.arguments) == len(args)+1 diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..5529072 --- /dev/null +++ b/test.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -e + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +cd "$DIR" + +# *** env setup *** +if ! command -v uv >/dev/null; then + curl -LsSf https://astral.sh/uv/install.sh | sh + export PATH="$HOME/.local/bin:$PATH" +fi +uv sync --extra dev + +# *** build *** +uv run scons -j8 + +# *** lint + test *** +uv run ruff check . +uv run mypy --ignore-missing-imports . +uv run pytest + +# *** all done *** +GREEN='\033[0;32m' +NC='\033[0m' +printf "\n${GREEN}All good!${NC} Finished lint and test in ${SECONDS}s\n"