Skip to content

Commit

Permalink
Adding basic Rust CI infrastructure (#1)
Browse files Browse the repository at this point in the history
* Placeholder crates to start working on infra

* More example infrastructure

* Add basic CI for Rust

* Fix formatting of yaml

* Add manual dispatch to workflow

* Use checkout v3

* Update and simplify

* Switch to warnings for clippy::pedantic for easier local development
  • Loading branch information
swernli authored Jan 31, 2023
1 parent 478128d commit 669fb07
Show file tree
Hide file tree
Showing 16 changed files with 485 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI Build and Test

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: "true"
- name: Check Formatting
run: cargo fmt -v --all -- --check

build:
name: CI Build and Test
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]

runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@v3
with:
submodules: "true"
- name: Clippy Lints
run: cargo clippy -vv --all-targets --all-features -- -D warnings
- name: Build
run: cargo build -vv --release
- name: Test
run: cargo test -vv --release -- --nocapture
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{matrix.os}}
path: |
target/release/qsc*
!target/release/qsc.d
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
265 changes: 265 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[workspace]
members = [
"compiler/qsc",
"compiler/qsc_ast",
"compiler/qsc_codegen",
"compiler/qsc_eval",
"compiler/qsc_frontend",
"compiler/qsc_passes",
]

[profile.release]
debug = 1
11 changes: 11 additions & 0 deletions compiler/qsc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "qsc"
version = "0.0.0"
edition = "2021"

[dependencies]
qsc_ast = { path = "../qsc_ast" }
qsc_frontend = { path = "../qsc_frontend" }
qsc_passes = { path = "../qsc_passes" }
qsc_codegen = { path = "../qsc_codegen" }
qsc_eval = { path = "../qsc_eval" }
8 changes: 8 additions & 0 deletions compiler/qsc/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#![warn(clippy::pedantic)]

fn main() {
println!("Hello, world!");
}
6 changes: 6 additions & 0 deletions compiler/qsc_ast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "qsc_ast"
version = "0.0.0"
edition = "2021"

[dependencies]
20 changes: 20 additions & 0 deletions compiler/qsc_ast/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#![warn(clippy::pedantic)]

#[must_use]
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
9 changes: 9 additions & 0 deletions compiler/qsc_codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "qsc_codegen"
version = "0.0.0"
edition = "2021"

[dependencies]
qsc_ast = { path = "../qsc_ast" }
qsc_frontend = { path = "../qsc_frontend" }
# LLVM dependency here...
Loading

0 comments on commit 669fb07

Please sign in to comment.