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
12 changes: 0 additions & 12 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,3 @@ jobs:
run: |
magic install
magic run mojo test tests -I .

- name: Run formating checks
run: |
magic install
cp -r ./ /tmp/decimojo-original
magic run mojo format ./
if ! diff -r --exclude=.git --exclude=.github --exclude=venv ./ /tmp/decimojo-original > /dev/null; then
echo "::error::Formatting issues detected. Run 'mojo format' locally to fix."
exit 1
else
echo "No formatting issues detected."
fi
51 changes: 51 additions & 0 deletions .github/workflows/test_pre_commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run pre-commit
on:
# Run pre-commit on pull requests
pull_request:
# Add a workflow_dispatch event to run pre-commit manually
workflow_dispatch:

permissions:
contents: read
pull-requests: read

jobs:
lint:
runs-on: "ubuntu-22.04"
timeout-minutes: 30

defaults:
run:
shell: bash
env:
DEBIAN_FRONTEND: noninteractive

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

- name: Install magic
run: |
curl -ssL https://magic.modular.com/deb181c4-455c-4abe-a263-afcff49ccf67 | bash

- name: Add path
run: |
echo "MODULAR_HOME=$HOME/.modular" >> $GITHUB_ENV
echo "$HOME/.modular/bin" >> $GITHUB_PATH
echo "$HOME/.modular/pkg/packages.modular.com_mojo/bin" >> $GITHUB_PATH

- name: Activate virtualenv
run: |
python3 -m venv $HOME/venv/
. $HOME/venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV

- name: Install pre-commit
run: |
pip install pre-commit
pre-commit install

- name: Run pre-commit
run: |
magic install
pre-commit run --all-files
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: local
hooks:
- id: mojo-format
name: mojo-format
entry: magic run mojo format
language: system
files: '\.(mojo|🔥|py)$'
stages: [pre-commit]
2 changes: 1 addition & 1 deletion decimojo/__init__.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ DeciMojo - Correctly-rounded, fixed-point Decimal library for Mojo.

from .decimal import Decimal
from .rounding_mode import RoundingMode
from .mathematics import round, power
from .mathematics import power, sqrt, round, absolute
from .logic import greater, greater_equal, less, less_equal, equal, not_equal
Loading