-
Notifications
You must be signed in to change notification settings - Fork 81
147 lines (146 loc) · 4.15 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: CI
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
jobs:
ci:
strategy:
fail-fast: false
matrix:
ghc: [ghc928, ghc945, ghc962]
name: Build and test on ${{ matrix.ghc }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
accept-flake-config = true
- uses: cachix/cachix-action@v12
with:
name: tweag-ormolu
authToken: '${{ secrets.CACHIX_TWEAG_ORMOLU_AUTH_TOKEN }}'
- name: Build and run tests
run: |
nix build -L --keep-going .#${{ matrix.ghc }}.ci
lint:
needs: ci
name: Formatting and linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
accept-flake-config = true
- name: Format via Cabal and Ormolu
run: |
nix run .#format
git diff --exit-code --color=always
- name: pre-commit-check
run: |
nix build -L .#pre-commit-check
live-wasm:
needs: lint
name: Build Ormolu WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
accept-flake-config = true
- uses: actions/cache@v3
with:
path: |
~/.ghc-wasm/.cabal/store
ormolu-live/dist-newstyle
key: wasm-${{ github.run_id }}
restore-keys: |
wasm-${{ github.run_id }}
wasm-
- name: Build Ormolu WASM
run: |
cd ormolu-live
nix develop .#ghcWasm -c sh -c \
'wasm32-wasi-cabal update && ./build-wasm.sh -Oz'
- uses: actions/upload-artifact@v3
with:
name: wasm
path: ormolu-live/src/ormolu.wasm
live-frontend:
needs: lint
name: Build Ormolu Live frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
accept-flake-config = true
- uses: cachix/cachix-action@v12
with:
name: tweag-ormolu
authToken: '${{ secrets.CACHIX_TWEAG_ORMOLU_AUTH_TOKEN }}'
- name: Build frontend
run: |
nix build -L .#ormoluLive
cp -r --no-preserve=mode,ownership result/ site
- uses: actions/upload-artifact@v3
with:
name: frontend
path: site/
live-deploy:
needs: [live-wasm, live-frontend]
name: Deploy Ormolu Live
runs-on: ubuntu-latest
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
steps:
- uses: actions/download-artifact@v3
- name: Combine
run: |
cp wasm/ormolu.wasm frontend/ormolu.*.wasm
- uses: geekyeggo/delete-artifact@v2
with:
name: |
wasm
frontend
- name: Deploy to Netlify, preview
if: env.NETLIFY_AUTH_TOKEN != ''
uses: nwtgck/actions-netlify@v2
with:
publish-dir: ./frontend
github-token: ${{ secrets.GITHUB_TOKEN }}
alias: ${{ github.event.pull_request.head.sha || github.sha }}
enable-pull-request-comment: true
enable-commit-comment: false
enable-commit-status: true
- name: Deploy to Netlify, production
if: env.NETLIFY_AUTH_TOKEN != '' && github.ref == 'refs/heads/master'
run: |
netlify deploy --prod -d ./frontend
# prevent stack.yaml from becoming outdated
stack:
name: Build and test via Stack
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: haskell/actions/setup@v2
with:
enable-stack: true
stack-no-global: true
- uses: actions/cache@v3
with:
path: ~/.stack
key: stack-${{ hashFiles('stack.yaml', 'ormolu.cabal') }}
- name: Build
run: stack build
- name: Test
run: stack test