Skip to content

Commit

Permalink
Merge branch 'main' into spellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
gpwclark authored Jul 22, 2024
2 parents bc82a6b + a27ff91 commit 74b0003
Show file tree
Hide file tree
Showing 23 changed files with 881 additions and 420 deletions.
44 changes: 37 additions & 7 deletions .github/workflows/pr_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- id: get_branch
if: github.event.pull_request.merged == true && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
run: echo "branch_name=master" >> "$GITHUB_OUTPUT"
run: echo "branch_name=main" >> "$GITHUB_OUTPUT"

backup_branch:
runs-on: ubuntu-latest
Expand All @@ -26,8 +26,7 @@ jobs:
if: github.event.pull_request.merged == true || github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
run: echo "branch_name=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"


benchmark_pr_with_bencher:
benchmark_pr_with_bencher_iai:
needs: [target_branch, backup_branch]
permissions:
pull-requests: write
Expand All @@ -37,7 +36,37 @@ jobs:
BENCHER_PROJECT: sl-sh
BENCHER_TESTBED: ubuntu-latest
BENCHER_ADAPTER: rust_iai_callgrind
BRANCH: ${{ needs.target_branch.outputs.branch_name || needs.backup_branch.outputs.branch_name || github.event.pull_request.base.ref || 'master' }}
BRANCH: ${{ needs.target_branch.outputs.branch_name || needs.backup_branch.outputs.branch_name || github.event.pull_request.base.ref || 'main' }}
steps:
- run: sudo apt-get update
- run: sudo apt install -y valgrind gnuplot
- uses: actions/checkout@v4
- uses: bencherdev/bencher@main
- run: cargo install iai-callgrind-runner --version 0.10.2
- name: cargo test --no-run benches (debug mode) to check compile
run: cargo test --benches --no-run
- name: Track Benchmarks with Bencher
run: |
echo "Running bencher for branch ${BRANCH}."
bencher run \
--if-branch "${BRANCH}" \
--else-if-branch "main" \
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
--token "${{ secrets.BENCHER_API_TOKEN }}" \
--err \
"cargo bench --all"
benchmark_pr_with_bencher_criterion:
needs: [target_branch, backup_branch]
permissions:
pull-requests: write
name: Continuous Benchmarking with Bencher
runs-on: ubuntu-latest
env:
BENCHER_PROJECT: sl-sh
BENCHER_TESTBED: ubuntu-latest
BENCHER_ADAPTER: rust_criterion
BRANCH: ${{ needs.target_branch.outputs.branch_name || needs.backup_branch.outputs.branch_name || github.event.pull_request.base.ref || 'main' }}
steps:
- run: sudo apt-get update
- run: sudo apt install -y valgrind gnuplot
Expand All @@ -46,12 +75,13 @@ jobs:
- run: cargo install iai-callgrind-runner --version 0.10.2
- name: cargo test --no-run benches (debug mode) to check compile
run: cargo test --benches --no-run

- name: Track Benchmarks with Bencher
run: |
echo "Running bencher for branch $BRANCH."
echo "Running bencher for branch ${BRANCH}."
bencher run \
--if-branch "$BRANCH" \
--else-if-branch "master" \
--if-branch "${BRANCH}" \
--else-if-branch "main" \
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
--token "${{ secrets.BENCHER_API_TOKEN }}" \
--err \
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ cargo run -p slosh
- install binary

```
sudo install -D -m 755 target/release/slosh /usr/local/bin/
mkdir -p /usr/local/bin
sudo install -m 755 target/release/slosh /usr/local/bin/
```
- add slosh to /etc/shells and change login shell to slosh
Expand All @@ -73,6 +74,11 @@ sudo install -D -m 755 target/release/slosh /usr/local/bin/
echo /usr/local/bin/slosh | sudo tee -a /etc/shells
chsh -s /usr/local/bin/slosh
```
### 4. (Optional) Configure slosh
The slosh configuration file lives at ~/.config/slosh/init.slosh. <br>
If you run slosh and the file does not exist, a default one will be created for you. <br>
Review your existing shell configuration files like ~/.bashrc and ~/.bash_profile and manually translate them to slosh syntax and add to your init.slosh file <br>
For example, `export JAVA_HOME="/usr/local/opt/openjdk@11/bin/java"` becomes `(sh "export JAVA_HOME='/usr/local/opt/openjdk@11/bin/java'")`
## Compiler
Expand Down
26 changes: 13 additions & 13 deletions builtins/src/collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ pub fn occurs(environment: &mut SloshVm, haystack: Value, needle: Value) -> VMRe
/// Section: collection
///
/// Example:
/// (assert-true (in? [1 2 3 4 5] 3))
/// (assert-false (in? [1 2 3 4 5] 9))
/// (assert-true (in? (list 1 2 3 4 5) 3))
/// (assert-true (in? '(1 2 3 4 5) 5))
/// (test::assert-true (in? [1 2 3 4 5] 3))
/// (test::assert-false (in? [1 2 3 4 5] 9))
/// (test::assert-true (in? (list 1 2 3 4 5) 3))
/// (test::assert-true (in? '(1 2 3 4 5) 5))
#[sl_sh_fn(fn_name = "in?", takes_env = true)]
pub fn is_in(environment: &mut SloshVm, haystack: Value, needle: Value) -> VMResult<Value> {
let mut stack = vec![];
Expand Down Expand Up @@ -254,12 +254,12 @@ pub fn flatten(vm: &mut SloshVm, registers: &[Value]) -> VMResult<Value> {
///
/// Example:
/// (let (tmap [1 2 3 0])
/// (assert-false (empty? tmap))
/// (test::assert-false (empty? tmap))
/// (set! tmap (reverse tmap))
/// (assert-equal 2 (get tmap 2))
/// (assert-equal 1 (get tmap 3))
/// (assert-equal 0 (get tmap 0))
/// (assert-error (reverse "string")))
/// (test::assert-equal 2 (get tmap 2))
/// (test::assert-equal 1 (get tmap 3))
/// (test::assert-equal 0 (get tmap 0))
/// (test::assert-error (reverse "string")))
#[sl_sh_fn(fn_name = "reverse", takes_env = true)]
pub fn reverse(environment: &mut SloshVm, seq: Value) -> VMResult<Value> {
match seq {
Expand Down Expand Up @@ -332,10 +332,10 @@ it into one vector of values.
Section: collection
Example:
(assert-equal [1 2 3 1 2 3] (flatten 1 2 3 (list 1 2 3)))
(assert-equal [1 2 3 1 2 3] (flatten 1 2 3 [1 2 3]))
(assert-equal [1 2 3 1 2] (flatten 1 2 3 (list 1 2)))
(assert-equal [1 2 3 1 2 3 1 2] (flatten 1 2 3 (list 1 2 3 (list 1 2))))
(test::assert-equal [1 2 3 1 2 3] (flatten 1 2 3 (list 1 2 3)))
(test::assert-equal [1 2 3 1 2 3] (flatten 1 2 3 [1 2 3]))
(test::assert-equal [1 2 3 1 2] (flatten 1 2 3 (list 1 2)))
(test::assert-equal [1 2 3 1 2 3 1 2] (flatten 1 2 3 (list 1 2 3 (list 1 2))))
",
);
add_builtin(
Expand Down
1 change: 0 additions & 1 deletion builtins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ Remainder from dividing first int by the second.
Section: math
Example:
(ns-import 'math)
(test::assert-equal 0 (rem 50 10))
(test::assert-equal 5 (rem 55 10))
(test::assert-equal 1 (rem 1 2))
Expand Down
2 changes: 1 addition & 1 deletion builtins/src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub fn fprn(vm: &mut SloshVm, registers: &[Value]) -> VMResult<Value> {
} else {
Err(VMError::new(
"io",
"fpr: require a writable IO object as first parameter",
"fprn: require a writable IO object as first parameter",
))
}
}
Expand Down
Loading

0 comments on commit 74b0003

Please sign in to comment.