-
Notifications
You must be signed in to change notification settings - Fork 2
256 lines (224 loc) · 7.41 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
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
name: CI
on:
push:
branches: ["main"]
tags: ["v*"]
pull_request:
branches: ["*"]
env:
JAVA_OPTS: "-Xmx4G"
JVM_OPTS: "-Xmx4G"
SBT_OPTS: "-Xmx4G"
REGISTRY_IMAGE: keynmol/sn-vcpkg
jobs:
build:
name: Unix CI ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: sbt
- name: Tests
run: sbt test pluginTests checkDocs publishLocal versionDump
- name: Cold start tests (docker)
run: docker build . -t sbt-vcpkg-tests
if: startsWith(matrix.os, 'ubuntu-')
- name: Cache vcpkg
uses: actions/cache@v3
with:
path: |
~/Library/Caches/sbt-vcpkg/vcpkg-install
~/.cache/sbt-vcpkg/vcpkg-install
~/.cache/sbt-vcpkg/vcpkg
key: ${{ runner.os }}-sbt-vcpkg
- name: Run example
env:
LLVM_BIN: /usr/local/opt/llvm@14/bin
if: startsWith(matrix.os, 'macos-')
run: |
set -e
brew install llvm@14
cd example
SBT_VCPKG_VERSION=$(cat ../version) sbt example/run
- uses: coursier/cache-action@v6
- uses: VirtusLab/scala-cli-setup@main
- name: CLI tests
shell: bash
run: |
set -xe
curl -fLo cs https://github.com/coursier/launchers/raw/master/coursier && chmod +x cs
./cs bootstrap com.indoorvivants.vcpkg:sn-vcpkg_3:$(cat version) -f -o local_cli
./local_cli bootstrap
./local_cli install -v -c -l libpq s2n
echo '{"name": "my-application","version": "0.15.2","dependencies": ["sqlite3"]}' > test-vcpkg.json
./local_cli install -v -c -l --manifest test-vcpkg.json
./local_cli clang -v sqlite3 -- .github/workflows/fixtures/test-sqlite.c
./local_cli clang -v --manifest test-vcpkg.json -- .github/workflows/fixtures/test-sqlite.c
./local_cli clang++ -v sqlite3 -- .github/workflows/fixtures/test-sqlite.c
./local_cli clang++ -v --manifest test-vcpkg.json -- .github/workflows/fixtures/test-sqlite.c
./local_cli clang -v curl --rename curl=libcurl -- .github/workflows/fixtures/test-curl.c && ./a.out
./local_cli scala-cli -v sqlite3 -- run .github/workflows/fixtures/test-scala-cli.scala
windows_build:
name: Windows CI
strategy:
fail-fast: false
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- name: Setup git config
run: git config --global core.autocrlf false
- name: Install pkg-config on Windows
run: choco install pkgconfiglite
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
cache: sbt
- name: Test
run: sbt test
mergify-build-checkpoint:
runs-on: ubuntu-latest
needs: [build, windows_build]
steps:
- name: I only exist to please Mergify :(
run: echo "It's a sad existence but necessary"
release:
name: Release
needs: [build, windows_build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: sbt
- name: Publish ${{ github.ref }}
run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build
id: build
uses: docker/build-push-action@v4
with:
push: false
file: ./modules/sn-vcpkg-docker/Dockerfile
context: .
outputs: type=image,name=${{ env.REGISTRY_IMAGE }}
docker_release_build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_IMAGE }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build and push by digest
id: build
uses: docker/build-push-action@v4
with:
context: .
file: ./modules/sn-vcpkg-docker/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE}}:main
cache-to: type=inline
-
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
-
name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
docker_release_merge:
runs-on: ubuntu-latest
needs: [docker_release_build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
steps:
-
name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_IMAGE }}
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}