Skip to content

Commit

Permalink
klang first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Aug 14, 2024
1 parent 57bcb8f commit a0a00ca
Show file tree
Hide file tree
Showing 9 changed files with 566 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Run tests
name: CI Checks (Linting and Tests)

on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
- ready_for_review

concurrency:
group: tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
JWT_SECRET: test
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_ENDPOINT_URL_DYNAMODB: http://localhost:8000
AWS_REGION: us-east-1

jobs:
check:
name: Check
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# .gitignore

# Rust
/target
Cargo.lock
**/*.rs.bk
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]

members = ["klang"]
59 changes: 59 additions & 0 deletions examples/clean_up_cans.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# /usr/bin/env klang
# Defines a simple klang program.
# This program is designed to get a robot to clean up soda cans.

action <Teleop> {
outcomes {
success [Success]
failure [Failure]
}
}

action <Find {item}> {
notes {
prefer [Move quickly]
avoid [Bumping into other objects]
avoid [Moving too hastily]
avoid [Moving slowly or staying in the same place for a long time]
}

outcomes {
success [Found {item}]
failure [Haven't moved in a while]
}
}

action <Pick up {item}> {
outcomes {
success [Holding {item}]
failure [Knocked over {item}]
retry [Not holding {item}]
}
}

action <Put {item} into {container}> {
outcomes {
success [{item} is inside {container} and we are not holding it]
failure [Dropped {item} outside the {container}]
retry [Still holding {item}]
}
}

action <Empty the soda can into the sink> {
outcomes {
success [Successfully emptied the soda can into the sink]
failure [Spilled soda outside the sink]
retry [There is still soda in the can]
}
}

loop {
<Find a soda can>
<Pick up the soda can>
<Find the sink>
<Empty the soda can into the sink>
<Find the recycling bin>
<Put the soda can into the recycling bin>
} until {
[No more soda cans]
}
17 changes: 17 additions & 0 deletions klang/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]

name = "klang"
version = "0.1.0"
authors = ["K-Scale Labs"]
edition = "2021"

[dependencies]

pest = "2.6"
pest_derive = "2.6"
thiserror = "1.0"

[[bin]]

name = "klang"
path = "src/main.rs"
Loading

0 comments on commit a0a00ca

Please sign in to comment.