-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92858d3
commit 208f727
Showing
3 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @erubboli @TheQuantumPhysicist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
33
build-tools/rust-version-extractor/rust-version-extractor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |