Skip to content

Commit

Permalink
Add CI and codowners
Browse files Browse the repository at this point in the history
  • Loading branch information
TheQuantumPhysicist committed Apr 17, 2024
1 parent 92858d3 commit 208f727
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @erubboli @TheQuantumPhysicist
78 changes: 78 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions build-tools/rust-version-extractor/rust-version-extractor.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 208f727

Please sign in to comment.