1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-17 03:45:00 +03:00
juvix/.github/workflows/ci.yml
Jonathan Cubides 839093cdbd
CI pre-commit maintenance (#1905)
This PR goes after:
- #1797 

Included in this PR:

- Add Clang formatting (v.15) as part of the pre-commits.
- Add new pre-commits:
   - forbid binary files 
   - check toml files for mdbook
   - detect-private-key
- format-juvix-examples: check all the Juvix programs in the `examples`
folder type-check for local runs.
- Remove .pre-commit-hooks and add ormolu for local pre-commit runs
instead.
2023-03-23 08:57:38 +00:00

313 lines
7.7 KiB
YAML

name: The Juvix compiler CI
"on":
workflow_dispatch:
inputs:
ref:
description: the repository ref to build
required: true
default: main
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true
env:
SKIP: ormolu,format-juvix-examples
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: pre-commit/action@v3.0.0
ormolu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: mrkkrp/ormolu-action@v11
with:
version: 0.5.2.0
extra-args: >-
--ghc-opt -XDerivingStrategies --ghc-opt -XImportQualifiedPost
--ghc-opt -XMultiParamTypeClasses --ghc-opt -XStandaloneDeriving
--ghc-opt -XTemplateHaskell --ghc-opt -XUnicodeSyntax
build-and-test-linux:
runs-on: ubuntu-20.04
steps:
- name: Checkout our repository
uses: actions/checkout@v3
with:
path: main
submodules: true
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v3
with:
path: |
C:/Program Files/LLVM
./llvm
key: "${{ runner.os }}-llvm-13"
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "13.0"
cached: "${{ steps.cache-llvm.outputs.cache-hit }}"
- name: Download and extract wasi-sysroot
run: >
curl
https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/wasi-sysroot-15.0.tar.gz
-OL
tar xfv wasi-sysroot-15.0.tar.gz
- name: Set WASI_SYSROOT_PATH
run: |
echo "WASI_SYSROOT_PATH=$GITHUB_WORKSPACE/wasi-sysroot" >> $GITHUB_ENV
- name: Install the latest Wasmer version
uses: jaxxstorm/action-install-gh-release@v1.10.0
with:
repo: wasmerio/wasmer
tag: latest
binaries-location: bin
cache: true
- name: Install libicu for testing
run: sudo apt install -y libicu66
- name: Make runtime
run: |
cd main
make runtime
- name: Stack setup
uses: freckle/stack-action@v4
with:
working-directory: main
test: false
- name: Install and test Juvix
id: test
if: ${{ success() }}
run: |
cd main
make install
make test
- name: Typecheck and format Juvix examples
if: ${{ success() }}
run: |
cd main
make -s juvix-format
- name: Add ~/.local/bin to PATH
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
- uses: actions/checkout@v3
with:
repository: jonaprieto/smoke
path: smoke
- uses: freckle/stack-cache-action@v2
with:
working-directory: smoke
- name: Install Smoke
run: |
cd smoke
stack install --stack-root ${{ github.workspace }}/.stack
shell: bash
- name: Smoke testing
id: smoke-linux
if: ${{ success() }}
run: |
cd main
make smoke
docs-linux:
needs: build-and-test-linux
if: >-
github.ref == 'refs/heads/main' || github.event_name ==
'workflow_dispatch'
runs-on: ubuntu-20.04
steps:
- name: Checkout our repository
uses: actions/checkout@v3
with:
path: main
submodules: recursive
- name: Install mdbook-pagetoc
uses: baptiste0928/cargo-install@v1
with:
crate: mdbook-pagetoc
- name: Install mdbook-katex
uses: baptiste0928/cargo-install@v1
with:
crate: mdbook-katex
- name: Install mdbook-linkcheck
uses: baptiste0928/cargo-install@v1
with:
crate: mdbook-linkcheck
- name: MDBook setup
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: "latest"
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v3
with:
path: |
C:/Program Files/LLVM
./llvm
key: "${{ runner.os }}-llvm-13"
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "13.0"
cached: "${{ steps.cache-llvm.outputs.cache-hit }}"
- name: Build the mdbook
run: |
cd main
make docs
- name: Make runtime
run: |
cd main
make runtime
- name: Stack setup
uses: freckle/stack-action@v4
with:
working-directory: main
test: false
- name: Generate HTML files from examples
run: |
cd main
echo "$GITHUB_WORKSPACE/.local/bin" >> $GITHUB_PATH
make install
make html-examples
make demo-example
# TODO: use new action 'pages deploy'
- name: Deploy HTML to github pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
publish_dir: main/book/html
enable_jekyll: false
cname: docs.juvix.org
build-and-test-macos:
runs-on: macos-12
steps:
- name: Checkout our repository
uses: actions/checkout@v3
with:
path: main
submodules: true
- name: Install ICU4C
run: |
brew install icu4c
brew link icu4c --force
- name: Download and extract wasi-sysroot
run: >
curl
https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-15/wasi-sysroot-15.0.tar.gz
-OL
tar xfv wasi-sysroot-15.0.tar.gz
- name: Set WASI_SYSROOT_PATH
run: |
echo "WASI_SYSROOT_PATH=$GITHUB_WORKSPACE/wasi-sysroot" >> $GITHUB_ENV
- name: Install the latest Wasmer version
uses: jaxxstorm/action-install-gh-release@v1.10.0
with:
repo: wasmerio/wasmer
tag: latest
binaries-location: bin
cache: true
- name: Set homebrew LLVM CC and LIBTOOL vars (macOS)
run: |
echo "CC=$(brew --prefix llvm)/bin/clang" >> $GITHUB_ENV
echo "LIBTOOL=$(brew --prefix llvm)/bin/llvm-ar" >> $GITHUB_ENV
- name: Make runtime
run: |
cd main
make CC=$CC LIBTOOL=$LIBTOOL runtime
- name: Stack setup
uses: freckle/stack-action@v4
with:
working-directory: main
test: false
- name: Add homebrew clang to the PATH (macOS)
run: |
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
- name: Install and test Juvix
if: ${{ success() }}
run: |
cd main
make CC=$CC LIBTOOL=$LIBTOOL install
make CC=$CC LIBTOOL=$LIBTOOL test
- name: Add ~/.local/bin to PATH
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Typecheck and format Juvix examples
if: ${{ success() }}
run: |
cd main
make -s juvix-format
- name: Install Smoke
uses: jaxxstorm/action-install-gh-release@v1.10.0
with:
repo: jonaprieto/smoke
tag: latest
extension-matching: disable
rename-to: smoke
chmod: 0755
- name: Smoke testing (macOS)
id: smoke-macos
if: ${{ success() }}
run: |
cd main
make CC=$CC LIBTOOL=$LIBTOOL smoke