Skip to content

Commit

Permalink
Major revisions to Makefile (#1431)
Browse files Browse the repository at this point in the history
* Major revisions to Makefile

* Remove from the CI the use of make install-shelltest

* Remove comment
  • Loading branch information
jonaprieto authored Aug 3, 2022
1 parent 01a44e4 commit 6a4b0e3
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 111 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
STACKFLAGS: --pedantic

jobs:
ormolu:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -115,7 +118,7 @@ jobs:
- name: Build Haskell Project
run: |
cd main
make ci-build
make build
test:
needs: build
Expand Down Expand Up @@ -173,15 +176,13 @@ jobs:
id: test
run: |
cd main
make ci-test
make test
- name : Shell tests
id: shell-tests
if: matrix.os == 'ubuntu-latest'
run : |
cd main
echo "$GITHUB_WORKSPACE/.local/bin" >> $GITHUB_PATH
make install
make install-shelltest
make test-shell
docs:
needs: build
Expand Down
213 changes: 106 additions & 107 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ PREFIX="$(PWD)/.stack-work/prefix"
UNAME := $(shell uname)
HLINTQUIET :=

ASSETS = seating-mascot.051c86a.svg \
Seating_Tara_smiling.svg \
teaching-mascot.f828959.svg

ORGFILES = $(shell find docs/org -type f -name '*.org')
MDFILES:=$(patsubst docs/org/%,docs/md/%,$(ORGFILES:.org=.md))
ASSETS = seating-mascot.051c86a.svg Seating_Tara_smiling.svg teaching-mascot.f828959.svg

EXAMPLEMILESTONE=examples/milestone
EXAMPLEHTMLOUTPUT=_docs/examples/html
EXAMPLES=ValidityPredicates/SimpleFungibleToken.juvix \
MiniTicTacToe/MiniTicTacToe.juvix \
Fibonacci/Fibonacci.juvix \
Collatz/Collatz.juvix
MiniTicTacToe/MiniTicTacToe.juvix \
Fibonacci/Fibonacci.juvix \
Collatz/Collatz.juvix

ORGTOMDPRG ?=pandoc
ORGOPTS=--from org --to markdown_strict -s -o $@
Expand All @@ -25,8 +28,31 @@ else
THREADS := $(shell echo %NUMBER_OF_PROCESSORS%)
endif

all:
make pre-commit
all: install

clean:
@stack clean --full
@rm -rf .hie
@rm -rf _docs

repl:
@stack ghci Juvix:lib

# ------------------------------------------------------------------------------
# -- The Juvix Book
# ------------------------------------------------------------------------------

# -- EXAMPLES

.PHONY: html-examples
html-examples: $(EXAMPLES)

$(EXAMPLES):
$(eval OUTPUTDIR=$(EXAMPLEHTMLOUTPUT)/$(dir $@))
@mkdir -p ${OUTPUTDIR}
@juvix html $(EXAMPLEMILESTONE)/$@ --recursive --output-dir=./../../../${OUTPUTDIR} --print-metadata

# -- MDBook

docs/md/README.md :
@mkdir -p docs/md
Expand All @@ -46,135 +72,108 @@ markdown-docs: docs/md/README.md docs/md/changelog.md $(MDFILES)
@echo "copying assets ..."
@mkdir -p docs/md/assets
@cp -v $(addprefix assets/,$(ASSETS)) docs/md/assets
mdbook build
@mdbook build

.PHONY: serve-docs
serve-docs: $(MDFILES)
mdbook serve --open

.PHONY : checklines
checklines :
@grep '.\{81,\}' \
--exclude=*.org \
-l --recursive src; \
status=$$?; \
if [ $$status = 0 ] ; \
then echo "Lines were found with more than 80 characters!" >&2 ; \
else echo "Succeed!"; \
fi
@mdbook serve --open

.PHONY : hlint
hlint :
@hlint src app test ${HLINTQUIET}
# -- Codebase Documentation

.PHONY : haddock
haddock :
cabal --docdir=docs/ --htmldir=docs/ haddock --enable-documentation
@cabal --docdir=docs/ --htmldir=docs/ haddock --enable-documentation

.PHONY : docs
docs :
cd docs ; \
sh conv.sh
# ------------------------------------------------------------------------------
# -- Codebase Health
# ------------------------------------------------------------------------------

.PHONY: ci
ci:
make ci-build
make install
make ci-test
make test-shell
ORMOLUFILES = $(shell git ls-files '*.hs' '*.hs-boot' | grep -v '^contrib/')
ORMOLUFLAGS?=--no-cabal
ORMOLUMODE?=inplace

.PHONY : build
build:
stack build --fast --jobs $(THREADS)

.PHONY : ci-build
ci-build:
stack build --fast --jobs $(THREADS) --pedantic
format:
@stack exec -- ormolu ${ORMOLUFLAGS} \
--ghc-opt -XStandaloneDeriving \
--ghc-opt -XUnicodeSyntax \
--ghc-opt -XDerivingStrategies \
--ghc-opt -XMultiParamTypeClasses \
--ghc-opt -XTemplateHaskell \
--ghc-opt -XImportQualifiedPost \
--mode ${ORMOLUMODE} \
$(ORMOLUFILES)

build-watch:
stack build --fast --file-watch
.PHONY: check-ormolu
check-ormolu: export ORMOLUMODE = check
check-ormolu:
make format

.PHONY : cabal
cabal :
cabal build all
.PHONY : hlint
hlint :
@hlint src app test ${HLINTQUIET}

clean:
cabal clean
stack clean
PRECOMMIT := $(shell command -v pre-commit 2> /dev/null)

clean-full:
stack clean --full
rm -rf .hie
rm -rf _docs
.PHONY : install-pre-commit
install-pre-commit :
@$(if $(PRECOMMIT),, pip install pre-commit)

.PHONY : test
test:
stack test --fast --jobs $(THREADS)
.PHONY : pre-commit
pre-commit :
@pre-commit run --all-files

.PHONY : ci-test
ci-test:
stack test --fast --jobs $(THREADS) --pedantic
# ------------------------------------------------------------------------------
# -- Build-Install-Test-Release
# ------------------------------------------------------------------------------

.PHONY : test-skip-slow
test-skip-slow:
stack test --fast --jobs $(THREADS) --ta '-p "! /slow tests/"'
STACKFLAGS?=--fast --jobs $(THREADS)

.PHONY : test-watch
test-watch:
stack test --fast --jobs $(THREADS) --file-watch
.PHONY: check
check:
@make build
@make install
@make test
@make test-shell
@make format
@make pre-commit

.PHONY : install-shelltest
install-shelltest:
stack install shelltestrunner
# -- Build requirements

.PHONY : test-shell
test-shell :
shelltest --color --diff -a -j8 tests
.PHONY: submodules
submodules:
@git submodule sync
@git submodule update --init --recursive

format:
@find . -name "*.hs" -exec ormolu --mode inplace {} --ghc-opt -XStandaloneDeriving --ghc-opt -XUnicodeSyntax --ghc-opt -XDerivingStrategies --ghc-opt -XMultiParamTypeClasses --ghc-opt -XTemplateHaskell --ghc-opt -XImportQualifiedPost \;
.PHONY : build
build: submodules
stack build ${STACKFLAGS}

.PHONY: check-ormolu
check-ormolu:
@find . -name "*.hs" -exec ormolu --mode check {} --ghc-opt -XStandaloneDeriving --ghc-opt -XUnicodeSyntax --ghc-opt -XDerivingStrategies --ghc-opt -XMultiParamTypeClasses --ghc-opt -XTemplateHaskell --ghc-opt -XImportQualifiedPost \;
# -- Install

.PHONY : install
install:
stack install --fast --jobs $(THREADS)

.PHONY : install-watch
install-watch:
stack install --fast --jobs $(THREADS) --file-watch

repl:
stack ghci Juvix:lib
install: submodules
@stack install ${STACKFLAGS}

.PHONY: html-examples
html-examples: $(EXAMPLES)
# -- Testing

$(EXAMPLES):
$(eval OUTPUTDIR=$(EXAMPLEHTMLOUTPUT)/$(dir $@))
mkdir -p ${OUTPUTDIR}
juvix html $(EXAMPLEMILESTONE)/$@ --recursive --output-dir=./../../../${OUTPUTDIR} --print-metadata
.PHONY : test
test: build
@stack test ${STACKFLAGS}

.PHONY : install-pre-commit
install-pre-commit:
pip install pre-commit
pre-commit install
.PHONY : test-skip-slow
test-skip-slow:
@stack test ${STACKFLAGS} --ta '-p "! /slow tests/"'

.PHONY : pre-commit
pre-commit :
pre-commit run --all-files
SHELLTEST := $(shell command -v shelltest 2> /dev/null)

.PHONY : update-submodules
update-submodules :
git submodule foreach git pull origin main
.PHONY : test-shell
test-shell : install
@$(if $(SHELLTEST),, stack install shelltestrunner)
shelltest --color --diff -a -j8 tests

.PHONY : juvix-stdlib
juvix-stdlib:
git submodule update --init juvix-stdlib
# -- Release

.PHONY : get-changelog-updates
get-changelog-updates :
@github_changelog_generator --since-tag $(shell git describe --tags $(shell git rev-list --tags --max-count=1)) 1> /dev/null
pandoc CHANGELOG.md --from markdown --to org -o UPDATES-FOR-CHANGELOG.org
.PHONY : changelog-updates
changelog-updates :
@github_changelog_generator
@pandoc CHANGELOG.md --from markdown --to org -o UPDATES-FOR-CHANGELOG.org

0 comments on commit 6a4b0e3

Please sign in to comment.