-
Notifications
You must be signed in to change notification settings - Fork 5
143 lines (116 loc) · 4.53 KB
/
go.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
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]
jobs:
test:
strategy:
matrix:
os:
- macos-latest
- ubuntu-24.04
llvm: [18]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Install dependencies
if: startsWith(matrix.os, 'macos')
run: |
brew update
brew install llvm@${{matrix.llvm}} bdw-gc openssl libffi
brew link --force libffi
echo "$(brew --prefix llvm@${{matrix.llvm}})/bin" >> $GITHUB_PATH
# llcppg dependencies
brew install cjson
- name: Install dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{matrix.llvm}} main" | sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y llvm-${{matrix.llvm}}-dev clang-${{matrix.llvm}} libunwind-dev libclang-${{matrix.llvm}}-dev lld-${{matrix.llvm}} pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libcjson-dev
echo "/usr/lib/llvm-${{matrix.llvm}}/bin" >> $GITHUB_PATH
- name: Install LLGO
run: |
git clone https://github.com/goplus/llgo.git
echo $PWD
cd llgo/compiler
go install -v ./cmd/...
export LLGO_ROOT=$GITHUB_WORKSPACE/llgo
echo "LLGO_ROOT=$LLGO_ROOT" >> $GITHUB_ENV
- name: Build
run: go build -v ./...
- name: Set up Go for testing
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Install llcppg modules
run: |
echo "Using LLGO_ROOT: $LLGO_ROOT"
bash ./install.sh
- name: Test llcppsymg & llcppsigfetch
run: |
llgo cmptest ./_xtool/llcppsigfetch/parse/cvt_test/...
# llgo cmptest ./_xtool/llcppsymg/_cmptest/... causes
# panic: runtime error: index out of range [0] with length 0
cd _xtool/llcppsymg/_cmptest
# llgo cmptest ./... cause lld: error: undefined symbol: sort.init
# https://github.com/goplus/llgo/issues/944
llgo cmptest ./args_test
llgo cmptest ./clangutils_test
llgo cmptest ./config_test
llgo cmptest ./names_test
llgo cmptest ./parse_test
llgo cmptest ./symbol_test
llgo cmptest ./symg_test
cd ../../../
- name: Test
if: ${{!startsWith(matrix.os, 'macos')}}
run: go test -v ./...
- name: Test with coverage
if: startsWith(matrix.os, 'macos')
run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./...
- name: Test demos
run: |
# TODO(lijie): force python3-embed to be linked with python-3.12-embed
# Currently, python3-embed is python-3.13-embed, doesn't work with pytorch
# Will remove this after pytorch is fixed.
pcdir=$HOME/pc
mkdir -p $pcdir
libdir=$(pkg-config --variable=libdir python-3.12-embed)
echo "libdir: $libdir"
ln -s $libdir/pkgconfig/python-3.12-embed.pc $pcdir/python3-embed.pc
export PKG_CONFIG_PATH=$pcdir
bash .github/workflows/test_demo.sh
- name: Test demos with generated pkgs
if: startsWith(matrix.os, 'macos')
run: |
# install demo's lib
brew install lua zlib isl libgpg-error raylib z3 sqlite3 gmp libxml2 libxslt
export PKG_CONFIG_PATH="/opt/homebrew/opt/zlib/lib/pkgconfig"
export PKG_CONFIG_PATH="/opt/homebrew/opt/sqlite/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="/opt/homebrew/opt/libxslt/lib/pkgconfig:$PKG_CONFIG_PATH"
pkg-config --cflags --libs sqlite3
pkg-config --cflags --libs libxslt
llcppgtest -demos ./_llcppgtest
- name: Test demos with generated pkgs
if: startsWith(matrix.os, 'ubuntu')
run: |
# install demo's lib
sudo apt install liblua5.4-dev -y
llcppgtest -demo ./_llcppgtest/cjson
llcppgtest -demo ./_llcppgtest/lua
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{secrets.CODECOV_TOKEN}}
slug: goplus/llcppg