Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI to install Smoke, Github actions, and Makefile fixes #1735

Merged
merged 21 commits into from
Jan 24, 2023
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
88 changes: 56 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ on:
- reopened
- synchronize
- ready_for_review
- review_requested
- closed

concurrency:
Expand All @@ -32,8 +31,8 @@ jobs:
ormolu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: mrkkrp/ormolu-action@v6
- uses: actions/checkout@v3
- uses: mrkkrp/ormolu-action@v9
with:
extra-args: >-
--ghc-opt -XDerivingStrategies
Expand All @@ -46,31 +45,32 @@ jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jidicula/clang-format-action@v4.9.0
- uses: actions/checkout@v3
- uses: jidicula/clang-format-action@v4.10.1
with:
clang-format-version: '15'
check-path: 'runtime/src'

hlint:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Set up HLint'
uses: rwe/actions-hlint-setup@v1
uses: haskell/actions/hlint-setup@v2
with:
version: '3.4'
version: '3.5'
- name: 'Run HLint'
uses: rwe/actions-hlint-run@v2.0.1
uses: haskell/actions/hlint-run@v2
with:
path: '["src/", "app/", "test/"]'
fail-on: warning
# fail-on: warning

pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- uses: pre-commit/action@v3.0.0
with:
extra_args:
Expand Down Expand Up @@ -100,11 +100,11 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-12]
os: [macos-12 , ubuntu-20.04]
ghc: ["9.2.5"]
steps:
- name: Checkout our repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: main
submodules: true
Expand All @@ -125,7 +125,7 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-stack-work-

- uses: haskell/actions/setup@v1
- uses: haskell/actions/setup@v2
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
Expand Down Expand Up @@ -155,6 +155,16 @@ jobs:
echo "CC=$(brew --prefix llvm)/bin/clang" >> $GITHUB_ENV
echo "LIBTOOL=$(brew --prefix llvm)/bin/llvm-ar" >> $GITHUB_ENV

- name: Install ICU4C
if: startsWith(matrix.os, 'macos-')
run: |
brew install icu4c
brew link icu4c --force

- name: Install libicu for testing
if: startsWith(matrix.os, 'ubuntu-')
run: sudo apt install -y libicu66

- name: Build Project (macOS)
if: runner.os == 'macOS'
run: |
Expand All @@ -176,7 +186,7 @@ jobs:
ghc: ["9.2.5"]
steps:
- name: Checkout the main repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: main
submodules: recursive
Expand All @@ -197,7 +207,7 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-stack-work-

- uses: haskell/actions/setup@v1
- uses: haskell/actions/setup@v2
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
Expand Down Expand Up @@ -231,7 +241,7 @@ jobs:
echo "WASI_SYSROOT_PATH=$GITHUB_WORKSPACE/wasi-sysroot" >> $GITHUB_ENV

- name: Setup Wasmer
uses: wasmerio/setup-wasmer@v1
uses: wasmerio/setup-wasmer@v2

- name: Set homebrew LLVM CC and LIBTOOL vars (macOS)
if: runner.os == 'macOS'
Expand Down Expand Up @@ -269,28 +279,42 @@ jobs:

- name: Download Smoke binary
uses: jaxxstorm/action-install-gh-release@v1.9.0
if: runner.os == 'macOS'
with:
repo: SamirTalwar/smoke
tag: v2.3.1
repo: jonaprieto/smoke
tag: v2.3.2
cache: enable
extension-matching: disable
rename-to: smoke
chmod: 0755

- name : Smoke testing (Linux)
id: smoke-linux
if: runner.os == 'Linux'
run : |
cd main
make smoke

- name : Smoke testing (macOS)
id: smoke-macos
if: runner.os == 'macOS'
run : |
cd main
make CC=$CC LIBTOOL=$LIBTOOL smoke

- uses: actions/checkout@v3
if: runner.os == 'Linux'
with:
repository: jonaprieto/smoke
path: smoke

- name: Install Smoke
if: runner.os == 'Linux'
run: |
cd smoke
stack install
shell: bash

- name : Smoke testing (linux)
id: smoke-linux
if: runner.os == 'Linux'
run : |
cd main
make smoke

docs:
needs: build
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
Expand All @@ -301,7 +325,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout our repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: main
submodules: recursive
Expand All @@ -322,16 +346,16 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-stack-work-

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: '2.13'
pandoc-version: '2.19.2'

- name: MDBook setup
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: '0.4.22'

- uses: haskell/actions/setup@v1
- uses: haskell/actions/setup@v2
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
Expand Down
2 changes: 2 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
- ignore: {name: Use String}
- ignore: {name: Avoid restricted qualification}
- ignore: {name: Redundant multi-way if}
- ignore: {name: Redundant bracket}
- ignore: {name: Eta reduce}
- ignore: {name: Avoid restricted alias}
- ignore: {name: Use tuple-section}
- ignore: {name: Use map with tuple-section}
30 changes: 17 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
PWD=$(CURDIR)
PREFIX="$(PWD)/.stack-work/prefix"
UNAME := $(shell uname)
HLINTQUIET :=


IMAGES = $(shell find assets/images -type f)
IMAGES = $(shell find assets/images -type f)

ORGFILES = $(shell find docs/org -type f -name '*.org')
MDFILES:=$(patsubst docs/org/%,docs/md/%,$(ORGFILES:.org=.md))
Expand Down Expand Up @@ -125,13 +123,17 @@ haddock :
# -- Codebase Health
# ------------------------------------------------------------------------------

MAKEAUXFLAGS?=-s
MAKE=make ${MAKEAUXFLAGS}

ORMOLU?=stack exec -- ormolu
ORMOLUFILES = $(shell git ls-files '*.hs' '*.hs-boot' | grep -v '^contrib/')
ORMOLUFLAGS?=--no-cabal
ORMOLUMODE?=inplace

.PHONY: format
format: clang-format
@stack exec -- ormolu ${ORMOLUFLAGS} \
${ORMOLU} ${ORMOLUFLAGS} \
--ghc-opt -XStandaloneDeriving \
--ghc-opt -XUnicodeSyntax \
--ghc-opt -XDerivingStrategies \
Expand All @@ -143,16 +145,22 @@ format: clang-format

.PHONY: clang-format
clang-format:
@cd runtime && make format
@cd runtime && ${MAKE} format

.PHONY: check-ormolu
check-ormolu: export ORMOLUMODE = check
check-ormolu:
@make -s format
@${MAKE} format

HLINT?=stack exec -- hlint
HLINTFLAGS?=
HLINTQUIET :=

.PHONY : hlint
hlint :
@hlint src app test ${HLINTQUIET}
${HLINT} ${HLINTFLAGS} app ${HLINTQUIET}
${HLINT} ${HLINTFLAGS} src ${HLINTQUIET}
${HLINT} ${HLINTFLAGS} test ${HLINTQUIET}

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

Expand All @@ -168,9 +176,6 @@ pre-commit :
# -- Build-Install-Test-Release
# ------------------------------------------------------------------------------

MAKEAUXFLAGS?=-s
MAKE=make ${MAKEAUXFLAGS}

STACKFLAGS?=--jobs $(THREADS)
STACKTESTFLAGS?=--ta --hide-successes --ta --ansi-tricks=false
SMOKEFLAGS?=--color --diff=git
Expand Down Expand Up @@ -234,10 +239,9 @@ fast-test-skip-slow:
SMOKE := $(shell command -v smoke 2> /dev/null)

.PHONY : smoke
smoke: install
smoke: install submodules
@$(if $(SMOKE),, $(error "Smoke not found, please install it from https://github.com/SamirTalwar/smoke"))
@find tests/smoke -type f -name '*.smoke.yaml' \
-exec sh -c "echo -n 'Running {}'; echo ; ${SMOKE} ${SMOKEFLAGS} {}" \;
@smoke $(shell find tests -name '*.smoke.yaml')

# -- Release

Expand Down
18 changes: 9 additions & 9 deletions app/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data RunAppIOArgs = RunAppIOArgs

runAppIO ::
forall r a.
Member (Embed IO) r =>
(Member (Embed IO) r) =>
RunAppIOArgs ->
Sem (App ': r) a ->
Sem r a
Expand Down Expand Up @@ -92,15 +92,15 @@ getEntryPoint' RunAppIOArgs {..} inputFile = do
_entryPointStdin = estdin
}

someBaseToAbs' :: Members '[App] r => SomeBase a -> Sem r (Path Abs a)
someBaseToAbs' :: (Members '[App] r) => SomeBase a -> Sem r (Path Abs a)
someBaseToAbs' f = do
r <- askInvokeDir
return (someBaseToAbs r f)

askGenericOptions :: Members '[App] r => Sem r GenericOptions
askGenericOptions :: (Members '[App] r) => Sem r GenericOptions
askGenericOptions = project <$> askGlobalOptions

getEntryPoint :: Members '[Embed IO, App] r => AppPath File -> Sem r EntryPoint
getEntryPoint :: (Members '[Embed IO, App] r) => AppPath File -> Sem r EntryPoint
getEntryPoint inputFile = do
_runAppIOArgsGlobalOptions <- askGlobalOptions
_runAppIOArgsPkgDir <- askPkgDir
Expand All @@ -109,20 +109,20 @@ getEntryPoint inputFile = do
_runAppIOArgsInvokeDir <- askInvokeDir
embed (getEntryPoint' (RunAppIOArgs {..}) inputFile)

runPipeline :: Member App r => AppPath File -> Sem PipelineEff a -> Sem r a
runPipeline :: (Member App r) => AppPath File -> Sem PipelineEff a -> Sem r a
runPipeline input p = do
r <- runPipelineEither input p
case r of
Left err -> exitJuvixError err
Right res -> return (snd res)

newline :: Member App r => Sem r ()
newline :: (Member App r) => Sem r ()
newline = say ""

printSuccessExit :: Member App r => Text -> Sem r a
printSuccessExit :: (Member App r) => Text -> Sem r a
printSuccessExit = exitMsg ExitSuccess

printFailureExit :: Member App r => Text -> Sem r a
printFailureExit :: (Member App r) => Text -> Sem r a
printFailureExit = exitMsg (ExitFailure 1)

getRight :: (Members '[App] r, AppError e) => Either e a -> Sem r a
Expand All @@ -135,4 +135,4 @@ instance AppError JuvixError where
appError = exitJuvixError

class AppError e where
appError :: Members '[App] r => e -> Sem r a
appError :: (Members '[App] r) => e -> Sem r a
2 changes: 1 addition & 1 deletion app/AsmInterpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Juvix.Compiler.Asm.Interpreter qualified as Asm
import Juvix.Compiler.Asm.Pretty qualified as Asm
import Juvix.Compiler.Asm.Transformation.Validate qualified as Asm

runAsm :: forall r. Members '[Embed IO, App] r => Bool -> Asm.InfoTable -> Sem r ()
runAsm :: forall r. (Members '[Embed IO, App] r) => Bool -> Asm.InfoTable -> Sem r ()
runAsm bValidate tab =
let v = if bValidate then Asm.validate' tab else Nothing
in case v of
Expand Down
Loading