-
Notifications
You must be signed in to change notification settings - Fork 277
180 lines (178 loc) · 5.03 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
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
name: CI
on:
push:
branches:
- main
tags:
- '*'
pull_request:
release:
types: [published]
permissions:
contents: read
jobs:
test:
strategy:
fail-fast: false
matrix:
java: [ '11', '21' ]
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JVM
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'sbt'
- uses: sbt/setup-sbt@v1
- run:
# for GitOps tests
git config --global user.email "scalafmt@scalameta.org" && git config --global user.name "scalafmt"
- run: TEST="2.12" sbt ci-test-jvm
shell: bash
- run: TEST="2.13" sbt ci-test-jvm
shell: bash
test-scala-native:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JVM
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'sbt'
- uses: sbt/setup-sbt@v1
- run:
# for GitOps tests
git config --global user.email "scalafmt@scalameta.org" && git config --global user.name "scalafmt"
- run: TEST="2.12" sbt ci-test-native
shell: bash
- run: TEST="2.13" sbt ci-test-native
shell: bash
community-test:
strategy:
fail-fast: false
matrix:
java: [ '11' ]
os: [windows-latest, ubuntu-latest]
group: [Scala2, Scala3, Spark, Intellij, Other]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JVM
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'sbt'
- uses: sbt/setup-sbt@v1
- run: sbt communityTests${{ matrix.group }}/test
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: 'sbt'
- run: ./scalafmt --test
- run: yarn install
- run: yarn format-check
native-image:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest]
libc: [default, musl]
exclude:
- os: macOS-latest
libc: musl
include:
- os: macOS-latest
artifact: scalafmt-macos
env:
NATIVE_IMAGE_STATIC: none
- os: ubuntu-latest
libc: default
artifact: scalafmt-linux-glibc
env:
NATIVE_IMAGE_STATIC: nolibc
- os: ubuntu-latest
libc: musl
artifact: scalafmt-linux-musl
env:
NATIVE_IMAGE_STATIC: musl
env: ${{ matrix.env }}
steps:
- uses: actions/checkout@v4
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm-community'
native-image-musl: ${{ matrix.libc == 'musl' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: sbt/setup-sbt@v1
- run: bin/build-native-image.sh
env:
CI: true
- uses: actions/upload-artifact@master
with:
name: ${{ matrix.artifact }}
path: scalafmt
- name: Upload release
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: scalafmt
asset_name: ${{ matrix.artifact }}
asset_content_type: application/zip
dockerize:
needs: [native-image,test]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') && github.event_name != 'release'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: scalameta/scalafmt
tags: type=semver,pattern={{raw}}
- name: Downloading scalafmt-linux-musl for Docker Build
uses: actions/download-artifact@v4
with:
name: scalafmt-linux-musl
path: tmp/scalafmt-linux-musl
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}