-
Notifications
You must be signed in to change notification settings - Fork 1.2k
280 lines (247 loc) · 11.4 KB
/
ci.yaml
File metadata and controls
280 lines (247 loc) · 11.4 KB
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
name: Scala 3
on:
push:
## Be careful if you add or remove something here! Quoting from
## <https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore>:
##
## > If you define only tags/tags-ignore or only branches/branches-ignore, the
## > workflow won't run for events affecting the undefined Git ref. If you
## > define neither tags/tags-ignore or branches/branches-ignore, the workflow
## > will run for events affecting either branches or tags.
##
## We want the CI to run on both branches and tags, so we should either have:
## - both (tags or tags-ignore) and (branches or branches-ignore),
## - or neither of them.
## But it's important to not have only one or the other.
tags:
- '*'
branches-ignore:
- 'gh-readonly-queue/**'
- 'release-**'
- 'lts-**'
pull_request:
merge_group:
workflow_dispatch:
# Cancels any in-progress runs within the same group identified by workflow name and GH reference (branch or tag)
# For example it would:
# - terminate previous PR CI execution after pushing more changes to the same PR branch
# - terminate previous on-push CI run after merging new PR to main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
DOTTY_CI_RUN: true
# In this file, we set `--cpu-shares 4096` on every job. This might seem useless
# since it means that every container has the same weight which should be
# equivalent to doing nothing, but it turns out that OpenJDK computes
# `Runtime.getRuntime.availableProcessors` by dividing the cpu-shares value if
# it exists by 1024 (cf
# http://mail.openjdk.java.net/pipermail/hotspot-dev/2019-January/036087.html),
# so this means that we effectively run every job with 4 cores. This is much
# nicer than setting `--cpus 4` because the latter enforces CPU quotas and ends
# up slowing our jobs more than needed. It's equivalent to running the JVM with
# `-XX:ActiveProcessorCount=4`, but since our tests can spawn new JVM in many
# places, it would be very hard to ensure that this option is always passed to
# `java` (we could use the `_JAVA_OPTIONS` environment variable, but this prints
# text on stderr and so can break tests which check the output of a program).
jobs:
# Run stdlib tests before publishing a release
stdlib-tests:
uses: ./.github/workflows/stdlib.yaml
if: "github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')"
secrets: inherit
test_windows_full:
runs-on: [self-hosted, Windows]
if: "github.event_name == 'schedule' && github.repository == 'scala/scala3'
|| github.event_name == 'push'
|| (
github.event_name == 'pull_request'
&& !contains(github.event.pull_request.body, '[skip ci]')
&& contains(github.event.pull_request.body, '[test_windows_full]')
)"
steps:
- name: Reset existing repo
shell: cmd
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Git Checkout
uses: actions/checkout@v6
- name: Test
run: sbt ";scala3-bootstrapped/compile ;scala3-compiler-bootstrapped/test"
shell: cmd
publish_release:
permissions:
contents: write # for GH CLI to create a release
runs-on: [self-hosted, Linux]
needs: [stdlib-tests]
container:
image: lampepfl/dotty:2024-10-18
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
- ${{ github.workspace }}/../../cache/general:/root/.cache
if: "github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')"
env:
RELEASEBUILD: yes
PGP_PW: ${{ secrets.PGP_PW }} # PGP passphrase
PGP_SECRET: ${{ secrets.PGP_SECRET }} # Export your private and public PGP key to an *.asc file, take the file's contents as a string
SONATYPE_PW: ${{ secrets.SONATYPE_PW_ORGSCALALANG }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER_ORGSCALALANG }}
steps:
##############################################################################################
## WARNING: DO NOT CHANGE THE JAVA VERSION HERE. SCALA 3.8.0+ IS DISTRIBUTED USING JAVA 17. ##
##############################################################################################
- name: Set JDK 17 as default
run: echo "/usr/lib/jvm/java-17-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
- name: Checkout cleanup script
uses: actions/checkout@v6
- name: Cleanup
run: .github/workflows/cleanup.sh
- name: Git Checkout
uses: actions/checkout@v6
- name: Add SBT proxy repositories
run: cp -vf .github/workflows/repositories /root/.sbt/ ; true
# Extract the release tag
- name: Extract the release tag
run : echo "RELEASE_TAG='${GITHUB_REF#*refs/tags/}'" >> $GITHUB_ENV
- name: Check compiler version
shell: bash
run : |
version=$(./project/scripts/sbt "print scala3-compiler-bootstrapped/version" | tail -n1)
echo "This build version: ${version}"
if [ "${version}" != "${{ env.RELEASE_TAG }}" ]; then
echo "Compiler version for this build '${version}', does not match tag: ${{ env.RELEASE_TAG }}"
exit 1
fi
- name: Prepare the SDKs
shell: bash
run : |
prepareSDK() {
distroSuffix="$1"
sbtProject="$2"
distDir="$3"
# Build binaries
./project/scripts/sbt "all ${sbtProject}/Universal/packageBin ${sbtProject}/Universal/packageZipTarball"
artifactName="scala3-${{ env.RELEASE_TAG }}${distroSuffix}"
# Caluclate SHA for each of archive files
for file in "${artifactName}.zip" "${artifactName}.tar.gz"; do
mv ${distDir}/target/universal/$file $file
sha256sum "${file}" > "${file}.sha256"
done
}
prepareSDK "" "dist" "./dist/"
prepareSDK "-aarch64-pc-linux" "dist-linux-aarch64" "./dist/linux-aarch64/"
prepareSDK "-x86_64-pc-linux" "dist-linux-x86_64" "./dist/linux-x86_64/"
prepareSDK "-aarch64-apple-darwin" "dist-mac-aarch64" "./dist/mac-aarch64/"
prepareSDK "-x86_64-apple-darwin" "dist-mac-x86_64" "./dist/mac-x86_64/"
prepareSDK "-x86_64-pc-win32" "dist-win-x86_64" "./dist/win-x86_64/"
- name: Download MSI package
uses: actions/download-artifact@v8
with:
name: scala.msi
path: .
- name: Prepare MSI package
shell: bash
run: |
msiInstaller="scala3-${{ env.RELEASE_TAG }}.msi"
mv scala.msi "${msiInstaller}"
sha256sum "${msiInstaller}" > "${msiInstaller}.sha256"
- name: Install GH CLI
uses: dev-hanz-ops/install-gh-cli-action@v0.2.1
with:
gh-cli-version: 2.59.0
# Create the GitHub release
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
shell: bash
run: |
# We need to config safe.directory in every step that might reference git
# It is not persisted between steps
git config --global --add safe.directory $GITHUB_WORKSPACE
gh release create \
--draft \
--title "${{ env.RELEASE_TAG }}" \
--notes-file ./changelogs/${{ env.RELEASE_TAG }}.md \
--latest=${{ !contains(env.RELEASE_TAG, '-RC') }} \
--prerelease=${{ contains(env.RELEASE_TAG, '-RC') }} \
--verify-tag ${{ env.RELEASE_TAG }} \
scala3-${{ env.RELEASE_TAG }}*.zip \
scala3-${{ env.RELEASE_TAG }}*.tar.gz \
scala3-${{ env.RELEASE_TAG }}*.sha256 \
scala3-${{ env.RELEASE_TAG }}.msi
# Each namespace needs to be published separately
- name: Publish Release (org.scala-lang)
run: |
rm -rf ./target/sona-staging/
./project/scripts/sbtPublish " \
all \
scala-library-bootstrapped/publishSigned \
scala3-compiler-bootstrapped/publishSigned \
scala3-interfaces/publishSigned \
scala3-language-server/publishSigned \
scala3-library-bootstrapped/publishSigned \
scala3-library-sjs/publishSigned \
scala3-presentation-compiler/publishSigned \
scala3-repl/publishSigned \
scala3-sbt-bridge-bootstrapped/publishSigned \
scala3-staging/publishSigned \
scala3-tasty-inspector/publishSigned \
scaladoc/publishSigned \
tasty-core-bootstrapped/publishSigned \
;sonaUpload"
- name: Publish Release (org.scala-js)
run: |
# Ensure the staging does not contain any stale artifacts
rm -rf ./target/sona-staging/
./project/scripts/sbtPublish "scala-library-sjs/publishSigned ;sonaUpload"
build-msi-package:
uses: ./.github/workflows/build-msi.yml
if :
(github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_msi]')) ||
(github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/'))
test-msi-package:
uses: ./.github/workflows/test-msi.yml
needs: [build-msi-package]
with:
version: ${{ needs.build-msi-package.outputs.version }}
java-version: 17
build-sdk-package:
uses: ./.github/workflows/build-sdk.yml
if:
(github.event_name == 'pull_request' && !contains(github.event.pull_request.body, '[skip ci]')) ||
(github.event_name == 'workflow_dispatch' && github.repository == 'scala/scala3') ||
(github.event_name == 'schedule' && github.repository == 'scala/scala3') ||
github.event_name == 'push' ||
github.event_name == 'merge_group'
with:
java-version: 17
build-chocolatey-package:
uses: ./.github/workflows/build-chocolatey.yml
needs: [ build-sdk-package ]
with:
version: 3.6.0-SNAPSHOT # Fake version, used only for choco tests
url : https://api.github.com/repos/scala/scala3/actions/artifacts/${{ needs.build-sdk-package.outputs.win-x86_64-id }}/zip
digest : ${{ needs.build-sdk-package.outputs.win-x86_64-digest }}
test-chocolatey-package:
uses: ./.github/workflows/test-chocolatey.yml
with:
version : 3.6.0-SNAPSHOT # Fake version, used only for choco tests
java-version: 17
if: github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_chocolatey]')
needs: [ build-chocolatey-package ]
scalafmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: coursier/cache-action@v8
- uses: VirtusLab/scala-cli-setup@v1.14
- run: scala-cli format --check