Skip to content

Commit b078e19

Browse files
authored
Merge pull request #205 from joyofrails/chore/separate-wasm-build
Move wasm build to separate workflow on main
2 parents 0604509 + b1f155b commit b078e19

File tree

2 files changed

+79
-72
lines changed

2 files changed

+79
-72
lines changed

.github/workflows/verify.yml

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Put this in the file: .github/workflows/verify.yml
2-
31
name: Verify
42
on: [push]
53

@@ -212,73 +210,3 @@ jobs:
212210
name: assets
213211
path: public
214212
retention-days: 1
215-
216-
wasm:
217-
name: WebAssembly
218-
needs: [test, lint, assets]
219-
runs-on: ubuntu-latest
220-
strategy:
221-
matrix:
222-
target: [web, node]
223-
steps:
224-
- uses: actions/checkout@v4
225-
- name: Install build tools from apt
226-
run: sudo apt-get install ruby bison make autoconf git curl build-essential libyaml-dev zlib1g-dev -y
227-
- name: Install wasmtime
228-
uses: bytecodealliance/actions/wasmtime/setup@v1
229-
- name: Install brotli from apt
230-
run: sudo apt-get install brotli -y
231-
- name: Workaround for Debian ruby distribution
232-
run: |
233-
# avoid using system rubygems while installing docs
234-
# related issue: https://github.com/rubygems/rubygems/issues/3831
235-
sudo rm -rf /usr/lib/ruby/vendor_ruby/rubygems/defaults
236-
- uses: ruby/setup-ruby@v1
237-
with:
238-
bundler-cache: true
239-
- name: Cache wasm
240-
id: cache-wasm
241-
uses: actions/cache@v4
242-
env:
243-
cache-name: cache-wasm-${{ matrix.target }}
244-
with:
245-
path: |
246-
build
247-
rubies
248-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Gemfile.lock') }}
249-
restore-keys: |
250-
${{ runner.os }}-build-${{ env.cache-name }}-
251-
${{ runner.os }}-build-
252-
${{ runner.os }}-
253-
- uses: actions/download-artifact@v4
254-
with:
255-
name: assets
256-
path: public
257-
- run: ls -lahR public
258-
- run: echo ${{ secrets.RAILS_MASTER_WASM_KEY }} > config/credentials/wasm.key
259-
- run: mkdir -p .wasm
260-
- name: Build rails wasm for web
261-
run: TARGET=${{ matrix.target }} bin/wasm/build
262-
- name: Pack rails wasm for web
263-
run: TARGET=${{ matrix.target }} bin/wasm/pack
264-
- name: Test rails wasm for node successful with wasmtime
265-
run: |
266-
if [[ "${{ matrix.target }}" == "node" ]]; then
267-
bin/wasm/test-node
268-
else
269-
echo "Skipping test for wasm web"
270-
fi
271-
- name: Compress the wasm files
272-
run: bin/wasm/compress
273-
- run: ls -lahR public
274-
- name: Upload wasm to cloud storage
275-
run: |
276-
if [[ "${{github.ref}}" == "refs/heads/main" ]]; then
277-
RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_PRODUCTION_KEY }} \
278-
RAILS_ENV=production \
279-
bin/rails wasm:upload
280-
else
281-
RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_TEST_KEY }} \
282-
RAILS_ENV=test \
283-
bin/rails wasm:upload
284-
fi

.github/workflows/wasm.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Wasm
2+
on:
3+
workflow_run:
4+
workflows:
5+
- Deploy
6+
branches:
7+
- main
8+
types:
9+
- completed
10+
11+
jobs:
12+
wasm:
13+
name: WebAssembly
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
target: [web, node]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Install build tools from apt
21+
run: sudo apt-get install ruby bison make autoconf git curl build-essential libyaml-dev zlib1g-dev -y
22+
- name: Install wasmtime
23+
uses: bytecodealliance/actions/wasmtime/setup@v1
24+
- name: Install brotli from apt
25+
run: sudo apt-get install brotli -y
26+
- name: Workaround for Debian ruby distribution
27+
run: |
28+
# avoid using system rubygems while installing docs
29+
# related issue: https://github.com/rubygems/rubygems/issues/3831
30+
sudo rm -rf /usr/lib/ruby/vendor_ruby/rubygems/defaults
31+
- uses: ruby/setup-ruby@v1
32+
with:
33+
bundler-cache: true
34+
- name: Cache wasm
35+
id: cache-wasm
36+
uses: actions/cache@v4
37+
env:
38+
cache-name: cache-wasm-${{ matrix.target }}
39+
with:
40+
path: |
41+
build
42+
rubies
43+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Gemfile.lock') }}
44+
restore-keys: |
45+
${{ runner.os }}-build-${{ env.cache-name }}-
46+
${{ runner.os }}-build-
47+
${{ runner.os }}-
48+
- uses: actions/download-artifact@v4
49+
with:
50+
name: assets
51+
path: public
52+
- run: ls -lahR public
53+
- run: echo ${{ secrets.RAILS_MASTER_WASM_KEY }} > config/credentials/wasm.key
54+
- run: mkdir -p .wasm
55+
- name: Build rails wasm for web
56+
run: TARGET=${{ matrix.target }} bin/wasm/build
57+
- name: Pack rails wasm for web
58+
run: TARGET=${{ matrix.target }} bin/wasm/pack
59+
- name: Test rails wasm for node successful with wasmtime
60+
run: |
61+
if [[ "${{ matrix.target }}" == "node" ]]; then
62+
bin/wasm/test-node
63+
else
64+
echo "Skipping test for wasm web"
65+
fi
66+
- name: Compress the wasm files
67+
run: bin/wasm/compress
68+
- run: ls -lahR public
69+
- name: Upload wasm to cloud storage
70+
run: |
71+
if [[ "${{github.ref}}" == "refs/heads/main" ]]; then
72+
RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_PRODUCTION_KEY }} \
73+
RAILS_ENV=production \
74+
bin/rails wasm:upload
75+
else
76+
RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_TEST_KEY }} \
77+
RAILS_ENV=test \
78+
bin/rails wasm:upload
79+
fi

0 commit comments

Comments
 (0)