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
90 changes: 15 additions & 75 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -1,107 +1,47 @@
name: check

on:
workflow_dispatch:
push:
branches:
- master
- main

- main
pull_request:

jobs:
check:
strategy:
matrix:
version: [stable]
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Moon
uses: illusory0x0/setup-moonbit@v0.1.0
with:
version: ${{ matrix.version }}
submodules: 'recursive'

- name: install
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
echo "$HOME/.moon/bin" >> $GITHUB_PATH

- name: moon version
run: |
moon version --all

- name: install module dependencies
- name: moon check
run: |
moon update
moon install

- name: moon check
run: moon check --deny-warn
moon check --deny-warn

- name: moon info
run: |
moon info --target all
git diff --exit-code

- name: moon fmt
- name: format diff
run: |
moon fmt
git diff --exit-code

- name: Setup MSVC
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1

- name: Set ulimit on unix
if: ${{ runner.os != 'Windows' }}
run: |
ulimit -s 8176

- name: moon test
run: |
moon test --target all
moon test --target all --release

moon-json-format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: check `moon.*.json` format
shell: bash
run: |
_passed=0;
for f in $(find . -type f -name "moon.*.json"); do
if ! jq '.' $f > /dev/null; then
echo $f;
_passed=1;
fi
done
(exit $_passed)

prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: |
npm install --global prettier;
find . -name *.mod.json -exec npx prettier --write {} \;
find . -name *.pkg.json -exec npx prettier --write {} \;
git diff --exit-code;

check-typos:
runs-on: ubuntu-latest

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

- name: AutoCorrect
uses: huacnlee/autocorrect-action@v2

- name: typos-action
uses: crate-ci/typos@v1.31.1
moon test --target all
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
target/
.mooncakes/
_build/
.DS_Store
.vscode/
.moonagent/
.moonagent/
19 changes: 8 additions & 11 deletions src/algorithms/capture.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub impl DiffHook for Capture with equal(
new_index : Int,
len : Int,
) -> Result[Unit, Error] {
self.0.push(DiffOp::Equal(old_index~, new_index~, len~))
self.0.push(Equal(old_index~, new_index~, len~))
Ok(())
}

Expand All @@ -95,7 +95,7 @@ pub impl DiffHook for Capture with delete(
old_len : Int,
new_index : Int,
) -> Result[Unit, Error] {
self.0.push(DiffOp::Delete(old_index~, old_len~, new_index~))
self.0.push(Delete(old_index~, old_len~, new_index~))
Ok(())
}

Expand All @@ -111,7 +111,7 @@ pub impl DiffHook for Capture with insert(
new_index : Int,
new_len : Int,
) -> Result[Unit, Error] {
self.0.push(DiffOp::Insert(old_index~, new_index~, new_len~))
self.0.push(Insert(old_index~, new_index~, new_len~))
Ok(())
}

Expand All @@ -129,7 +129,7 @@ pub impl DiffHook for Capture with replace(
new_index : Int,
new_len : Int,
) -> Result[Unit, Error] {
self.0.push(DiffOp::Replace(old_index~, old_len~, new_index~, new_len~))
self.0.push(Replace(old_index~, old_len~, new_index~, new_len~))
Ok(())
}

Expand Down Expand Up @@ -160,13 +160,10 @@ pub fn Capture::sort(self : Capture) -> Unit {
/// Helper function to extract sorting keys from operations
fn get_old_new_index(op : DiffOp) -> (Int, Int)? {
match op {
DiffOp::Equal(old_index~, new_index~, len=_) =>
Some((old_index, new_index))
DiffOp::Delete(old_index~, old_len=_, new_index~) =>
Some((old_index, new_index))
DiffOp::Insert(old_index~, new_index~, new_len=_) =>
Some((old_index, new_index))
DiffOp::Replace(old_index~, old_len=_, new_index~, new_len=_) =>
Equal(old_index~, new_index~, len=_) => Some((old_index, new_index))
Delete(old_index~, old_len=_, new_index~) => Some((old_index, new_index))
Insert(old_index~, new_index~, new_len=_) => Some((old_index, new_index))
Replace(old_index~, old_len=_, new_index~, new_len=_) =>
Some((old_index, new_index))
}
}
Expand Down
Loading
Loading