-
-
Notifications
You must be signed in to change notification settings - Fork 6
241 lines (232 loc) · 8.99 KB
/
test-crystal-shards.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
name: Test Crystal & Shards
on:
workflow_dispatch:
inputs:
crystal_repo:
default: 'crystal-lang/crystal'
required: true
crystal_branch:
default: 'master'
required: true
shards_repo:
default: 'crystal-lang/shards'
required: true
shards_branch:
default: 'master'
required: true
crystal_opts:
default: '--exclude-warnings none --error-on-warnings --error-trace'
required: false
shards_opts:
default: '--ignore-crystal-version'
required: false
crystal_build_opts:
default: 'release=1'
required: false
previous_crystal_release:
default: 'https://github.com/crystal-lang/crystal/releases/download/1.14.0/crystal-1.14.0-1-linux-x86_64.tar.gz'
required: true
jobs:
build:
runs-on: ubuntu-latest
container: ubuntu:latest
steps:
- name: Workflow Arguments
run: |
echo "crystal_repo: ${{ github.event.inputs.crystal_repo }}"
echo "crystal_branch: ${{ github.event.inputs.crystal_branch }}"
echo "shards_repo: ${{ github.event.inputs.shards_repo }}"
echo "shards_branch: ${{ github.event.inputs.shards_branch }}"
echo "crystal_opts: ${{ github.event.inputs.crystal_opts }}"
echo "shards_opts: ${{ github.event.inputs.shards_opts }}"
echo "crystal_build_opts: ${{ github.event.inputs.crystal_build_opts }}"
echo "previous_crystal_release: ${{ github.event.inputs.previous_crystal_release }}"
- name: Checkout test-ecosystem
uses: actions/checkout@v4
with:
path: test-ecosystem
- name: Install Libraries
run: |
apt-get update
./test-ecosystem/scripts/apt-install-tools.sh
./test-ecosystem/scripts/apt-install-llvm-libclang.sh
echo "LLVM_CONFIG=$LLVM_CONFIG" >> $GITHUB_ENV
./test-ecosystem/scripts/apt-install-crystal-deps.sh
# for https://github.com/actions/checkout/issues/209
apt-get install -y jq
- name: Install Previous Crystal
run: |
curl -fsSL ${{ github.event.inputs.previous_crystal_release }} -o /tmp/crystal.tar.gz
mkdir /tmp/crystal
tar -xz -C /tmp/crystal --strip-component=1 -f /tmp/crystal.tar.gz
echo "/tmp/crystal/bin/" >> $GITHUB_PATH
- name: Checkout Crystal
uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.crystal_repo }}
ref: ${{ github.event.inputs.crystal_branch }}
# https://github.com/actions/checkout#checkout-multiple-repos-private
token: ${{ secrets.MY_GITHUB_PAT }}
path: crystal
# https://github.com/actions/checkout/issues/209
- id: get-crystal-sha
run: |
echo ::set-output name=sha::$( curl -u "u:${{ secrets.MY_GITHUB_PAT }}" https://api.github.com/repos/${{ github.event.inputs.crystal_repo }}/git/ref/heads/${{ github.event.inputs.crystal_branch }} | jq .object.sha | tr -d '"' )
- name: Checkout Shards
uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.shards_repo }}
ref: ${{ github.event.inputs.shards_branch }}
# https://github.com/actions/checkout#checkout-multiple-repos-private
token: ${{ secrets.MY_GITHUB_PAT }}
path: shards
- id: get-shards-sha
run: |
echo ::set-output name=sha::$( curl -u "u:${{ secrets.MY_GITHUB_PAT }}" https://api.github.com/repos/${{ github.event.inputs.shards_repo }}/git/ref/heads/${{ github.event.inputs.shards_branch }} | jq .object.sha | tr -d '"' )
- name: Compute build cache keys
run: |
crystal env CRYSTAL_VERSION > ./build-cache-key
echo "LLVM_VERSION=$($LLVM_CONFIG --version)" >> ./build-cache-key
echo "crystal_build_opts=${{ github.event.inputs.crystal_build_opts }}" >> ./build-cache-key
cd crystal
echo "CRYSTAL_SHA1=${{ steps.get-crystal-sha.outputs.sha }}" >> ../build-cache-key
cd ../shards
echo "SHARDS_SHA1=${{ steps.get-shards-sha.outputs.sha }}" >> ../build-cache-key
cat ../build-cache-key
- name: Build cache
id: build-cache
uses: actions/cache@v4
with:
path: |
./crystal/.build/crystal
./shards/bin/shards
./crystal-lib
key: ${{ runner.os }}-build-${{ hashFiles('./build-cache-key') }}
- name: Build Crystal Deps
run: |
cd crystal
make deps
- name: Build Crystal
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
mkdir crystal-lib
cp -r $(/tmp/crystal/bin/crystal env CRYSTAL_LIBRARY_PATH)/* ./crystal-lib/
cd crystal
make crystal CRYSTAL_CONFIG_LIBRARY_PATH=$(readlink -f ../crystal-lib) ${{ github.event.inputs.crystal_build_opts }}
bin/crystal --version
- name: Build Shards
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
cd shards
make bin/shards CRYSTAL=../crystal/bin/crystal
bin/shards --version
- name: Artifact (with permissions)
uses: actions/cache@v4
with:
path: |
./test-ecosystem
./crystal
./shards
./crystal-lib
key: artifacts-${{ github.run_id }}-${{ github.run_number }}
# Workaround https://github.com/actions/download-artifact/issues/14
# - name: Upload artifacts
# uses: actions/upload-artifact@v2
# with:
# name: files
# path: |
# ./test-ecosystem
# ./crystal
# ./shards
# ./crystal-lib
test:
strategy:
matrix:
script:
- 00-crystal-init-spec.bats
- 01-shards.bats
- 10-crystal-db.bats
- 20-crystal-ext.bats
- 30-tools.bats
# - 40-web-frameworks-amber.bats
- 40-web-frameworks-kemal.bats
- 40-web-frameworks-lucky.bats
- 50-crystal.bats
- 60-crystal-progress.bats
- 70-implementations.bats
- 80-tutorials.bats
fail-fast: false
name: test ${{ matrix.script }}
runs-on: ubuntu-latest
container: ubuntu:latest
services:
postgres:
image: postgres:17.0-alpine
env:
POSTGRES_HOST_AUTH_METHOD: trust
mysql:
image: mysql:9.1
env:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
redis:
image: redis:alpine
needs: build
steps:
- name: Artifact (with permissions)
uses: actions/cache@v4
with:
path: |
./test-ecosystem
./crystal
./shards
./crystal-lib
key: artifacts-${{ github.run_id }}-${{ github.run_number }}
# Workaround https://github.com/actions/download-artifact/issues/14
# - name: Download artifacts
# uses: actions/download-artifact@v2
# with:
# name: files
- name: Install Libraries
run: |
apt-get update
./test-ecosystem/scripts/apt-install-tools.sh
./test-ecosystem/scripts/apt-install-llvm-libclang.sh
echo "LLVM_CONFIG=$LLVM_CONFIG" >> $GITHUB_ENV
./test-ecosystem/scripts/apt-install-crystal-deps.sh
./test-ecosystem/scripts/00-install-bats.sh
- name: Initialize postgres
uses: docker://postgres:17.0-alpine
with:
args: /bin/sh -c "psql -U postgres -h postgres -f ./test-ecosystem/scripts/pg-init.sql"
- name: Initialize mysql
uses: docker://mysql:9.1
with:
args: /bin/sh -c "mysql -uroot -h mysql < ./test-ecosystem/scripts/mysql-init.sql"
- name: Configure git
run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
- name: Setup env vars
run: |
echo "SHARDS_OPTS=${{ github.event.inputs.shards_opts }}" >> $GITHUB_ENV
echo "CRYSTAL_OPTS=${{ github.event.inputs.crystal_opts }}" >> $GITHUB_ENV
echo "CRYSTAL_LIBRARY_PATH=$(readlink -f ./crystal-lib)" >> $GITHUB_ENV
echo "REPOS_DIR=$(readlink -f ./repos)" >> $GITHUB_ENV
echo "SHARDS_OVERRIDE=$(readlink -f ./repos)/shard.override.yml" >> $GITHUB_ENV
echo "SHARDS_CACHE_PATH=$(readlink -f ./shards_cache)" >> $GITHUB_ENV
echo "$(readlink -f ./shards/bin)" >> $GITHUB_PATH
echo "$(readlink -f ./crystal/bin)" >> $GITHUB_PATH
echo "POSTGRES_HOST=postgres" >> $GITHUB_ENV
echo "MYSQL_HOST=mysql" >> $GITHUB_ENV
echo "REDIS_HOST=redis" >> $GITHUB_ENV
- name: Crystal & Shards information
run: |
which crystal
crystal --version
crystal env
which shards
shards --version
env | grep CRYSTAL
env | grep SHARDS
- run: ./test-ecosystem/scripts/10-clone-repos.sh
- run: bats ./test-ecosystem/bats/${{ matrix.script }}