Skip to content

Commit d824bc9

Browse files
amesgenmrkkrp
andcommitted
Add WASM-based Ormolu Live
Co-authored-by: Mark Karpov <mark.karpov@tweag.io>
1 parent de79216 commit d824bc9

31 files changed

+13699
-419
lines changed

.github/workflows/ci.yml

+85
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,88 @@ jobs:
4949
- name: pre-commit-check
5050
run: |
5151
nix build -L .#pre-commit-check
52+
live-wasm:
53+
needs: lint
54+
name: Build Ormolu WASM
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v3
58+
- uses: cachix/install-nix-action@v18
59+
with:
60+
# https://github.com/NixOS/nix/issues/7644
61+
install_url: https://releases.nixos.org/nix/nix-2.12.0/install
62+
extra_nix_config: |
63+
accept-flake-config = true
64+
- uses: actions/cache@v3
65+
with:
66+
path: |
67+
~/.ghc-wasm/.cabal/store
68+
ormolu-live/dist-newstyle
69+
key: wasm-${{ github.run_id }}
70+
restore-keys: |
71+
wasm-${{ github.run_id }}
72+
wasm-
73+
- name: Build Ormolu WASM
74+
run: |
75+
cd ormolu-live
76+
nix develop .#ghcWasm -c sh -c \
77+
'wasm32-wasi-cabal update && ./build-wasm.sh -Oz'
78+
- uses: actions/upload-artifact@v3
79+
with:
80+
name: wasm
81+
path: ormolu-live/src/ormolu.wasm
82+
live-frontend:
83+
needs: lint
84+
name: Build Ormolu Live frontend
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v3
88+
- uses: cachix/install-nix-action@v18
89+
with:
90+
# https://github.com/NixOS/nix/issues/7644
91+
install_url: https://releases.nixos.org/nix/nix-2.12.0/install
92+
extra_nix_config: |
93+
accept-flake-config = true
94+
- uses: cachix/cachix-action@v12
95+
with:
96+
name: tweag-ormolu
97+
authToken: '${{ secrets.CACHIX_TWEAG_ORMOLU_AUTH_TOKEN }}'
98+
- name: Build frontend
99+
run: |
100+
nix build -L .#ormoluLive
101+
cp -r --no-preserve=mode,ownership result/ site
102+
- uses: actions/upload-artifact@v3
103+
with:
104+
name: frontend
105+
path: site/
106+
live-deploy:
107+
needs: [live-wasm, live-frontend]
108+
name: Deploy Ormolu Live
109+
runs-on: ubuntu-latest
110+
env:
111+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
112+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
113+
steps:
114+
- uses: actions/download-artifact@v3
115+
- name: Combine
116+
run: |
117+
cp wasm/ormolu.wasm frontend/ormolu.*.wasm
118+
- uses: geekyeggo/delete-artifact@v2
119+
with:
120+
name: |
121+
wasm
122+
frontend
123+
- name: Deploy to Netlify, preview
124+
if: env.NETLIFY_AUTH_TOKEN != ''
125+
uses: nwtgck/actions-netlify@v2
126+
with:
127+
publish-dir: ./frontend
128+
github-token: ${{ secrets.GITHUB_TOKEN }}
129+
alias: ${{ github.event.pull_request.head.sha || github.sha }}
130+
enable-pull-request-comment: true
131+
enable-commit-comment: false
132+
enable-commit-status: true
133+
- name: Deploy to Netlify, production
134+
if: env.NETLIFY_AUTH_TOKEN != '' && github.ref == 'refs/heads/master'
135+
run: |
136+
netlify deploy --prod -d ./frontend

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ result*
3232
# These are touched on every :reload in GHCi.
3333
# https://gitlab.haskell.org/ghc/ghc/-/issues/22669
3434
*.o-boot
35+
36+
# Local Netlify folder
37+
.netlify

0 commit comments

Comments
 (0)