Skip to content

Commit

Permalink
Add Makefile rule and GitHub Actions workflow to check the format
Browse files Browse the repository at this point in the history
  • Loading branch information
minoki committed Jul 9, 2024
1 parent 404d276 commit 6e024d7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/check-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on: [push, pull_request]
name: check-format
jobs:
check-format:
name: Check format with smlfmt
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Cache smlfmt
id: cache-smlfmt
uses: actions/cache@v3
with:
path: ~/.local/bin
key: ${{ runner.os }}-smlfmt
- if: ${{ steps.cache-smlfmt.outputs.cache-hit != 'true' }}
name: Install smlfmt
run: |
sudo apt-get update
sudo apt-get install mlton
curl -Lo smlfmt.tar.gz https://github.com/shwestrick/smlfmt/archive/refs/tags/v1.1.0.tar.gz
tar xf smlfmt.tar.gz
make -C smlfmt-1.1.0
install -d ~/.local/bin
install -m 755 smlfmt-1.1.0/smlfmt ~/.local/bin
- name: smlfmt
run: make check-format
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ NODE = node
MKDIR = mkdir -p
CP = cp -fpR
INSTALL_EXEC = install -p -m 0755
SMLFMT = smlfmt

include version.mk

Expand Down Expand Up @@ -72,9 +73,25 @@ sources = \
src/main.sml \
src/main-default.sml

autogen_sources = \
src/language-options-record.sml \
src/primitives.sml \
src/syntax.grm.sig \
src/syntax.grm.sml \
src/command-line-settings.sml \
src/version.sml

formatted_sources = \
$(filter-out $(autogen_sources),$(sources)) \
src/main-esmod.sml

typecheck: src/lunarml-main.mlb $(sources)
mlton -stop tc -default-ann "warnUnused true" $<

.PHONY: check-format
check-format:
$(SMLFMT) --check $(formatted_sources)

bin/lunarml: src/lunarml-main.mlb $(sources)
mlton -output $@ $<

Expand Down

0 comments on commit 6e024d7

Please sign in to comment.