-
Notifications
You must be signed in to change notification settings - Fork 7
143 lines (116 loc) · 4.98 KB
/
build.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
name: Build
on:
push:
branches: ["master"]
pull_request:
types: [ opened, synchronize ]
workflow_dispatch:
# automatically cancel previous runs on the same PR
# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre/67939898#67939898
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
# https://github.com/actions/checkout/issues/626
# This is correct, because we're using a merge queue (mergify) which only merges when built against the latest target branch.
# https://docs.mergify.com/actions/queue/
ref: ${{ github.event.pull_request.head.sha }}
- uses: coursier/cache-action@v6
- uses: olafurpg/setup-scala@v14
with:
java-version: openjdk@1.17
# https://github.com/actions/cache/blob/master/examples.md#node---yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn
uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache Scalablytyped transpilations
uses: actions/cache@v4
with:
path: |
~/.ivy2/local/org.scalablytyped
~/.cache/scalablytyped
key: ${{ runner.os }}-scalablytyped-${{ hashfiles('build.sbt') }}-${{ hashFiles('*/yarn.lock') }}
restore-keys: |
${{ runner.os }}-scalablytyped-
- name: load envrc
uses: HatsuneMiku3939/direnv-action@v1
- name: Compile and Bundle
run: |
# Runner has 7G of RAM, so 4G for sbt is ok here:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
ENABLE_FATAL_WARNINGS=true sbt --mem 4096 \
compile Test/compile \
test \
scalafmtCheck scalafmtSbtCheck \
{webapp,lambda}/fastOptJS/webpack
- uses: hashicorp/setup-terraform@v3
- name: Validate Terraform
run: |
cd terraform
cat <<EOF > terraform.tf
provider "aws" {
region = "eu-central-1"
}
provider "aws" {
alias = "us-east-1"
region = "us-east-1"
}
EOF
terraform init
terraform validate
rm -r .terraform.lock.hcl terraform.tf
- name: Yarn install
run: yarn install --frozen-lockfile
- name: Prepare End-to-End Tests
run: |
# Start frontend dev-webserver
(
cd webapp/target/scala-2.13/scalajs-bundler/main
node node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.config.dev.js --port $FRONTEND_PORT || kill 0
) &
# Start the lambda backend
(npx fun-local-env \
--auth $AUTH_PORT \
--ws $WS_PORT \
--http $HTTP_PORT \
--http-api lambda/target/scala-2.13/scalajs-bundler/main/lambda-fastopt.js httpApi \
--http-rpc lambda/target/scala-2.13/scalajs-bundler/main/lambda-fastopt.js httpRpc \
--ws-rpc lambda/target/scala-2.13/scalajs-bundler/main/lambda-fastopt.js wsRpc \
--ws-event-authorizer lambda/target/scala-2.13/scalajs-bundler/main/lambda-fastopt.js wsEventAuth \
> /tmp/local-env-logs 2>&1 || kill 0) &
# Test http api
until nc -z 127.0.0.1 $HTTP_PORT &>/dev/null; do sleep 0.5; done
[ "$(curl -v localhost:$HTTP_PORT/books/drama/2011?limit=10)" == '[{"title":"Programming in Scala"}]' ]
# Wait until the dev server is running
npx wait-on http://localhost:$FRONTEND_PORT
- name: Cypress run (UI tests)
uses: cypress-io/github-action@v6.7.2
- name: On E2E test failure, print logs
if: failure()
run: if [[ -f /tmp/local-env-logs ]]; then cat /tmp/local-env-logs; fi
- name: Production build
run: |
# Runner has 7G of RAM, so 4G for sbt is ok here:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
ENABLE_FATAL_WARNINGS=true sbt --mem 4096 \
prod
- name: Check if working directory is clean
run: git diff --quiet --exit-code || (git status && false)
# - name: Debug over SSH (tmate)
# # if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true