Skip to content

Commit 791ed5e

Browse files
authored
Merge pull request #507 from YOU54F/feat/alpine_support
feat: alpine support
2 parents a4c3871 + 2fb19fe commit 791ed5e

21 files changed

+1003
-473
lines changed

.github/workflows/build-and-test.yml

+110-36
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
with:
1616
fetch-depth: 0
1717
- run: GH_CREATE_PRE_RELEASE=true ./script/ci/release.sh
18-
if: github.ref == 'refs/heads/master' && env.ACT != 'true' && runner.os == 'Linux'
18+
if: github.ref == 'refs/heads/master' && env.ACT != true && runner.os == 'Linux'
1919
env:
2020
GITHUB_TOKEN: ${{ github.token }}
21-
21+
2222
prebuild:
23-
needs: [ create_pre_release ]
23+
needs: [create_pre_release]
2424
runs-on: ${{ matrix.os }}
2525
defaults:
2626
run:
@@ -30,11 +30,31 @@ jobs:
3030
matrix:
3131
node-version: [20]
3232
os: [
33-
macos-14,
34-
macos-12,
35-
ubuntu-latest,
36-
windows-latest
33+
macos-12,
34+
ubuntu-latest,
35+
windows-latest,
3736
]
37+
docker: [false]
38+
alpine: [false]
39+
arch: ['amd64']
40+
include:
41+
- os: ubuntu-latest
42+
docker: true
43+
alpine: false
44+
arch: arm64
45+
- os: ubuntu-latest
46+
docker: true
47+
alpine: true
48+
arch: arm64
49+
- os: ubuntu-latest
50+
docker: true
51+
alpine: true
52+
arch: amd64
53+
- os: macos-14
54+
docker: false
55+
alpine: false
56+
arch: arm64
57+
name: Prebuild ${{ matrix.docker == true && matrix.alpine == true && 'linux-musl' || matrix.docker == true && matrix.alpine == false && 'linux' || matrix.os }}-${{ matrix.arch }}
3858

3959
env:
4060
NODE_VERSION: ${{ matrix.node-version }}
@@ -43,7 +63,7 @@ jobs:
4363
- uses: actions/checkout@v4
4464
with:
4565
fetch-depth: 0
46-
66+
4767
- name: Use Node.js ${{ env.NODE_VERSION }}
4868
uses: actions/setup-node@v4
4969
with:
@@ -52,27 +72,32 @@ jobs:
5272
- if: runner.os == 'Windows'
5373
run: echo "ONLY_DOWNLOAD_PACT_FOR_WINDOWS=true" >> $GITHUB_ENV
5474

55-
- run: ./script/ci/prebuild.sh
56-
5775
- name: Set up QEMU
58-
if: runner.os == 'Linux'
76+
if: ${{ matrix.docker == true && matrix.arch == 'arm64' }}
5977
uses: docker/setup-qemu-action@v3
60-
- name: Set up Docker Buildx
61-
if: runner.os == 'Linux'
62-
uses: docker/setup-buildx-action@v3
63-
- if: runner.os == 'Linux'
64-
name: prebuild arm64
65-
run: docker run -v $PWD:/home --platform linux/arm64 --rm node:20 bin/bash -c 'cd /home && /home/script/ci/prebuild.sh'
78+
- if: ${{ matrix.docker == true && matrix.alpine == true }}
79+
name: prebuild linux ${{ matrix.arch }} musl
80+
run: docker run -v $PWD:/home --platform linux/${{ matrix.arch }} --rm node:20-alpine bin/sh -c 'apk add bash && cd /home && bash -c "/home/script/ci/prebuild-alpine.sh" && rm -rf ffi node_modules'
81+
82+
- if: ${{ matrix.docker == true && matrix.alpine != true }}
83+
name: prebuild linux ${{ matrix.arch }}
84+
run: docker run -v $PWD:/home --platform linux/${{ matrix.arch }} --rm node:20 bin/bash -c 'cd /home && /home/script/ci/prebuild.sh && rm -rf ffi node_modules'
85+
86+
- run: sudo chown -R $(id -u):$(id -g) prebuilds
87+
if: ${{ matrix.docker == true }}
88+
89+
- run: ./script/ci/prebuild.sh
90+
if: ${{ matrix.docker != true }}
6691

6792
- name: Upload prebuild for ${{ runner.os }}-${{ runner.arch }}
6893
uses: actions/upload-artifact@v3
6994
with:
7095
path: prebuilds/*.tar.gz
71-
96+
7297
- run: GH_PRE_RELEASE_UPLOAD=true ./script/ci/release.sh
73-
if: github.ref == 'refs/heads/master' && env.ACT != 'true'
98+
if: github.ref == 'refs/heads/master' && env.ACT != true
7499
env:
75-
GITHUB_TOKEN: ${{ github.token }}
100+
GITHUB_TOKEN: ${{ github.token }}
76101

77102
test:
78103
runs-on: ${{ matrix.os }}
@@ -83,13 +108,53 @@ jobs:
83108
strategy:
84109
fail-fast: false
85110
matrix:
86-
node-version: [16,18,20]
87-
os: [
88-
macos-14,
89-
macos-12,
90-
ubuntu-latest,
91-
windows-latest
92-
]
111+
node-version: [16, 18, 20, 22]
112+
os: [macos-14, macos-12, ubuntu-latest, windows-latest]
113+
docker: [false]
114+
include:
115+
- os: ubuntu-latest
116+
docker: true
117+
alpine: false
118+
arch: arm64
119+
node-version: 22
120+
- os: ubuntu-latest
121+
docker: true
122+
alpine: true
123+
arch: arm64
124+
node-version: 22
125+
- os: ubuntu-latest
126+
docker: true
127+
alpine: true
128+
arch: amd64
129+
node-version: 22
130+
- os: ubuntu-latest
131+
docker: true
132+
alpine: false
133+
arch: arm64
134+
node-version: 20
135+
- os: ubuntu-latest
136+
docker: true
137+
alpine: true
138+
arch: arm64
139+
node-version: 20
140+
- os: ubuntu-latest
141+
docker: true
142+
alpine: true
143+
arch: amd64
144+
node-version: 20
145+
- os: ubuntu-latest
146+
docker: true
147+
alpine: true
148+
arch: arm64
149+
node-version: 18
150+
- os: ubuntu-latest
151+
docker: true
152+
alpine: true
153+
arch: amd64
154+
node-version: 18
155+
156+
name: Test ${{ matrix.docker == true && matrix.alpine == true && 'linux-musl' || matrix.docker == true && matrix.alpine == false && 'linux' || matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node-version }}
157+
93158
env:
94159
NODE_VERSION: ${{ matrix.node-version }}
95160
LOG_LEVEL: debug
@@ -109,22 +174,31 @@ jobs:
109174

110175
- if: runner.os == 'Windows'
111176
run: echo "ONLY_DOWNLOAD_PACT_FOR_WINDOWS=true" >> $GITHUB_ENV
112-
- run: LOG_LEVEL=debug ./script/ci/unpack-and-test.sh
177+
- if: matrix.os == 'macos-14'
178+
run: brew install protobuf
113179

180+
- run: LOG_LEVEL=debug ./script/ci/unpack-and-test.sh
181+
if: ${{ matrix.docker != true }}
114182

115183
- name: Set up QEMU
116-
if: runner.os == 'Linux'
184+
if: ${{ matrix.docker == true && matrix.arch == 'arm64' }}
117185
uses: docker/setup-qemu-action@v3
118-
- name: Set up Docker Buildx
119-
if: runner.os == 'Linux'
120-
uses: docker/setup-buildx-action@v3
121-
- if: runner.os == 'Linux'
186+
187+
- if: ${{ matrix.docker == true && matrix.alpine != true && matrix.arch == 'arm64' }}
122188
name: test arm64
123-
run: docker run -v $PWD:/home --platform linux/arm64 --rm node:20 bin/bash -c 'cd /home && npm test'
189+
run: docker run -v $PWD:/home --platform linux/${{ matrix.arch }} --rm node:${{ matrix.node-version }} bin/bash -c 'cd /home && /home/script/ci/unpack-and-test.sh'
190+
191+
- if: ${{ matrix.docker == true && matrix.alpine == true && matrix.arch == 'amd64' }}
192+
name: test linux amd64 musl
193+
run: docker run -v $PWD:/home --platform linux/${{ matrix.arch }} --rm node:${{ matrix.node-version }}-alpine bin/sh -c 'apk add bash curl gcompat file && cd /home && /home/script/ci/unpack-and-test.sh'
194+
195+
- if: ${{ matrix.docker == true && matrix.alpine == true && matrix.arch == 'arm64' }}
196+
name: test linux arm64 musl
197+
run: docker run -v $PWD:/home --platform linux/${{ matrix.arch }} --rm node:${{ matrix.node-version }}-alpine bin/sh -c 'apk add bash curl file protoc protobuf-dev && cd /home && /home/script/ci/unpack-and-test.sh'
124198

125199
release_dry_run:
126200
runs-on: ubuntu-latest
127-
needs: [ create_pre_release, prebuild ]
201+
needs: [create_pre_release, prebuild]
128202
if: github.ref == 'refs/heads/master'
129203

130204
env:
@@ -141,7 +215,7 @@ jobs:
141215
node-version: ${{ env.NODE_VERSION }}
142216
registry-url: 'https://registry.npmjs.org'
143217

144-
- name: "release - dry run: ${{ env.DRY_RUN }}"
218+
- name: 'release - dry run: ${{ env.DRY_RUN }}'
145219
id: publish
146220
run: script/ci/release.sh
147221
env:

0 commit comments

Comments
 (0)