Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial CI build #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
branches:
- main
pull_request:

env:
# The NAME makes it easier to copy/paste snippets from other CI configs
NAME: mir-json

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deps
run: |
rustup default nightly-2023-01-23
rustup component add clippy rustc-dev
- uses: Swatinem/rust-cache@v2.7.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should configure the cache a bit more to make it behave like our typical Haskell GHA setups. After reading the rust-cache README a bit, I think we should tweak the following:

  • I think we should enable cache-on-failure so that build dependencies will still cache even if building mir-json itself fails.
  • To future-proof this a little bit in case we accidentally corrupt the cache and need to invalidate it, I think it would be worth setting prefix-key: ${{ env.CACHE_VERSION }}, where CACHE_VERSION is a GHA environment variable.

Similarly for the use of rust-cache in the other job below.

# TODO: Fix lints, use --deny warnings
- name: Lint
run: cargo clippy

test:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be named "build" instead of "test"? At present, this job doesn't run any tests.

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deps
run: |
rustup default nightly-2023-01-23
rustup component add rustc-dev
- uses: Swatinem/rust-cache@v2.7.0
# TODO: Fix builds of examples, run tests
# - run: cargo test --locked --no-run
# - run: cargo test
- run: cargo build --bin=mir-json --release
- name: Upload binary
uses: actions/upload-artifact@v3
if: github.repository == 'GaloisInc/${{ env.NAME }}'
with:
name: "${{ env.NAME }}"
path: "target/release/${{ env.NAME }}"
if-no-files-found: error
Comment on lines +40 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you confirmed that the resulting binary is actually usable if the toolchain isn't installed?

2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
// Add the toolchain lib/ directory to `-L`. This fixes the linker error "cannot find
// -lLLVM-13-rust-1.60.0-nightly".
let out = Command::new("rustup")
.args(&["which", "rustc"])
.args(["which", "rustc"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is surprising. What motivated this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy! I can revert it if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right! Perhaps this belongs in a separate commit to make this clearer.

.output().unwrap();
assert!(out.status.success());
let rustc_path = Path::new(str::from_utf8(&out.stdout).unwrap().trim_end());
Expand Down