diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..8861d34 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @erubboli @TheQuantumPhysicist diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d0a2cc9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,78 @@ +name: build + +on: + push: + branches: + - "**" # target all branches + pull_request: + branches: + - master + +env: + CARGO_TERM_COLOR: always + RUST_LOG: debug + RUST_BACKTRACE: full + +jobs: + build_windows: + runs-on: windows-latest + # if: github.ref == 'refs/heads/master' + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Install python toml package + run: python3 -m pip install toml + - name: Install rust + run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/rust-version-extractor/rust-version-extractor.py) + - name: Build + run: cargo build --release --locked + - name: Run tests + run: cargo test --release --workspace + - name: Run doc tests + run: cargo test --release --doc + + build_ubuntu: + env: + ML_CONTAINERIZED_TESTS: 1 + runs-on: ubuntu-latest + # if: github.ref == 'refs/heads/master' + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Update local dependency repositories + run: sudo apt-get update + - name: Install dependencies + run: sudo apt-get install -yqq --no-install-recommends build-essential python3 python3-toml podman build-essential pkg-config libssl-dev + - name: Install rust deps + run: sudo apt-get install -yqq build-essential pkg-config libssl-dev + - name: Install rust + run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/rust-version-extractor/rust-version-extractor.py) + - name: Build + run: cargo build --release --locked + - name: Run tests + run: cargo test --release --workspace + - name: Run doc tests + run: cargo test --release --doc + + build_macos: + runs-on: macos-latest + # if: github.ref == 'refs/heads/master' + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Install python toml package + run: python3 -m pip install toml + - name: Install rust + run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $(python3 ./build-tools/rust-version-extractor/rust-version-extractor.py) + - name: Build + run: cargo build --release --locked + - name: Run tests + run: cargo test --release --workspace + - name: Run doc tests + run: cargo test --release --doc diff --git a/build-tools/rust-version-extractor/rust-version-extractor.py b/build-tools/rust-version-extractor/rust-version-extractor.py new file mode 100644 index 0000000..f06d9fe --- /dev/null +++ b/build-tools/rust-version-extractor/rust-version-extractor.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +''' +A simple program that extracts the rust version and prints it to stdout. +To be used in CI. +''' + +import os +import re +import sys +import toml +import itertools + +def get_rust_version(): + cargo_toml_root = toml.load('Cargo.toml') + + if "package" not in cargo_toml_root: + raise KeyError("'package' not found in 'workspace' in root") + package_settings = cargo_toml_root['package'] + + if "rust-version" not in package_settings: + raise KeyError("Rust version is not specified in [package]") + + version = package_settings["rust-version"] + + # Unfortunately, rust-init doesn't support completing the version on its own, so we just pad with whatever works + if len(version.split('.')) == 2: + version = version + '.0' + + return version + +if __name__ == "__main__": + rust_version = get_rust_version() + print(rust_version)