Skip to content

Commit

Permalink
Add initial github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekker1 committed Apr 4, 2024
1 parent 8a45b88 commit acffc5b
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 6 deletions.
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
groups:
production:
dependency-type: "production"
development:
dependency-type: "development"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
76 changes: 76 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and test

on:
push:
branches-ignore:
- "dependabot/**"
pull_request:

env:
RUST_CHANNEL: "stable"
RUST_TEST_CHANNEL: "nightly"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup toolchain install --profile minimal --no-self-update ${{ env.RUST_CHANNEL }}
rustup default ${{ env.RUST_CHANNEL }}
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Build fzn-huub
run: cargo install --root dist/ --path crates/fzn-huub
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: fzn-huub-${{ matrix.os }}
path: dist/
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup toolchain install --profile minimal --no-self-update ${{ env.RUST_TEST_CHANNEL }}
rustup default ${{ env.RUST_TEST_CHANNEL }}
- name: Install grcov
uses: SierraSoftworks/setup-grcov@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Run cargo test
run: cargo test
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort"
- name: Collect covereage data
run: grcov . --binary-path target/debug/deps/ -s . -t lcov --ignore-not-existing --ignore '../**' --ignore '/*' -o ./lcov.info
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./lcov.info
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup toolchain install --profile minimal --component clippy --no-self-update ${{ env.RUST_CHANNEL }}
rustup default ${{ env.RUST_CHANNEL }}
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Run clippy
run: cargo clippy -- -D warnings
26 changes: 26 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check Format

on:
push:
branches-ignore:
- "dependabot/**"
pull_request:

env:
# Lets us format with unstable rustfmt options
RUST_CHANNEL: nightly

jobs:
check_format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# Check formatting of Rust files
- name: Install Rust toolchain
run: |
rustup toolchain install --profile minimal --component rustfmt --no-self-update ${{ env.RUST_CHANNEL }}
rustup default ${{ env.RUST_CHANNEL }}
- name: Run cargo format
run: cargo +nightly fmt --all --check
6 changes: 2 additions & 4 deletions crates/fzn-huub/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ use std::{
time::Duration,
};

use ::tracing::Level;
use clap::Parser;
use flatzinc_serde::{FlatZinc, Literal};
use huub::{
SimplifiedBool, SimplifiedInt, SimplifiedVariable, SolveResult, Solver, Valuation, Value,
};
use miette::{IntoDiagnostic, Result, WrapErr};

use ::tracing::Level;
use tracing_subscriber::fmt::time::uptime;

use tracing::FmtLitFields;
use tracing_subscriber::fmt::time::uptime;

/// fzn-huub entry point
///
Expand Down
7 changes: 6 additions & 1 deletion crates/huub/src/solver/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ impl IpasirPropagator for Engine {

fn add_reason_clause(&mut self, propagated_lit: pindakaas::Lit) -> Vec<pindakaas::Lit> {
let reason = match &self.reason_map[&propagated_lit] {
Reason::Lazy(_, _) => todo!(),
Reason::Lazy(prop, data) => {
let reason = self.propagators[*prop].explain(*data);
once(propagated_lit)
.chain(reason.iter().map(|l| !l))
.collect()
}
Reason::Eager(v) => once(propagated_lit).chain(v.iter().map(|l| !l)).collect(),
Reason::Simple(l) => vec![propagated_lit, !l],
};
Expand Down
5 changes: 4 additions & 1 deletion crates/huub/src/solver/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use std::num::NonZeroI32;

use pindakaas::Lit as RawLit;

use crate::{solver::engine::int_var::IntVarRef, solver::SatSolver, Solver};
use crate::{
solver::{engine::int_var::IntVarRef, SatSolver},
Solver,
};

pub enum SolverView {
Bool(BoolView),
Expand Down

0 comments on commit acffc5b

Please sign in to comment.