diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3c19809 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,54 @@ +name: Build all packages + +# on: +# push: +# branches: +# - main +# workflow_dispatch: +# pull_request: +# branches: +# - main +on: ["push"] + +jobs: + build: + strategy: + matrix: + include: + - { target: linux-64, os: ubuntu-latest } + - { target: osx-arm64, os: macos-14 } + fail-fast: false + + runs-on: ${{ matrix.os }} + timeout-minutes: 5 + + defaults: + run: + shell: bash + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install magic + run: | + curl -ssL https://magic.modular.com | bash + + - name: Build package for target platform + env: + TARGET_PLATFORM: ${{ matrix.target }} + PREFIX_API_KEY: ${{ secrets.PREFIX_API_KEY }} + CONDA_BLD_PATH: ${{ runner.workspace }}/.rattler + + run: | + source $HOME/.bash_profile + + # Temporary method to fetch the rattler binary. + RATTLER_BINARY="rattler-build-aarch64-apple-darwin" + if [[ $TARGET_PLATFORM == "linux-64" ]]; then RATTLER_BINARY="rattler-build-x86_64-unknown-linux-musl"; fi + curl -SL --progress-bar https://github.com/prefix-dev/rattler-build/releases/latest/download/${RATTLER_BINARY} -o rattler-build + chmod +x rattler-build + + # Build and push + magic run build --target-platform=$TARGET_PLATFORM + magic run publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d141180..dbee817 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,25 +2,39 @@ name: Run Tests on: pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +permissions: + contents: read + pull-requests: read jobs: test: - runs-on: ubuntu-latest - environment: basic + name: with ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # os: ["ubuntu-latest", "macos-14"] # mac tests just hang for some reason? + os: ["ubuntu-latest"] + + runs-on: ${{ matrix.os }} + timeout-minutes: 5 + + defaults: + run: + shell: bash + steps: - - name: Check out repository code - uses: actions/checkout@v2 - - name: Install dependencies + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install magic run: | - curl https://get.modular.com | MODULAR_AUTH=${{ secrets.MODULAR_AUTH }} sh - - modular auth ${{ secrets.MODULAR_AUTH }} - modular install mojo - pip install pytest - pip install git+https://github.com/guidorice/mojo-pytest.git - - name: Unit Tests + curl -ssL https://magic.modular.com | bash + + - name: Run tests run: | - export MODULAR_HOME="/home/runner/.modular" - export PATH="/home/runner/.modular/pkg/packages.modular.com_mojo/bin:$PATH" - pytest tests/unit - pytest tests/integration - bash run_examples.sh + source $HOME/.bash_profile + magic run tests + magic run benchmarks + magic run examples diff --git a/src/recipe.yaml b/src/recipe.yaml index b52cff4..9f39fcb 100644 --- a/src/recipe.yaml +++ b/src/recipe.yaml @@ -4,7 +4,7 @@ context: version: "13.4.2" package: - name: "mist" + name: "mog" version: 0.1.3.nightly source: @@ -15,14 +15,15 @@ source: build: script: - mkdir -p ${PREFIX}/lib/mojo - - magic run mojo package mist - - cp mist.mojopkg ${PREFIX}/lib/mojo/mist.mojopkg + - magic run mojo package mog + - cp mog.mojopkg ${PREFIX}/lib/mojo/mog.mojopkg requirements: run: - - gojo >= 0.1.6.nightly - - hue >= 0.1.3.nightly + - gojo >= 0.1.7.nightly - max >= 24.6.0.dev2024091205 + - weave >= 0.1.0.nightly + - mist >= 0.1.3.nightly tests: - script: @@ -31,19 +32,19 @@ tests: # if I don't copy everything into a test dir, mojo test runs the tests in the .magic dir and fails :| - mkdir -p test - mv test_*.mojo test/ - - mv mist.mojopkg test/ + - mv mog.mojopkg test/ - magic run mojo test test files: # Extra files to be copied to the test directory from the "work directory" source: - - mist.mojopkg + - mog.mojopkg - mojoproject.toml - test_*.mojo about: - homepage: https://github.com/thatstoasty/mist + homepage: https://github.com/thatstoasty/mog license: MIT license_file: LICENSE - summary: mist lets you safely use advanced styling options on the terminal. https://github.com/thatstoasty/mist - repository: https://github.com/thatstoasty/mist + summary: Style definitions for nice terminal layouts. Built with TUIs in mind. https://github.com/thatstoasty/mog + repository: https://github.com/thatstoasty/mog diff --git a/test.mojo b/test.mojo deleted file mode 100644 index 53127e0..0000000 --- a/test.mojo +++ /dev/null @@ -1,143 +0,0 @@ -from mog.gojo.strings import StringBuilder -import mog - -alias line: String = "─" -alias width = 96 -alias column_width = 30 -alias subtle = mog.AdaptiveColor(light=0xD9DCCF, dark=0x383838) -alias highlight = mog.AdaptiveColor(light=0x874BFD, dark=0x7D56F4) -alias special = mog.AdaptiveColor(light=0x43BF6D, dark=0x73F59F) - - -fn build_lists() -> String: - var list_style = mog.Style().border(mog.NORMAL_BORDER, False, True, False, False).border_foreground( - subtle - ).margin_right(2).height(8) - # width(column_width + 1) - - var list_header = mog.Style().border(mog.NORMAL_BORDER, False, False, True, False).border_foreground( - subtle - ).margin_right(2) - - var list_item = mog.Style().padding_left(2) - # var check_mark = mog.Style().foreground(special).padding_right(1).render("✔") - # var list_done = mog.Style().crossout().foreground(mog.AdaptiveColor(light=0x969B86, dark=0x696969)) - - # var lists = mog.join_horizontal( - # mog.position.top, - # list_style.render( - # mog.join_vertical( - # mog.position.left, - # list_header.render("Citrus Fruits to Try"), - # list_item.render("Grapefruit"), - # list_item.render("Yuzu"), - # list_item.render("Citron"), - # list_item.render("Kumquat"), - # list_item.render("Pomelo"), - # ), - # ), - # list_style.width(column_width).render( - # mog.join_vertical( - # mog.position.left, - # list_header.render("Actual Lip Gloss Vendors"), - # list_item.render("Glossier"), - # list_item.render("Claire's Boutique"), - # list_item.render("Nyx"), - # list_item.render("Mac"), - # list_item.render("Milk"), - # ), - # ), - # list_style.width(column_width - 1).render( - # mog.join_vertical( - # mog.position.left, - # list_header.render("Programming Languages"), - # list_item.render("Mojo"), - # list_item.render("Rust"), - # list_item.render("Python"), - # list_item.render("Gleam"), - # list_item.render("Go"), - # ), - # ), - # ) - - return list_style.render( - mog.join_vertical( - mog.position.left, - list_header.render("Citrus Fruits to Try"), - list_item.render("Grapefruit"), - list_item.render("Yuzu"), - list_item.render("Citron"), - list_item.render("Kumquat"), - list_item.render("Pomelo"), - ), - ) - - -fn find(s: String, substr: String, start: Int = 0) -> Int: - var i = start - for char in s: - print("char", char) - if char == substr: - break - i += len(char) - - return i - - -fn get_slice(s: String, start: Int = 0, end: Int = -1) -> String: - var i = 0 - var builder = StringBuilder() - for char in s: - if i >= start and i < end: - _ = builder.write(char.as_bytes_slice()) - i += len(char) - - return str(builder) - - -fn split(s: String, sep: String, maxsplit: Int = -1) raises -> List[String]: - var output = List[String]() - - var str_byte_len = len(s) - 1 - var lhs = 0 - var rhs = 0 - var items = 0 - var sep_len = sep.byte_length() - if sep_len == 0: - raise Error("ValueError: empty separator") - if str_byte_len < 0: - output.append("") - - while lhs <= str_byte_len: - rhs = find(s, sep, lhs) - # rhs = s.find(sep, lhs) - print(lhs, rhs, str_byte_len) - if rhs == -1: - mog.raw_print(s[lhs:]) - output.append(get_slice(s, lhs)) - break - - if maxsplit > -1: - if items == maxsplit: - output.append(get_slice(s, lhs)) - break - items += 1 - - output.append(get_slice(s, lhs, rhs)) - mog.raw_print(s[lhs:rhs]) - lhs = rhs + sep_len - - if s.endswith(sep) and (len(output) <= maxsplit or maxsplit == -1): - output.append("") - return output - - -fn main() raises: - var text: String = "─Go\n\n\n" - # var text2: String = 'Go\n\n\n' - var lines = split(text, "\n") - print(lines.__str__(), len(lines)) - print(text) - # var lines2 = split(text, "\n") - # print(lines2.__str__(), len(lines2)) - # print(text2)