-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
232 lines (203 loc) · 8.66 KB
/
waspc-ci.yaml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: WASPC-CI
on:
push:
paths:
- 'waspc/**'
branches:
- main
- release
pull_request:
paths:
- 'waspc/**'
create: { tags: [v*] }
schedule:
# Additionally run once per week (At 00:00 on Sunday) to avoid loosing cache
# (GH deletes it after 7 days of not using it).
- cron: '0 0 * * 0'
env:
WASP_TELEMETRY_DISABLE: 1
defaults:
run:
shell: bash
working-directory: waspc
jobs:
cancel:
name: Cancel redundant actions already in progress
runs-on: ubuntu-latest
steps:
- name: Cancel actions in progress of same workflow and same branch
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
build:
name: Build Wasp
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
# Using Ubuntu 20.04 due to recent GLIBC_2.34 version mismatch errors for
# users and other services. The strategy here is to pick a slightly older LTS
# version of Ubuntu to build on so glibc is not too new. glibc has great backward
# compatibility though, so older builds will run on new OSs (but not vice versa).
# We can return to `ubuntu-latest` when enough time has elapsed.
# Still looking into musl static binaries.
# Ref: https://github.com/wasp-lang/wasp/issues/650
- ubuntu-20.04
- macos-latest
- windows-latest
node-version:
- 'latest'
ghc:
- '8.10.7'
cabal:
- '3.6.2.0'
# In addition to the default matrix, we also want to run the build job for
# additional Node.js versions, to make sure that Wasp works with them.
# To reduce the number of jobs, we only test the Node.js versions on
# Ubuntu 20.04.
include:
- os: ubuntu-20.04
node-version: 18
ghc: '8.10.7'
cabal: '3.6.2.0'
- os: ubuntu-20.04
node-version: 20
ghc: '8.10.7'
cabal: '3.6.2.0'
steps:
- name: Configure git
working-directory: ~
# For waspc parser tests, we need to make sure git doesn't convert line
# endings to CRLF during checkout on Windows because that would cause
# the test cases to fail.
run: |
git config --global core.autocrlf input
git config --global core.eol lf
- uses: 'actions/checkout@v3'
with:
# Workaround for a Github Checkout action bug
# https://github.com/actions/checkout/issues/1359#issuecomment-1567902034
ref: ${{ github.event.pull_request.head.sha }}
# TODO: This is a temporary workaround for the failing GHCup installation on Ubuntu 20.04.
# The fix will be propagated in a few days, so we can remove this workaround then.
# https://github.com/actions/runner-images/issues/7061
- name: Workaround runner image issue
if: matrix.os == 'ubuntu-20.04'
run: sudo chown -R $USER /usr/local/.ghcup
- name: Set up Haskell
id: setup-haskell-cabal
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- name: Verify Haskell setup
run: |
ghc --version
cabal --version
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache
uses: actions/cache@v3
with:
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
# TODO: Right now, actions/cache updates cache only if cache was not fe
# This is not ideal for us, because we would ideally update cache even if it
# was fetched, because we want to cache any newly installed packages.
# This was working normally on Travis and Appveyor.
# There is an issue for this, and for now we are using proposed "fix" from it,
# https://github.com/actions/cache/issues/342#issuecomment-673371329,
# which mitigates the problem by creating new cache for each job and then using
# the feature of restore-keys which makes sure that next cache picked is the
# latest one. However, this keeps creating new cache each time which is not
# ideal because caches keep getting evicted, so for example if Win job
# fails multiple times while others don't, its cache will likely get evicted,
# making it even slower to test and fix (uffff).
# When they fix this, we should remove ${{ github.run_id }} from the end of the key.
key: wasp-build-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('waspc/waspc.cabal') }}-${{ hashFiles('waspc/cabal.project') }}-${{ github.run_id }}
restore-keys: wasp-build-${{ matrix.os }}-${{ matrix.ghc }}-
- name: Check Haskell code formatting
if: matrix.os == 'ubuntu-20.04'
run: ./run ormolu:check
- name: packages/ts-inspect - Run tests
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-latest'
run: |
cd packages/ts-inspect
npm ci
npm test
- name: Compile TS packages and move it into the Cabal data dir
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-latest'
run: ./tools/install_packages_to_data_dir.sh
- name: Build external dependencies
run: cabal build --enable-tests --enable-benchmarks --only-dependencies
- name: Build wasp code
run: cabal build all
- name: On MacOS, skip e2e tests with Docker since it is not installed
if: matrix.os == 'macos-latest'
run: export WASP_E2E_TESTS_SKIP_DOCKER=1
- name: Run unit tests
run: cabal test cli-test waspc-test waspls-test
- name: Ensure examples/todoApp compiles and builds
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-latest'
run: ./examples/todoApp/ensure_app_compiles_and_builds.sh
- name: Headless - Cache Node Modules
id: headless-cache-node-modules
uses: actions/cache@v3
if: matrix.os == 'ubuntu-20.04'
with:
path: ~/.npm
key: node-modules-${{ hashFiles('./waspc/headless-test/package-lock.json') }}-${{ matrix.os }}-${{ matrix.node-version }}
- name: Headless - Install Dependencies
id: headless-install-dependencies
if: matrix.os == 'ubuntu-20.04'
run: |
cd headless-test
npm ci
- name: Headless - Store Playwright's Version
id: headless-store-playwright-version
if: matrix.os == 'ubuntu-20.04'
run: |
cd headless-test
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Headless - Cache Playwright Browsers for Playwright's Version
id: headless-cache-playwright-browsers
if: matrix.os == 'ubuntu-20.04'
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}
- name: Headless - Setup Playwright
id: headless-setup-playwright
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' && matrix.os == 'ubuntu-20.04'
run: |
cd headless-test
npx playwright install --with-deps
- name: Headless - Run Playwright Tests
id: headless-run-playwright-tests
if: matrix.os == 'ubuntu-20.04'
run: |
cd headless-test
npm ci
# Runs the tests with the debug flag so that we can see Wasp output
DEBUG=pw:webserver npx playwright test
- name: Run e2e tests
run: cabal test e2e-test
- name: Create binary package (Unix)
if: startsWith(github.ref, 'refs/tags/v') && (matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-latest') && matrix.node-version == 'latest'
run: |
OS_NAME=`case "${{ runner.os }}" in Linux) echo "linux";; macOS) echo "macos";; *) exit 1;; esac`
mkdir artifacts
./tools/make_binary_package.sh "artifacts/wasp-$OS_NAME-x86_64.tar.gz"
- name: Create Github release
uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/v') && (matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-latest') && matrix.node-version == 'latest'
with:
draft: true
allowUpdates: true
artifacts: 'waspc/artifacts/*'
artifactErrorsFailBuild: true
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}