Skip to content
Merged
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
138 changes: 88 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,115 +1,153 @@
name: CI / Build & Test

on:
'on':
push:
branches: [master]
branches:
- master
pull_request:
branches: [master]
branches:
- master
workflow_dispatch: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name != 'master' && github.ref || github.run_id }}
group: >-
${{ github.workflow }}-${{ github.ref_name != 'master' && github.ref ||
github.run_id }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
find-crates:
name: Discover Crates
runs-on: ubuntu-latest
outputs:
crates: '${{ steps.list-crates.outputs.crates }}'
filters: '${{ steps.list-crates.outputs.filters }}'
steps:
- uses: actions/checkout@v6
- id: list-crates
run: >
crates=$(find crates -maxdepth 1 -mindepth 1 -type d -exec basename {}
\; | jq -R -s -c 'split("\n")[:-1]')

echo "crates=$crates" >> $GITHUB_OUTPUT

filters=$(find crates -maxdepth 1 -mindepth 1 -type d -exec basename
{} \; | while read -r crate; do
echo "${crate}:"
echo " - 'crates/${crate}/**'"
echo " - 'Cargo.toml'"
echo " - 'Cargo.lock'"
done)

filters="${filters}

integration:
- 'crates/**'
- 'tests/**'
- 'Cargo.toml'
- 'Cargo.lock'"
echo "filters<<EOF" >> $GITHUB_OUTPUT

echo "$filters" >> $GITHUB_OUTPUT

echo "EOF" >> $GITHUB_OUTPUT
changes:
name: Detect Changes
runs-on: ubuntu-latest
needs: find-crates
outputs:
crates: '${{ steps.build-outputs.outputs.crates }}'
testing: '${{ steps.filter.outputs.integration }}'
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4
id: filter
with:
list-files: none
filters: '${{ needs.find-crates.outputs.filters }}'
- id: build-outputs
run: >
crates=$(echo '${{ steps.filter.outputs.changes }}' | jq -c '[.[] |
select(. != "integration")]')

echo "crates=$crates" >> $GITHUB_OUTPUT
required:
name: Required Checks
runs-on: ubuntu-latest
if: always() # Always run to determine status of upstream jobs
if: always()
needs:
- build
- integration-test
- lint
- test

steps:
- id: status
name: Determine status
if: always()
run: |
results=$(tr -d '\n' <<< '${{ toJSON(needs.*.result) }}')

echo "Upstream results: $results"

if echo "$results" | grep -qE '(failure|cancelled|skipped)'; then
if echo "$results" | grep -qE '(failure|cancelled)'; then
result="failed"
else
result="success"
fi

echo "result=$result" >> $GITHUB_OUTPUT
echo "results=$results" >> $GITHUB_OUTPUT

- if: steps.status.outputs.result != 'success'
name: Fail if any upstream failed
run: |
echo "One or more upstream jobs failed: ${{ steps.status.outputs.results }}"
exit 1
run: >
echo "One or more upstream jobs failed: ${{
steps.status.outputs.results }}"

exit 1
build:
name: Build - Workspace
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

uses: actions/checkout@v6
- name: Build
run: cargo build --workspace --all-targets

lint:
name: Lint, Format and Docs - Workspace
name: 'Lint, Format and Docs - Workspace'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

uses: actions/checkout@v6
- name: Run Clippy
run: cargo clippy --workspace --all-targets -- -D warnings

- name: Check Formatting
run: cargo fmt --all -- --check

- name: Check Docs
run: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items

run: >-
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps
--document-private-items
test:
name: Test - Crate
runs-on: ubuntu-latest
needs: find-crates
needs:
- changes
- find-crates
if: 'needs.changes.outputs.crates != ''[]'''
strategy:
matrix:
crate: ${{ fromJSON(needs.find-crates.outputs.crates) }}
crate: '${{ fromJSON(needs.changes.outputs.crates) }}'
steps:
- uses: actions/checkout@v4
- name: Run ${{ matrix.crate }} tests
run: cargo test -p ${{ matrix.crate }}

- uses: actions/checkout@v6
- name: 'Run ${{ matrix.crate }} tests'
run: 'cargo test -p ${{ matrix.crate }}'
integration-test:
name: Integration Test - Crate
runs-on: ubuntu-latest
needs:
- changes
- build
- test
if: |
needs.changes.outputs.testing == 'true' &&
needs.test.result != 'failure'
steps:
- name: Checkout
uses: actions/checkout@v4

# FIXME: This timeout should be replaced with either something in the test itself
# or something within the solver.
uses: actions/checkout@v6
- name: Run integration tests
run: timeout 240s cargo netlib -- --nocapture

find-crates:
name: Discover Crates
runs-on: ubuntu-latest
outputs:
crates: ${{ steps.list-crates.outputs.crates }}
steps:
- uses: actions/checkout@v4
- id: list-crates
run: |
crates=$(find crates -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | jq -R -s -c 'split("\n")[:-1]')
echo "crates=$crates" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion .github/workflows/conventional-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Validate PR title
id: check_title
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
-Force

- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.archive_name }}
path: dist/${{ matrix.archive_name }}
Expand All @@ -98,7 +98,7 @@ jobs:

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v6
with:
path: dist

Expand All @@ -117,7 +117,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
Expand Down
52 changes: 52 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ keywords = ["optimization", "linear-programming", "convex"]
readme = "README.md"

[workspace.dependencies]
cnvx = { path = ".", version = "0.0.1" }
cnvx-cli = { path = "crates/cnvx-cli", version = "0.0.1" }
cnvx-core = { path = "crates/cnvx-core", version = "0.0.1" }
cnvx-lp = { path = "crates/cnvx-lp", version = "0.0.1" }
Expand Down
31 changes: 31 additions & 0 deletions bindings/typst/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "cnvx-typst"
version = "0.0.1"
edition = { workspace = true }
description = "Typst WebAssembly bindings for the cnvx optimization library"
authors = { workspace = true }
repository = { workspace = true }
license = { workspace = true }
keywords = { workspace = true }
readme = { workspace = true }
publish = false

[lib]
name = "cnvx"
crate-type = ["cdylib"]
path = "src/lib.rs"
doc = false

[dependencies]
cnvx-lp = { workspace = true }
cnvx-math = { workspace = true }
cnvx-graph = { workspace = true }
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.150"
wasm-minimal-protocol = "0.2.0"

[profile.release]
opt-level = "z" # minimise WASM binary size
lto = true
codegen-units = 1
strip = true
1 change: 1 addition & 0 deletions bindings/typst/LICENSE
Loading