-
Notifications
You must be signed in to change notification settings - Fork 1
218 lines (188 loc) · 7.19 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
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
name: Build and Upload JARs
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
release_name: snapshot-linux
- os: windows-2019
release_name: snapshot-windows
- os: macos-14
release_name: snapshot-macos
- os: macos-12
release_name: snapshot-macos-intel
env:
SCALA_VERSION: '3.5.0'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
defaults:
run:
shell: bash
working-directory: ./
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Pick and display a JDK version and distribution
id: pick-jdk
run: |
JDK_VERSION=8
if [[ "$RUNNER_OS" == "macOS" && "$RUNNER_ARCH" == "ARM64" ]]; then
JDK_VERSION=11
fi
JDK_DISTRIBUTION=temurin
echo "JDK_VERSION=$JDK_VERSION" >> $GITHUB_ENV
echo "JDK_DISTRIBUTION=$JDK_DISTRIBUTION" >> $GITHUB_ENV
shell: bash
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: ${{ env.JDK_DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}
cache: sbt
- uses: sbt/setup-sbt@v1
- name: Cache SBT (Unix)
if: runner.os != 'Windows'
uses: actions/cache@v4
with:
path: |
~/.ivy2/cache
~/.sbt
~/.coursier
~/.cache/coursier
key: ${{ matrix.os }}-sbt-${{ hashFiles('**/*.sbt') }}
restore-keys: |
${{ matrix.os }}-sbt-
- name: Cache SBT for Windows
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: |
C:\Users\runneradmin\.ivy2\cache
C:\Users\runneradmin\.sbt
C:\Users\runneradmin\.coursier
C:\Users\runneradmin\AppData\Local\Coursier\cache
key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }}
restore-keys: |
${{ runner.os }}-sbt-
- name: Clone scala-graph and publishM2 (for Java8 and Scala Native)
run: |
git clone https://github.com/mio-19/scala-graph
cd scala-graph
git checkout 6381eb20c8595f5507410f4e2bfa9e27b8d88a30
sbt publishM2
shell: bash
- name: SBT Clean
run: sbt clean
# for some reason clean calls stImport and stImport usually fails at first run
continue-on-error: true
# maybe test will fail on the first try because of stImport, the typescript to scala thing.
- name: Run Tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 25
max_attempts: 3
shell: bash
command: sbt test
- name: Build Common JAR with SBT
run: sbt common/assembly
- name: Build CLI JAR with SBT
run: sbt cli/assembly
- name: Build LSP JAR with SBT
run: sbt lsp/assembly
- name: Build CLI Native Executable
run: sbt cliNative/nativeLink
- name: Rename CLI Native Executable
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
mv cli/native/target/scala-${{ env.SCALA_VERSION }}/cli-out.exe cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out.exe || mv cli/native/target/scala-${{ env.SCALA_VERSION }}/native/chester.cli.Main.exe cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out.exe
else
mv cli/native/target/scala-${{ env.SCALA_VERSION }}/cli-out cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out || mv cli/native/target/scala-${{ env.SCALA_VERSION }}/native/chester.cli.Main cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out
fi
- name: Generate JS Artifacts for CLI
run: |
sbt cliJS/fullLinkJS
mv cli/js/target/scala-${{ env.SCALA_VERSION }}/cli-opt/main.js cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js
- uses: graalvm/setup-graalvm@v1
with:
java-version: '22'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: GraalVM Env
run: |
echo "NATIVE_IMAGE_INSTALLED=true" >> $GITHUB_ENV
echo "GRAALVM_INSTALLED=true" >> $GITHUB_ENV
- name: Build Native Image for LSP
run: sbt lsp/nativeImage
- name: Build Native Image for CLI
run: sbt cli/nativeImage
- name: Test Native Image for CLI integrity
run: ./target/chester integrity
- name: List files for debugging
run: find . -type f -name "*.jar" -or -name "chester" -or -name "chester-lsp" -or -name "chester-out" -or -name "*.exe"
continue-on-error: true
- name: Upload Unix Artifacts
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.release_name }}
path: |
./common/jvm/target/scala-${{ env.SCALA_VERSION }}/common.jar
./cli/jvm/target/scala-${{ env.SCALA_VERSION }}/chester.jar
./lsp/.jvm/target/scala-${{ env.SCALA_VERSION }}/chester-lsp.jar
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js
./target/chester
./target/chester-lsp
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out
- name: Upload Windows Artifacts
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.release_name }}
path: |
./common/jvm/target/scala-${{ env.SCALA_VERSION }}/common.jar
./cli/jvm/target/scala-${{ env.SCALA_VERSION }}/chester.jar
./lsp/.jvm/target/scala-${{ env.SCALA_VERSION }}/chester-lsp.jar
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js
./target/chester.exe
./target/chester-lsp.exe
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out.exe
- name: Create or Update GitHub Release for Unix
if: runner.os != 'Windows'
uses: ncipollo/release-action@v1
with:
tag: ${{ matrix.release_name }}
name: ${{ matrix.release_name }}
allowUpdates: true
prerelease: true
artifacts: |
./common/jvm/target/scala-${{ env.SCALA_VERSION }}/common.jar,
./cli/jvm/target/scala-${{ env.SCALA_VERSION }}/chester.jar,
./lsp/.jvm/target/scala-${{ env.SCALA_VERSION }}/chester-lsp.jar,
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js,
./target/chester,
./target/chester-lsp,
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out
- name: Create or Update GitHub Release for Windows
if: runner.os == 'Windows'
uses: ncipollo/release-action@v1
with:
tag: ${{ matrix.release_name }}
name: ${{ matrix.release_name }}
allowUpdates: true
prerelease: true
artifacts: |
./common/jvm/target/scala-${{ env.SCALA_VERSION }}/common.jar,
./cli/jvm/target/scala-${{ env.SCALA_VERSION }}/chester.jar,
./lsp/.jvm/target/scala-${{ env.SCALA_VERSION }}/chester-lsp.jar,
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js,
./target/chester.exe,
./target/chester-lsp.exe,
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out.exe