Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
FiveMovesAhead committed Apr 23, 2024
1 parent a071aed commit e95a3f9
Show file tree
Hide file tree
Showing 54 changed files with 6,518 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build_algorithm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build Algorithm

on:
push:
branches:
- 'satisfiability/*'
- 'vehicle_routing/*'
- 'knapsack/*'
- 'test/satisfiability/*'
- 'test/vehicle_routing/*'
- 'test/knapsack/*'
- 'dev/satisfiability/*'
- 'dev/vehicle_routing/*'
- 'dev/knapsack/*'

jobs:
build_wasm:
name: Compile Algorithm to WASM
runs-on: ubuntu-latest
permissions:
contents: write
statuses: write
steps:
- uses: actions/checkout@v4
- name: Set Env Vars
run: |
CHALLENGE=`echo $GITHUB_REF_NAME | rev | cut -d/ -f2 | rev`
ALGORITHM=`echo $GITHUB_REF_NAME | rev | cut -d/ -f1 | rev`
WASM_PATH=tig-algorithms/wasm/${CHALLENGE}/${ALGORITHM}.wasm
if [ -f $WASM_PATH ]; then
echo "SKIP_JOB=true" >> $GITHUB_ENV
else
echo "SKIP_JOB=false" >> $GITHUB_ENV
fi
echo "CHALLENGE=$CHALLENGE" >> $GITHUB_ENV
echo "ALGORITHM=$ALGORITHM" >> $GITHUB_ENV
echo "WASM_PATH=$ALGORITHM" >> $GITHUB_ENV
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasi
- name: Cargo Build
if: env.SKIP_JOB != 'true'
run: >
CHALLENGE=${{ env.CHALLENGE }}
ALGORITHM=${{ env.ALGORITHM }}
cargo build -p tig-wasm --target wasm32-wasi --release --features entry-point;
mkdir -p tig-algorithms/wasm/${{ env.CHALLENGE }};
- name: Optimize WASM
if: env.SKIP_JOB != 'true'
uses: NiklasEi/wasm-opt-action@v2
with:
file: target/wasm32-wasi/release/tig_wasm.wasm
output: tig-algorithms/wasm/${{ env.CHALLENGE }}/${{ env.ALGORITHM }}.wasm
options: -O2 --remove-imports
- name: Auto commit
if: env.SKIP_JOB != 'true'
id: auto_commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Compiled algorithm ${{ env.ALGORITHM }} into WASM
- name: Update Commit Status (Success)
if: env.SKIP_JOB != 'true' && success()
uses: myrotvorets/set-commit-status-action@master
with:
status: 'success'
sha: ${{ steps.auto_commit.outputs.commit_hash }}
- name: Update Commit Status (Failure)
if: env.SKIP_JOB != 'true' && failure()
uses: myrotvorets/set-commit-status-action@master
with:
status: 'failure'
40 changes: 40 additions & 0 deletions .github/workflows/build_benchmarker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build Benchmarker

on:
push:
branches:
- 'benchmarker/*'
- 'test/benchmarker/*'
- 'dev/benchmarker/*'

jobs:
build_wasm:
name: Compile Benchmarker to WASM
runs-on: ubuntu-latest
permissions:
contents: write
statuses: write
steps:
- uses: actions/checkout@v4
- name: Install
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Cargo Build
run: >
wasm-pack build tig-benchmarker --release --target web;
rm tig-benchmarker/wasm/.gitignore;
- name: Auto commit
id: auto_commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Add compiled WASM for benchmarker
- name: Update Commit Status (Success)
if: success()
uses: myrotvorets/set-commit-status-action@master
with:
status: 'success'
sha: ${{ steps.auto_commit.outputs.commit_hash }}
- name: Update Commit Status (Failure)
if: failure()
uses: myrotvorets/set-commit-status-action@master
with:
status: 'failure'
41 changes: 41 additions & 0 deletions .github/workflows/test_workspace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test Workspace

on:
push:
branches-ignore:
- 'benchmarker/*'
- 'satisfiability/*'
- 'vehicle_routing/*'
- 'knapsack/*'
- 'test/benchmarker/*'
- 'test/satisfiability/*'
- 'test/vehicle_routing/*'
- 'test/knapsack/*'
- 'dev/benchmarker/*'
- 'dev/satisfiability/*'
- 'dev/vehicle_routing/*'
- 'dev/knapsack/*'

jobs:
test_workspace:
name: Test Workspace
permissions:
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu
- name: Cargo Test
run: cargo test
- name: Update Commit Status (Success)
if: success()
uses: myrotvorets/set-commit-status-action@master
with:
status: 'success'
- name: Update Commit Status (Failure)
if: failure()
uses: myrotvorets/set-commit-status-action@master
with:
status: 'failure'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

.vscode/
24 changes: 24 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[workspace]
members = [
"tig-algorithms",
"tig-api",
"tig-benchmarker",
"tig-challenges",
"tig-protocol",
"tig-structs",
"tig-utils",
"tig-wasm",
"tig-worker",
]
exclude = []
resolver = "2"

[workspace.package]
authors = ["TIG UG <[email protected]>", "Ying Chan <[email protected]>"]
repository = "https://github.com/tig-foundation/tig-monorepo"
edition = "2021"
readme = "README.md"

[profile.release]
lto = true
codegen-units = 1
15 changes: 15 additions & 0 deletions tig-algorithms/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "tig-algorithms"
version = "0.1.0"
authors.workspace = true
repository.workspace = true
edition.workspace = true

[dependencies]
anyhow = "1.0.81"
ndarray = "0.15.6"
rand = { version = "0.8.5", default-features = false, features = ["std_rng"] }
tig-challenges = { path = "../tig-challenges" }

[lib]
crate-type = ["cdylib", "rlib"]
100 changes: 100 additions & 0 deletions tig-algorithms/src/knapsack/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// c003_a001 placeholder
// c003_a002 placeholder
// c003_a003 placeholder
// c003_a004 placeholder
// c003_a005 placeholder
// c003_a006 placeholder
// c003_a007 placeholder
// c003_a008 placeholder
// c003_a009 placeholder
// c003_a010 placeholder
// c003_a011 placeholder
// c003_a012 placeholder
// c003_a013 placeholder
// c003_a014 placeholder
// c003_a015 placeholder
// c003_a016 placeholder
// c003_a017 placeholder
// c003_a018 placeholder
// c003_a019 placeholder
// c003_a020 placeholder
// c003_a021 placeholder
// c003_a022 placeholder
// c003_a023 placeholder
// c003_a024 placeholder
// c003_a025 placeholder
// c003_a026 placeholder
// c003_a027 placeholder
// c003_a028 placeholder
// c003_a029 placeholder
// c003_a030 placeholder
// c003_a031 placeholder
// c003_a032 placeholder
// c003_a033 placeholder
// c003_a034 placeholder
// c003_a035 placeholder
// c003_a036 placeholder
// c003_a037 placeholder
// c003_a038 placeholder
// c003_a039 placeholder
// c003_a040 placeholder
// c003_a041 placeholder
// c003_a042 placeholder
// c003_a043 placeholder
// c003_a044 placeholder
// c003_a045 placeholder
// c003_a046 placeholder
// c003_a047 placeholder
// c003_a048 placeholder
// c003_a049 placeholder
// c003_a050 placeholder
// c003_a051 placeholder
// c003_a052 placeholder
// c003_a053 placeholder
// c003_a054 placeholder
// c003_a055 placeholder
// c003_a056 placeholder
// c003_a057 placeholder
// c003_a058 placeholder
// c003_a059 placeholder
// c003_a060 placeholder
// c003_a061 placeholder
// c003_a062 placeholder
// c003_a063 placeholder
// c003_a064 placeholder
// c003_a065 placeholder
// c003_a066 placeholder
// c003_a067 placeholder
// c003_a068 placeholder
// c003_a069 placeholder
// c003_a070 placeholder
// c003_a071 placeholder
// c003_a072 placeholder
// c003_a073 placeholder
// c003_a074 placeholder
// c003_a075 placeholder
// c003_a076 placeholder
// c003_a077 placeholder
// c003_a078 placeholder
// c003_a079 placeholder
// c003_a080 placeholder
// c003_a081 placeholder
// c003_a082 placeholder
// c003_a083 placeholder
// c003_a084 placeholder
// c003_a085 placeholder
// c003_a086 placeholder
// c003_a087 placeholder
// c003_a088 placeholder
// c003_a089 placeholder
// c003_a090 placeholder
// c003_a091 placeholder
// c003_a092 placeholder
// c003_a093 placeholder
// c003_a094 placeholder
// c003_a095 placeholder
// c003_a096 placeholder
// c003_a097 placeholder
// c003_a098 placeholder
// c003_a099 placeholder
// c003_a100 placeholder
3 changes: 3 additions & 0 deletions tig-algorithms/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod knapsack;
pub mod satisfiability;
pub mod vehicle_routing;
Loading

0 comments on commit e95a3f9

Please sign in to comment.