From d7afb2bdf9dfb8a2da815213bafbd195012cd304 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Mon, 29 Jul 2024 19:21:03 -0700 Subject: [PATCH] Trying to let the Windows runners find MSVC Signed-off-by: Scott Wilson --- .github/workflows/codeql_c.yml | 25 +------- .github/workflows/codeql_cpp.yml | 25 +------- .github/workflows/test_suite_c.yml | 46 +++----------- .github/workflows/test_suite_cpp.yml | 48 +++------------ .github/workflows/test_suite_python.yml | 15 ----- bindings/python/Makefile | 81 ------------------------- scripts/install_package.py | 26 ++++++++ 7 files changed, 45 insertions(+), 221 deletions(-) delete mode 100644 bindings/python/Makefile create mode 100644 scripts/install_package.py diff --git a/.github/workflows/codeql_c.yml b/.github/workflows/codeql_c.yml index 30d3445..bd20560 100644 --- a/.github/workflows/codeql_c.yml +++ b/.github/workflows/codeql_c.yml @@ -45,7 +45,6 @@ jobs: defaults: run: working-directory: bindings/c - shell: bash runs-on: ubuntu-latest permissions: actions: read @@ -78,29 +77,9 @@ jobs: with: python-version: 3 cache: 'pip' - - name: Cache virtualenv - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version}}-${{ hashFiles('pyproject.toml') }} - path: .venv - - name: Setup virtual environment - run: | - python -m venv .venv - source .venv/bin/activate - name: Install ninja - run: | - python -m venv .venv - - if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt-get install ninja-build - elif [ "$RUNNER_OS" == "Windows" ]; then - choco install ninja - elif [ "$RUNNER_OS" == "macOS" ]; then - brew install ninja - else - echo "$RUNNER_OS not supported" - exit 1 - fi + working-directory: 'scripts' + run: python install_package.py ninja - name: Install meson run: python -m pip install .[build] - name: Meson Setup diff --git a/.github/workflows/codeql_cpp.yml b/.github/workflows/codeql_cpp.yml index 6871f75..6af9711 100644 --- a/.github/workflows/codeql_cpp.yml +++ b/.github/workflows/codeql_cpp.yml @@ -45,7 +45,6 @@ jobs: defaults: run: working-directory: bindings/cpp - shell: bash runs-on: ubuntu-latest permissions: actions: read @@ -78,29 +77,9 @@ jobs: with: python-version: 3 cache: 'pip' - - name: Cache virtualenv - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version}}-${{ hashFiles('pyproject.toml') }} - path: .venv - - name: Setup virtual environment - run: | - python -m venv .venv - source .venv/bin/activate - name: Install ninja - run: | - python -m venv .venv - - if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt-get install ninja-build - elif [ "$RUNNER_OS" == "Windows" ]; then - choco install ninja - elif [ "$RUNNER_OS" == "macOS" ]; then - brew install ninja - else - echo "$RUNNER_OS not supported" - exit 1 - fi + working-directory: 'scripts' + run: python install_package.py ninja - name: Install meson run: python -m pip install .[build] - name: Meson Setup diff --git a/.github/workflows/test_suite_c.yml b/.github/workflows/test_suite_c.yml index 301fd62..14f89fa 100644 --- a/.github/workflows/test_suite_c.yml +++ b/.github/workflows/test_suite_c.yml @@ -30,7 +30,6 @@ jobs: defaults: run: working-directory: bindings/c - shell: bash strategy: matrix: os: @@ -64,43 +63,13 @@ jobs: with: python-version: 3 cache: 'pip' - - name: Cache virtualenv - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version}}-${{ hashFiles('pyproject.toml') }} - path: .venv - - name: Setup virtual environment - run: | - python -m venv .venv - - if [ "$RUNNER_OS" == "Windows" ]; then - source .venv/Scripts/activate - else - source .venv/bin/activate - fi - name: Install ninja - run: | - python -m venv .venv - - if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt-get install ninja-build - elif [ "$RUNNER_OS" == "Windows" ]; then - choco install ninja - elif [ "$RUNNER_OS" == "macOS" ]; then - brew install ninja - else - echo "$RUNNER_OS not supported" - exit 1 - fi + working-directory: 'scripts' + run: python install_package.py ninja - name: Install meson run: python -m pip install .[build] - name: Meson Setup - run: | - if [ "$RUNNER_OS" == "Windows" ]; then - CC=cl CXX=cl meson setup build -Dtests=true -Db_coverage=true - else - meson setup build -Dtests=true -Db_coverage=true - fi + run: meson setup build -Dtests=true -Db_coverage=true - name: Meson Compile working-directory: bindings/c/build run: | @@ -120,13 +89,12 @@ jobs: valgrind -v --leak-check=full --show-leak-kinds=all tests/test_result valgrind -v --leak-check=full --show-leak-kinds=all tests/test_runner valgrind -v --leak-check=full --show-leak-kinds=all tests/test_status + - name: Install LCov + working-directory: '.' + run: python install_package.py lcov - name: Run LCov working-directory: bindings/c/build - if: ${{ matrix.os == 'ubuntu-latest' }} - run: | - sudo apt update - sudo apt install -y lcov - lcov -c -d . -o coverage.info + run: lcov -c -d . -o coverage.info - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 with: flags: lang-c diff --git a/.github/workflows/test_suite_cpp.yml b/.github/workflows/test_suite_cpp.yml index 7632497..f71406b 100644 --- a/.github/workflows/test_suite_cpp.yml +++ b/.github/workflows/test_suite_cpp.yml @@ -30,7 +30,6 @@ jobs: defaults: run: working-directory: bindings/cpp - shell: bash strategy: matrix: os: @@ -57,43 +56,13 @@ jobs: with: python-version: 3 cache: 'pip' - - name: Cache virtualenv - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version}}-${{ hashFiles('pyproject.toml') }} - path: .venv - - name: Setup virtual environment - run: | - python -m venv .venv - - if [ "$RUNNER_OS" == "Windows" ]; then - source .venv/Scripts/activate - else - source .venv/bin/activate - fi - name: Install ninja - run: | - python -m venv .venv - - if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt-get install ninja-build - elif [ "$RUNNER_OS" == "Windows" ]; then - choco install ninja - elif [ "$RUNNER_OS" == "macOS" ]; then - brew install ninja - else - echo "$RUNNER_OS not supported" - exit 1 - fi + working-directory: 'scripts' + run: python install_package.py ninja - name: Install meson run: python -m pip install .[build] - name: Meson Setup - run: | - if [ "$RUNNER_OS" == "Windows" ]; then - CC=cl CXX=cl meson setup build -Dtests=true -Db_coverage=true - else - meson setup build -Dtests=true -Db_coverage=true - fi + run: meson setup build -Dtests=true -Db_coverage=true - name: Meson Compile working-directory: bindings/cpp/build run: | @@ -112,13 +81,12 @@ jobs: valgrind -v --leak-check=full --show-leak-kinds=all tests/test_result valgrind -v --leak-check=full --show-leak-kinds=all tests/test_runner valgrind -v --leak-check=full --show-leak-kinds=all tests/test_status + - name: Install LCov + working-directory: '.' + run: python install_package.py lcov - name: Run LCov - working-directory: bindings/cpp/build - if: ${{ matrix.os == 'ubuntu-latest' }} - run: | - sudo apt update - sudo apt install -y lcov - lcov -c -d . -o coverage.info + working-directory: bindings/c/build + run: lcov -c -d . -o coverage.info - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 with: flags: lang-cpp diff --git a/.github/workflows/test_suite_python.yml b/.github/workflows/test_suite_python.yml index 08e6221..841f98a 100644 --- a/.github/workflows/test_suite_python.yml +++ b/.github/workflows/test_suite_python.yml @@ -30,7 +30,6 @@ jobs: defaults: run: working-directory: bindings/python - shell: bash strategy: matrix: os: @@ -74,20 +73,6 @@ jobs: with: python-version: ${{matrix.python-version}} cache: 'pip' - - name: Cache virtualenv - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version}}-${{ hashFiles('pyproject.toml') }} - path: .venv - - name: Setup virtual environment - run: | - python -m venv .venv - - if [ "$RUNNER_OS" == "Windows" ]; then - source .venv/Scripts/activate - else - source .venv/bin/activate - fi - name: Install dependencies run: python -m pip install .[test] - name: Lint with Ruff diff --git a/bindings/python/Makefile b/bindings/python/Makefile deleted file mode 100644 index 8ed8473..0000000 --- a/bindings/python/Makefile +++ /dev/null @@ -1,81 +0,0 @@ -# Needed SHELL since I'm using zsh -SHELL := /bin/bash - -ts := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") - -.PHONY: help -help: ## This help message - @echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)" - -.PHONY: build -build: dev-build-packages ## Builds Rust code and checks Python modules - python -m maturin build - -.PHONY: build-release -build-release: dev-build-packages ## Build checks module in release mode - python -m maturin build --release - -.PHONY: install -install: dev-build-packages ## Install checks module into current virtualenv - python -m maturin develop --release - -.PHONY: publish -publish: ## Publish crate on Pypi - python -m maturin publish - -.PHONY: clean -clean: ## Clean up build artifacts - cargo clean - -.PHONY: dev-build-packages -dev-build-packages: ## Install Python development packages for project - python -m pip install .[build] - -.PHONY: dev-test-packages -dev-test-packages: dev-build-packages ## Install Python development packages for project - python -m pip install .[test] - -.PHONY: dev-docs-packages -dev-docs-packages: dev-build-packages ## Install Python development packages for project - python -m pip install .[docs] - -.PHONY: cargo-test -cargo-test: ## Run cargo tests only - cargo test - -.PHONY: cargo-clippy -cargo-clippy: ## Run cargo clippy only - cargo clippy - -.PHONY: test -test: cargo-test dev-test-packages build quicktest ## Intall checks module and run tests - -.PHONY: quicktest -quicktest: dev-test-packages ## Run tests on already installed checks module - python -m pytest --hypothesis-profile default -n=auto tests/ - -.PHONY: coverage -coverage: cargo-test dev-test-packages ## Intall checks module and run tests with code coverage[] - python -m pytest --hypothesis-profile default --cov-report term-missing --cov=checks -n=auto tests/ - -.PHONY: build-profile -build-profile: ## Builds binary for profiling - cd profiling && python -m cargo build --release - -.PHONY: clean-docs -clean-docs: ## Clean the documentation build folder - rm -rf docs/build - -.PHONY: build-docs -build-docs: dev-docs-packages clean-docs ## Build documentation - python -m sphinx-build -b html docs/source docs/build - -# Setup instructions here: -# https://gist.github.com/dlaehnemann/df31787c41bd50c0fe223df07cf6eb89 -.PHONY: profile -profile: OUTPUT_PATH = measurements/flame-$(ts).svg -profile: FLAGS=booleans --iterations 10000 -profile: build-profile ## Run perf-based profiling (only works on Linux!) - perf record --call-graph dwarf,16384 -e cpu-clock -F 997 target/release/profiling $(FLAGS) - time perf script | stackcollapse-perf.pl | c++filt | flamegraph.pl > $(OUTPUT_PATH) - @echo "$(OUTPUT_PATH)" diff --git a/scripts/install_package.py b/scripts/install_package.py new file mode 100644 index 0000000..32f2f02 --- /dev/null +++ b/scripts/install_package.py @@ -0,0 +1,26 @@ +import argparse +import subprocess +import sys + +_PACKAGE_NAME_OVERRIDE = {"ninja": {"linux": "ninja-build"}} + + +def main(package: str): + package = _PACKAGE_NAME_OVERRIDE.get(package, {}).get(sys.platform, package) + + if sys.platform == "linux": + subprocess.run(["sudo", "apt-get", "install", package], shell=True, check=True) + elif sys.platform == "win32": + subprocess.run(["choco", "install", package], shell=True, check=True) + elif sys.platform == "darwin": + subprocess.run(["brew", "install", package], shell=True, check=True) + else: + raise NotImplementedError(f"{sys.platform!r} is not supported") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("package") + args = parser.parse_args() + + main(args.package)