Skip to content

Commit f41c465

Browse files
committed
github/workflows: support multiple GOOS
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 01fe80a commit f41c465

File tree

1 file changed

+65
-6
lines changed

1 file changed

+65
-6
lines changed

.github/workflows/test.yaml

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,80 @@ on:
55
branches:
66
- "main"
77
pull_request:
8-
branches:
9-
- "main"
8+
9+
defaults:
10+
run:
11+
shell: bash
1012

1113
env:
1214
LLVM_VERSION: 15
1315

1416
jobs:
1517
test:
16-
name: test
17-
runs-on: ubuntu-22.04
18+
strategy:
19+
matrix:
20+
os:
21+
- "ubuntu-22.04" # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
22+
- "macos-13" # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md
23+
go-version:
24+
- "1.20.x"
25+
- "1.21.x"
26+
fail-fast: false
27+
28+
runs-on:
29+
labels: ${{ matrix.os }}
30+
31+
env:
32+
# for Homebrew: https://docs.brew.sh/Manpage
33+
HOMEBREW_PREFIX: /usr/local
34+
HOMEBREW_CURL_VERBOSE: 1
35+
HOMEBREW_DEVELOPER: 1
36+
HOMEBREW_DISPLAY_INSTALL_TIMES: 1
37+
HOMEBREW_NO_ANALYTICS: 1
38+
HOMEBREW_NO_AUTO_UPDATE: 1
39+
HOMEBREW_NO_INSTALL_CLEANUP: 1
40+
HOMEBREW_NO_INSTALL_UPGRADE: 1
41+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
42+
HOMEBREW_VERBOSE: 1
1843

1944
steps:
2045
- name: Checkout
2146
uses: actions/checkout@v4
2247

23-
- name: Test in Docker
48+
- name: Install Go
49+
uses: actions/setup-go@v4
50+
with:
51+
go-version: ${{ matrix.go-version }}
52+
check-latest: true
53+
54+
- name: Setup install LLVM
55+
if: matrix.os == 'ubuntu-22.04'
56+
run: |
57+
if ! command -v brew > /dev/null 2>&1; then
58+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
59+
echo "PATH=/home/linuxbrew/.linuxbrew/bin:$PATH" >> ${GITHUB_ENV}
60+
fi
61+
echo "HOMEBREW_CACHE=${HOME}/.cache/Homebrew" >> ${GITHUB_ENV}
62+
echo "CPPFLAGS=-I${HOMEBREW_PREFIX}/opt/llvm@15/include:${CPPFLAGS}" >> ${GITHUB_ENV}
63+
echo "LDFLAGS=-L${HOMEBREW_PREFIX}/opt/llvm@15/lib:${LDFLAGS}" >> ${GITHUB_ENV}
64+
65+
- name: Install latest LLVM toolchain
66+
if: matrix.os == 'ubuntu-22.04'
67+
run: |
68+
mkdir -p ${HOMEBREW_CACHE}
69+
brew install llvm@${LLVM_VERSION}
70+
71+
- name: Cache brewed LLVM
72+
uses: actions/cache@v3
73+
with:
74+
key: ${{ matrix.os }}-homebrew
75+
path: $[HOMEBREW_CACHE}
76+
77+
- name: Test
78+
if: matrix.os == 'ubuntu-22.04'
2479
run: |
25-
docker container run -t --mount type=bind,src=$PWD,dst=/go/src/github.com/go-clang/clang-v${LLVM_VERSION} -w /go/src/github.com/go-clang/clang-v${LLVM_VERSION} ghcr.io/go-clang/base:${LLVM_VERSION} make test
80+
docker container run -t \
81+
--mount type=bind,src=$PWD,dst=/go/src/github.com/go-clang/clang-v${LLVM_VERSION} \
82+
--workdir /go/src/github.com/go-clang/clang-v${LLVM_VERSION} \
83+
ghcr.io/go-clang/base:${LLVM_VERSION} \
84+
make test

0 commit comments

Comments
 (0)