Skip to content

Commit 820d0c1

Browse files
committed
Refactor CI with matrix build
1 parent 2919348 commit 820d0c1

File tree

1 file changed

+67
-119
lines changed

1 file changed

+67
-119
lines changed

.github/workflows/build.yml

Lines changed: 67 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ jobs:
3131

3232
runs-on: ${{ matrix.os }}
3333

34+
container: ${{ matrix.container.image != 'docker.io/nixos/nix:latest' && matrix.container || null }}
35+
3436
strategy:
3537
fail-fast: false
3638
matrix:
3739
os:
3840
- macos-latest
3941
- ubuntu-latest
4042
- windows-latest
43+
container:
44+
-
45+
vm:
46+
-
4147
ruby-version:
4248
- '3.1'
4349
- '3.2'
@@ -50,157 +56,99 @@ jobs:
5056
ruby-version: truffleruby
5157
- os: windows-latest
5258
ruby-version: truffleruby+graalvm
53-
54-
steps:
55-
- name: Checkout
56-
uses: actions/checkout@v4
57-
58-
- name: Setup ruby
59-
uses: ruby/setup-ruby@v1
60-
with:
61-
ruby-version: ${{ matrix.ruby-version }}
62-
bundler-cache: true
63-
64-
- name: Compile
65-
run: bundle exec rake compile
66-
67-
- name: Spec
68-
run: bundle exec rake spec
69-
70-
- name: Install
71-
run: rake -f -r bundler/gem_tasks install
72-
73-
spec-musl:
74-
75-
name: spec (alpine-latest, ${{ matrix.ruby-version }})
76-
77-
runs-on: ubuntu-latest
78-
79-
container:
80-
image: docker.io/library/ruby:${{ matrix.ruby-version }}-alpine
81-
82-
strategy:
83-
fail-fast: false
84-
matrix:
85-
ruby-version:
86-
- '3.1'
87-
- '3.2'
88-
- '3.3'
89-
90-
steps:
91-
- name: Checkout
92-
uses: actions/checkout@v4
93-
94-
- name: Install dependencies
95-
run: apk add build-base
96-
97-
- name: Bundle
98-
run: bundle install
99-
100-
- name: Compile
101-
run: bundle exec rake compile
102-
103-
- name: Install
104-
run: rake -f -r bundler/gem_tasks install
105-
106-
- name: Spec
107-
run: bundle exec rake spec
108-
109-
spec-nix:
110-
111-
name: spec (nix-latest)
112-
113-
runs-on: ubuntu-latest
114-
115-
services:
116-
nix:
117-
image: docker.io/nixos/nix:latest
118-
options: --tty
119-
volumes:
120-
- ${{ github.workspace }}:${{ github.workspace }}
121-
122-
steps:
123-
- name: Checkout
124-
uses: actions/checkout@v4
125-
126-
- name: Setup shell
127-
run: |
128-
mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash"
129-
#!/bin/bash --
130-
exec docker exec -i -w "$PWD" ${{ job.services.nix.id }} nix-shell --packages ruby --run "exec \"\$SHELL\"$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}"
131-
EOF
132-
133-
- name: Bundle
134-
run: bundle install
135-
136-
- name: Compile
137-
run: bundle exec rake compile
138-
139-
- name: Install
140-
run: rake -f -r bundler/gem_tasks install
141-
142-
- name: Spec
143-
run: bundle exec rake spec
144-
145-
spec-bsd:
146-
147-
name: spec (${{ matrix.vm }}-latest)
148-
149-
runs-on: ubuntu-latest
150-
151-
strategy:
152-
fail-fast: false
153-
matrix:
15459
include:
155-
- vm: freebsd
156-
install-dependencies: |
157-
pkg install -y node npm protobuf ruby rubygem-bundler rubygem-rake
158-
- vm: openbsd
159-
install-dependencies: |
160-
ruby=$(pkg_info -Q ruby | grep '^ruby-[0-9]' | sort -rV | head -n 1)
161-
pkg_add node protobuf $ruby
162-
pkg_info $ruby | grep 'ln -sf' | $SHELL
60+
- os: ubuntu-latest
61+
container:
62+
image: docker.io/library/ruby:3.1-alpine
63+
- os: ubuntu-latest
64+
container:
65+
image: docker.io/library/ruby:3.2-alpine
66+
- os: ubuntu-latest
67+
container:
68+
image: docker.io/library/ruby:3.3-alpine
69+
- os: ubuntu-latest
70+
container:
71+
image: docker.io/nixos/nix:latest
72+
- os: ubuntu-latest
73+
vm: freebsd
74+
- os: ubuntu-latest
75+
vm: openbsd
16376

16477
steps:
16578
- name: Checkout
16679
uses: actions/checkout@v4
16780

168-
- name: Setup vm
81+
- name: Setup vm (freebsd)
16982
if: matrix.vm == 'freebsd'
17083
uses: vmactions/freebsd-vm@v1
17184

172-
- name: Setup vm
85+
- name: Setup vm (openbsd)
17386
if: matrix.vm == 'openbsd'
17487
uses: vmactions/openbsd-vm@v1
17588

176-
- name: Setup shell
89+
- name: Setup vm shell
90+
if: matrix.vm
17791
run: |
17892
mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash"
17993
#!/bin/bash --
18094
exec ssh ${{ matrix.vm }} "cd $(printf %q "$PWD") && exec \"\$SHELL\"$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}"
18195
EOF
18296
183-
- name: Install dependencies
184-
run: ${{ matrix.install-dependencies }}
97+
- name: Setup nix-shell
98+
if: matrix.container.image == 'docker.io/nixos/nix:latest'
99+
run: |
100+
docker run --rm -d --name nix --volume "$PWD:$PWD" --entrypoint sleep ${{ matrix.container.image }} infinity
101+
mkdir -p "$HOME/.local/bin" && tee "$HOME/.local/bin/bash" <<'EOF' && chmod a+x "$HOME/.local/bin/bash"
102+
#!/bin/bash --
103+
exec docker exec -i -w "$PWD" nix nix-shell --packages ruby --run "exec \"\$SHELL\"$(test $# -gt 0 && printf ' %q' "${@:1:$#-1}")" <"${@:$#}"
104+
EOF
105+
106+
- name: Install dependencies (freebsd)
107+
if: matrix.vm == 'freebsd'
108+
run: pkg install -y node npm protobuf ruby rubygem-bundler rubygem-rake
109+
110+
- name: Install dependencies (openbsd)
111+
if: matrix.vm == 'openbsd'
112+
run: |
113+
ruby=$(pkg_info -Q ruby | grep '^ruby-[0-9]' | sort -rV | head -n 1)
114+
pkg_add node protobuf "$ruby"
115+
pkg_info "$ruby" | grep 'ln -sf' | $SHELL
116+
117+
- name: Install dependencies (alpine)
118+
if: endsWith(matrix.container.image, ':alpine') || endsWith(matrix.container.image, '-alpine')
119+
run: apk add build-base
120+
121+
- name: Setup ruby
122+
if: matrix.ruby-version
123+
uses: ruby/setup-ruby@v1
124+
with:
125+
ruby-version: ${{ matrix.ruby-version }}
126+
bundler-cache: true
185127

186128
- name: Bundle
129+
if: "!matrix.ruby-version"
187130
run: bundle install
188131

189132
- name: Compile
133+
if: "!matrix.vm"
134+
run: bundle exec rake compile
135+
136+
- name: Compile
137+
if: matrix.vm
190138
run: EMBEDDED_SASS_PROTOCOL=https://github.com/sass/sass/raw/HEAD/spec/embedded_sass.proto PROTOC_BIN=$(which protoc) bundle exec rake compile
191139

140+
- name: Spec
141+
if: "!matrix.vm" # TODO: https://github.com/sass/dart-sass/pull/2413
142+
run: bundle exec rake spec
143+
192144
- name: Install
193145
run: rake -f -r bundler/gem_tasks install
194146

195-
# TODO: https://github.com/sass/dart-sass/pull/2413
196-
# - name: Spec
197-
# run: bundle exec rake spec
198-
199147
release:
200148

201149
if: github.event.repository.fork == false && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
202150

203-
needs: [lint, spec, spec-musl, spec-nix, spec-bsd]
151+
needs: [lint, spec]
204152

205153
runs-on: ubuntu-latest
206154

0 commit comments

Comments
 (0)