-
Notifications
You must be signed in to change notification settings - Fork 1
158 lines (134 loc) · 3.91 KB
/
test.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Pytest
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- goos: darwin
goarch: amd64
ext: '.dylib'
os: macos-latest
- goos: linux
goarch: amd64
ext: '.so'
CC: gcc
CXX: g++
os: ubuntu-20.04
- goos: darwin
goarch: arm64
ext: '.dylib'
os: macos-latest
- goos: windows
goarch: amd64
ext: '.dll'
os: windows-latest
- goos: linux
goarch: arm64
ext: '.so'
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
os: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Setup msbuild
if: matrix.goos == 'windows'
uses: microsoft/[email protected]
- name: Install aarch64-linux-gnu-gcc (for linux/arm64 builds only)
if: matrix.goos == 'linux' && matrix.goarch == 'arm64'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Build Library
run: |
export GOOS=${{ matrix.goos }}
export GOARCH=${{ matrix.goarch }}
export CC=${{ matrix.CC }}
export CXX=${{ matrix.CXX }}
export CGO_ENABLED=1
export PATH="$(pwd)/osxcross/target/bin:$PATH"
cd go
go mod tidy
go build -o sapphirewrapper-${{ matrix.goarch }}${{ matrix.ext }} -buildmode=c-shared
shell: bash
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: sapphirewrapper-${{ matrix.goos }}-${{ matrix.goarch }}
path: ./go/sapphirewrapper-${{ matrix.goarch }}${{ matrix.ext }}
test:
name: Pytest
runs-on: ubuntu-20.04
needs: build
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
arch: [amd64, arm64]
python-version: [3.11]
include:
- os: windows-latest
arch: amd64
python-version: 3.11
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Download built library - Linux
uses: actions/download-artifact@v2
with:
name: sapphirewrapper-linux-amd64
path: ./bin/
- name: Download built library - Darwin amd64
uses: actions/download-artifact@v2
with:
name: sapphirewrapper-darwin-amd64
path: ./bin/
- name: Download built library - Darwin arm64
uses: actions/download-artifact@v2
with:
name: sapphirewrapper-darwin-arm64
path: ./bin/
- name: Download built library - Linux arm64
uses: actions/download-artifact@v2
with:
name: sapphirewrapper-linux-arm64
path: ./bin/
- name: Download built library - Windows amd64
uses: actions/download-artifact@v2
with:
name: sapphirewrapper-windows-amd64
path: ./bin/
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install web3
pip install .
- name: Wait for 30 seconds
run: sleep 30
if: matrix.os == 'macos-latest'
- name: Wait for 30 seconds
run: sleep 30
if: matrix.arch == 'arm64'
- name: Wait for 60 seconds
run: sleep 60
if: matrix.arch == 'arm64' && matrix.os == 'macos-latest'
- name: Run tests
env:
TEST_PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }}
run: |
pytest