-
Notifications
You must be signed in to change notification settings - Fork 55
185 lines (180 loc) · 5.92 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
name: Build ruby.wasm
on:
push:
branches: [main]
tags: ["*"]
paths-ignore:
- "*.md"
- "docs/**"
pull_request:
workflow_call:
inputs:
publish:
type: boolean
description: "Whether to publish or not"
default: true
prerel_name:
type: string
description: "Pre-release name to be released"
required: true
secrets:
NODE_AUTH_TOKEN:
required: true
jobs:
lint:
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
with:
ruby-version: "head"
bundler-cache: true
- run: ./bin/setup
- run: bundle exec rake check:type
- run: sudo apt-get install clang-format
- run: ./bin/clang-format-diff.sh
- run: bundle exec rake check:bindgen
- run: git diff --exit-code
build-builder-image:
strategy:
fail-fast: false
matrix:
entry:
- { target: wasm32-unknown-wasip1 }
- { target: wasm32-unknown-emscripten }
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository_owner }}/ruby.wasm/builder/${{ matrix.entry.target }}
- uses: docker/build-push-action@v5
with:
context: builders/${{ matrix.entry.target }}
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-rake-task-matrix:
runs-on: ubuntu-20.04
outputs:
entries: ${{ steps.set-matrix.outputs.entries }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "head"
bundler-cache: true
- run: ./bin/setup
- run: rake ci:pin_build_manifest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
with:
name: build-manifest
path: build_manifest.json
- name: Set matrix
id: set-matrix
run: |
rake ci:rake_task_matrix
echo "entries=$(cat ci_matrix.json)" >> $GITHUB_OUTPUT
rake-tasks:
strategy:
fail-fast: false
matrix:
entry: ${{ fromJson(needs.build-rake-task-matrix.outputs.entries) }}
needs: [build-rake-task-matrix]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: build-manifest
- uses: actions/[email protected]
if: ${{ matrix.entry.rubies_cache_key != null }}
with:
path: ./rubies
key: ${{ matrix.entry.rubies_cache_key }}
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
id: builder-image
env:
DOCKER_BUILD_NO_SUMMARY: true
with:
context: builders/${{ matrix.entry.builder }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Setup builder container
run: |
docker run -dit -v "$GITHUB_WORKSPACE:/home/me/build" -w /home/me/build \
-e "ENABLE_GITHUB_ACTIONS_MARKUP=true" \
-e "RUBYWASM_UID=$(id -u)" -e "RUBYWASM_GID=$(id -g)" \
-e "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" \
--name builder \
${{ steps.builder-image.outputs.imageid }} /bin/sh
echo 'docker exec -u me builder "$@"' > ./build-exec
chmod +x ./build-exec
# wait for docker exec to be ready
timeout 10 bash -c 'until ./build-exec bundle config set --local without check; do sleep 1; done'
- run: ./build-exec ./bin/setup
- run: ./build-exec bundle exec rake compile
- name: Pre-release configuration
run: ./build-exec bundle exec rake ${{ matrix.entry.prerelease }}[${{ inputs.prerel_name }}]
if: ${{ inputs.prerel_name != '' && matrix.entry.prerelease != '' }}
- name: rake ${{ matrix.entry.task }}
run: ./build-exec rake --verbose ${{ matrix.entry.task }}
- uses: actions/upload-artifact@v4
if: ${{ matrix.entry.artifact }}
with:
name: ${{ matrix.entry.artifact_name }}
path: ${{ matrix.entry.artifact }}
- uses: ruby/setup-ruby@v1
if: ${{ matrix.entry.test != '' }}
with:
ruby-version: "head"
bundler-cache: false
- name: rake ${{ matrix.entry.test }}
run: |
bundle install --with=check --without=development
rake ${{ matrix.entry.test }}
if: ${{ matrix.entry.test != '' }}
release-artifacts:
needs: [rake-tasks]
runs-on: ubuntu-20.04
if: ${{ startsWith(github.ref, 'refs/tags/') || inputs.publish }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: build-manifest
- uses: actions/download-artifact@v4
with:
path: release
- uses: actions/setup-node@v4
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- uses: ruby/setup-ruby@v1
with:
ruby-version: "head"
bundler-cache: true
- run: ./bin/setup
- run: echo "PREREL_NAME=${{ inputs.prerel_name }}" >> $GITHUB_ENV
- run: bundle exec rake "ci:publish[${PREREL_NAME:-$GITHUB_REF_NAME}]"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}