├── .github └── workflows │ └── ci.yml ├── .gitignore ├── Dockerfile ├── HelloIdris2 ├── Greet.idr └── Main.idr ├── Makefile ├── README.md ├── helloidris2.ipkg └── tests ├── Main.idr ├── Makefile ├── helloidris2 ├── test001 │ ├── Main.idr │ ├── expected │ ├── input │ └── run └── test002 │ ├── Greet.idr │ ├── expected │ └── run └── tests.ipkg /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Ubuntu 2 | on: 3 | push: 4 | branches: 5 | - '**' 6 | tags: 7 | - '**' 8 | pull_request: 9 | branches: 10 | - $default-branch 11 | 12 | env: 13 | SCHEME: scheme 14 | IDRIS2_TESTS_CG: chez 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-latest 19 | container: snazzybucket/idris2:latest 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@v2 23 | - name: idris build and test 24 | run: | 25 | make clean && make build && make install && make test INTERACTIVE='' 26 | shell: bash 27 | build-docker: 28 | runs-on: ubuntu-latest 29 | steps: 30 | - name: Checkout 31 | uses: actions/checkout@v2 32 | - name: build docker image 33 | run: | 34 | make clean 35 | make docker-build 36 | shell: bash 37 | - name: test docker image 38 | run: | 39 | make docker-run 40 | shell: bash 41 | generate-docs: 42 | needs: [build, build-docker] 43 | runs-on: ubuntu-latest 44 | container: snazzybucket/idris2:latest 45 | steps: 46 | - name: Checkout 47 | uses: actions/checkout@v2 48 | - name: generate docs 49 | run: | 50 | make docs 51 | shell: bash 52 | - name: Upload Artifacts 53 | uses: actions/upload-artifact@v1 54 | with: 55 | name: docs 56 | path: build/docs 57 | deploy-docs: 58 | needs: [generate-docs] 59 | if: ${{ github.ref == 'refs/heads/$default-branch' }} 60 | runs-on: ubuntu-latest 61 | steps: 62 | - name: Checkout 63 | uses: actions/checkout@v2.3.1 64 | - name: Download Artifacts 65 | uses: actions/download-artifact@v1 66 | with: 67 | name: docs 68 | - name: Deploy 🚀 69 | uses: JamesIves/github-pages-deploy-action@4.1.3 70 | with: 71 | token: ${{ secrets.GITHUB_TOKEN }} 72 | branch: gh-pages 73 | folder: 'docs' 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.ibc 2 | *.idr~ 3 | build/ 4 | 5 | /tests/**/build 6 | /tests/**/output 7 | /tests/**/*.so 8 | /tests/**/*.dylib 9 | /tests/**/*.dll 10 | /tests/build/exec 11 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM snazzybucket/idris2:latest as builder 2 | 3 | RUN mkdir /opt/hello-idris2 4 | WORKDIR /opt/hello-idris2 5 | 6 | COPY . ./ 7 | RUN true 8 | 9 | RUN make build-executable 10 | RUN pwd 11 | RUN ls -R build 12 | 13 | FROM ubuntu:20.04 14 | 15 | RUN apt-get update && apt-get install --yes chezscheme && rm -rf /var/lib/apt/lists/* 16 | 17 | RUN mkdir -p /opt/hello-idris2/exec 18 | 19 | COPY --from=builder /opt/hello-idris2/build/exec /opt/hello-idris2/exec 20 | 21 | ENV PATH="/opt/hello-idris2/exec:${PATH}" 22 | 23 | ENTRYPOINT /opt/hello-idris2/exec/helloIdris2 24 | -------------------------------------------------------------------------------- /HelloIdris2/Greet.idr: -------------------------------------------------------------------------------- 1 | module HelloIdris2.Greet -- module name must be the same as file name, and upper case 2 | 3 | ||| Given a name, this function will say hello 4 | export 5 | greet : String -> String 6 | greet name = "hello " ++ name 7 | -------------------------------------------------------------------------------- /HelloIdris2/Main.idr: -------------------------------------------------------------------------------- 1 | module HelloIdris2.Main 2 | 3 | import HelloIdris2.Greet 4 | 5 | ||| Call greet twice 6 | export 7 | multigreet : IO () 8 | multigreet = do 9 | printLn $ greet "once" 10 | printLn $ greet "again" 11 | 12 | ||| The entrypoint of the app 13 | main : IO () 14 | main = printLn $ greet "idris2" 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | repl: 2 | rlwrap idris2 HelloIdris2/Main.idr 3 | 4 | edit-tests1: 5 | cd ./tests/helloidris2/test001 && rlwrap idris2 -p helloidris2 Main.idr 6 | 7 | edit-tests2: 8 | cd ./tests/helloidris2/test002 && rlwrap idris2 -p helloidris2 Greet.idr 9 | 10 | clean: 11 | rm -f tests/*.idr~ 12 | rm -f tests/*.ibc 13 | rm -f Idrall/*.idr~ 14 | rm -f Idrall/*.ibc 15 | rm -rf build/ 16 | rm -rf tests/build/ 17 | 18 | .PHONY: build 19 | build: 20 | idris2 --build helloidris2.ipkg 21 | 22 | # this step is covered by `make build` if have set `main` and `executable` set in the `.ipkg` file. 23 | build-executable: build # Has a dependency on build, not sure why 24 | idris2 ./HelloIdris2/Main.idr -o helloIdris2 # this is the name of the executable 25 | # it will be created in ./build/exec/ 26 | 27 | run-executable: build-executable 28 | ./build/exec/helloIdris2 29 | 30 | install: 31 | idris2 --install helloidris2.ipkg 32 | 33 | testbin: 34 | @${MAKE} -C tests testbin 35 | 36 | # run like: `make test only=test002` 37 | test-only: 38 | ${MAKE} -C tests only=$(only) 39 | 40 | # only run the tests that fail during the last run 41 | retest-only: 42 | ${MAKE} -C tests retest 43 | 44 | test: build install testbin test-only 45 | retest: build install testbin retest-only 46 | 47 | time-time: 48 | time ${MAKE} test INTERACTIVE='' 49 | 50 | docs: 51 | idris2 --mkdoc helloidris2.ipkg 52 | 53 | docker-build: 54 | docker build . -t snazzybucket/hello-idris2 55 | 56 | docker-run: 57 | docker run snazzybucket/hello-idris2 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![ci](https://github.com/alexhumphreys/hello-idris2/actions/workflows/ci.yml/badge.svg)](https://github.com/alexhumphreys/hello-idris2/actions/workflows/ci.yml) 2 | 3 | # Hello Idris2 4 | 5 | This is a template of an idris2 project. It has some simple modules setup, golden tests created, and a github action to run them. 6 | 7 | There's comments scattered throughout that'll hopefully help you customise this to your own needs. 8 | 9 | This is still an early draft for this, so if you can think of any features that would be good to showcase, comments to add, package manages to configure, please do contribute them! And feel free to open issues if you run into any. 10 | 11 | ## Running 12 | 13 | To build this project, run: 14 | 15 | ``` 16 | make build 17 | ``` 18 | 19 | To test this project, run: 20 | 21 | ``` 22 | make test 23 | ``` 24 | 25 | To create and run an executable, run: 26 | 27 | ``` 28 | make run-executable 29 | ``` 30 | 31 | There's some other `make` tasks for editing files (using `rlwrap` to make the repl behave better), and for docker and documentation. Take a look to see. 32 | 33 | ## Documentation 34 | 35 | The CI job also builds a docs site (using the command `idris2 --mkdoc`) and publishes it to Github Pages. You can see the one for this project at https://alexhumphreys.github.io/hello-idris2/ 36 | -------------------------------------------------------------------------------- /helloidris2.ipkg: -------------------------------------------------------------------------------- 1 | package helloidris2 2 | 3 | -- `sourcedir` 4 | -- The `./HelloIdris2` dir is in the root of the repo, so this is `"./"` 5 | -- If you were to move that to `"./src/` then you'd update this field 6 | sourcedir = "./" 7 | 8 | -- `depends` 9 | -- This is a comma separated list of deps, eg: `depends = base, contrib` 10 | depends = base 11 | 12 | -- `modules` 13 | -- This is a comma separated list of the modules you'll want to export 14 | -- to the final artifact 15 | modules = 16 | HelloIdris2.Main, 17 | HelloIdris2.Greet 18 | 19 | -- `main` 20 | -- the entrypoint for the main function for the executable 21 | main = HelloIdris2.Main 22 | 23 | -- `executable` 24 | -- the name of the executable in the `./build/exec/` dir 25 | executable = helloIdris2 26 | -------------------------------------------------------------------------------- /tests/Main.idr: -------------------------------------------------------------------------------- 1 | module Main 2 | 3 | import Test.Golden 4 | 5 | %default covering 6 | 7 | allTests : TestPool 8 | allTests = MkTestPool "Name of the pool" [] Default 9 | [ "test001" 10 | , "test002" -- To add more tests, copy one of the test directories, then update this list 11 | ] 12 | 13 | main : IO () 14 | main = runner 15 | [ testPaths "helloidris2" allTests 16 | ] where 17 | testPaths : String -> TestPool -> TestPool 18 | testPaths dir = record { testCases $= map ((dir ++ "/") ++) } 19 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | INTERACTIVE ?= --interactive 2 | 3 | .PHONY: testbin test 4 | 5 | test: 6 | ./build/exec/runtests idris2 $(INTERACTIVE) --failure-file failures --only $(only) 7 | 8 | retest: 9 | @touch failures 10 | ./build/exec/runtests idris2 $(INTERACTIVE) --failure-file failures --only-file failures --only $(only) 11 | 12 | testbin: 13 | idris2 --build tests.ipkg 14 | 15 | clean: 16 | $(RM) -r build 17 | @find . -type f -name 'output' -exec rm -rf {} \; 18 | @find . -type f -name '*.ttc' -exec rm -f {} \; 19 | @find . -type f -name '*.ttm' -exec rm -f {} \; 20 | @find . -type f -name '*.ibc' -exec rm -f {} \; 21 | -------------------------------------------------------------------------------- /tests/helloidris2/test001/Main.idr: -------------------------------------------------------------------------------- 1 | module Main 2 | 3 | import HelloIdris2.Main 4 | 5 | main : IO () 6 | main = do HelloIdris2.Main.multigreet 7 | -------------------------------------------------------------------------------- /tests/helloidris2/test001/expected: -------------------------------------------------------------------------------- 1 | 1/1: Building Main (Main.idr) 2 | Main> "hello once" 3 | "hello again" 4 | Main> Bye for now! 5 | -------------------------------------------------------------------------------- /tests/helloidris2/test001/input: -------------------------------------------------------------------------------- 1 | :exec main 2 | :q 3 | -------------------------------------------------------------------------------- /tests/helloidris2/test001/run: -------------------------------------------------------------------------------- 1 | $1 --no-banner --no-color --console-width 0 -p helloidris2 Main.idr < input 2 | 3 | rm -rf build 4 | -------------------------------------------------------------------------------- /tests/helloidris2/test002/Greet.idr: -------------------------------------------------------------------------------- 1 | module Main 2 | 3 | import HelloIdris2.Greet 4 | 5 | main : IO () 6 | main = do 7 | printLn $ greet "world" 8 | printLn $ greet "idris2" 9 | -------------------------------------------------------------------------------- /tests/helloidris2/test002/expected: -------------------------------------------------------------------------------- 1 | "hello world" 2 | "hello idris2" 3 | -------------------------------------------------------------------------------- /tests/helloidris2/test002/run: -------------------------------------------------------------------------------- 1 | $1 --no-banner --no-color --console-width 0 -p helloidris2 Greet.idr --client ":exec main" 2 | 3 | rm -rf build 4 | -------------------------------------------------------------------------------- /tests/tests.ipkg: -------------------------------------------------------------------------------- 1 | package runtests 2 | 3 | depends = contrib, test, helloidris2 -- make sure to depend on your own project 4 | main = Main 5 | 6 | executable = runtests -- the name of the executable that is created in `./build/exec` 7 | --------------------------------------------------------------------------------