Skip to content

Commit d751003

Browse files
galarghrvagg
andauthored
ci: migrate ci setup from circle ci to github actions (#464)
* ci: migrate ci setup from circle ci to github actions * fix: the env var setup for the ci workflow * fix: use the correct casing for os checks * fix: gopath setting for the ci workflow * fix: put go and rust bin on path * fix: install cuda on linux arm, change xcode on macos and install golangci-lint * fix: install libmx * fix: install cuda on linux arm * fix: remove unused variable from bls_test * fix: link libcuda.so correctly * fix: install pkg-config on linux * fix: disable cargo term colors * fix: update library path on arm too * fix: symlink of cuda stubs * fix: x64 -> ARM64 * fix: do not run leak detector by default * chore: enabled triggering release from an arbitrary ref * chore: set DEBIAN_FRONTEND env variable to noninteractive * chore: remove comments that are not needed anymore * Update .github/workflows/ci.yml Co-authored-by: Rod Vagg <rod@vagg.org> --------- Co-authored-by: Rod Vagg <rod@vagg.org>
1 parent d041c9a commit d751003

File tree

3 files changed

+274
-2
lines changed

3 files changed

+274
-2
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Configure Environment Variables
2+
description: Configure environment variables for Filecoin FFI
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- if: runner.os == 'Linux' && runner.arch == 'ARM64'
8+
run: |
9+
wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/sbsa/cuda-ubuntu2204.pin
10+
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
11+
wget -q https://developer.download.nvidia.com/compute/cuda/12.5.1/local_installers/cuda-repo-ubuntu2204-12-5-local_12.5.1-555.42.06-1_arm64.deb
12+
sudo dpkg -i cuda-repo-ubuntu2204-12-5-local_12.5.1-555.42.06-1_arm64.deb
13+
sudo cp /var/cuda-repo-ubuntu2204-12-5-local/cuda-*-keyring.gpg /usr/share/keyrings/
14+
sudo apt-get update
15+
sudo apt-get -y install cuda-toolkit-12-5
16+
sudo mkdir -p /usr/lib/aarch64-linux-gnu/stubs
17+
sudo ln -s /usr/local/cuda-12.5/lib64/stubs/libcuda.so /usr/lib/aarch64-linux-gnu/stubs/libcuda.so.1
18+
sudo ln -s /usr/local/cuda-12.5/lib64/stubs/libcuda.so /usr/lib/aarch64-linux-gnu/stubs/libcuda.so
19+
shell: bash
20+
- run: |
21+
echo "FIL_PROOFS_PARAMETER_CACHE=${GITHUB_WORKSPACE}/filecoin-proof-parameters/" >> $GITHUB_ENV
22+
echo 'GO111MODULE=on' >> $GITHUB_ENV
23+
echo 'RUST_LOG=info' >> $GITHUB_ENV
24+
echo "GOPATH=${HOME}/go" >> $GITHUB_ENV
25+
echo "CARGO_TERM_COLOR=never" >> $GITHUB_ENV
26+
shell: bash
27+
- run: |
28+
echo "/usr/local/go/bin" >> $GITHUB_PATH
29+
echo "${GOPATH}/bin" >> $GITHUB_PATH
30+
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
31+
echo "${HOME}/.bin" >> $GITHUB_PATH
32+
shell: bash
33+
- if: runner.os == 'Linux' && runner.arch == 'ARM64'
34+
run: |
35+
echo "LD_LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/stubs:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
36+
echo "LIBRARY_PATH=/usr/lib/aarch64-linux-gnu/stubs:${LIBRARY_PATH}" >> $GITHUB_ENV
37+
shell: bash
38+
- if: runner.os == 'macOS'
39+
run: |
40+
echo "CPATH=$(brew --prefix)/include" >> $GITHUB_ENV
41+
echo "LIBRARY_PATH=$(brew --prefix)/lib" >> $GITHUB_ENV
42+
shell: bash
43+
- if: runner.os == 'Linux'
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install --no-install-recommends -y valgrind ocl-icd-opencl-dev libssl-dev libhwloc-dev nvidia-cuda-toolkit g++-10 pkgconf
47+
# Downgrade to GCC 10, as CUDA 11 doesn't play nice with GCC 11
48+
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-10 10
49+
sudo update-alternatives --set c++ /usr/bin/g++-10
50+
# Check if we need to install cuda-toolkit-12-5
51+
shell: bash
52+
- if: runner.os == 'macOS'
53+
run: |
54+
HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config md5sha1sum jq hwloc
55+
shell: bash
56+
- uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
57+
with:
58+
toolchain: 1.73
59+
- uses: actions/setup-go@v5
60+
with:
61+
go-version: '1.21'

.github/workflows/ci.yml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
tags:
9+
- v*
10+
workflow_dispatch:
11+
inputs:
12+
save:
13+
description: 'Save Filecoin parameters'
14+
required: false
15+
default: 'false'
16+
publish:
17+
description: 'Publish the static library'
18+
required: false
19+
default: 'false'
20+
run-leak-detector:
21+
description: 'Run the CGO leak detector'
22+
required: false
23+
default: 'false'
24+
ref:
25+
description: 'The ref to build'
26+
required: false
27+
28+
defaults:
29+
run:
30+
shell: bash
31+
32+
concurrency:
33+
group: ${{ github.workflow }}-${{ github.ref }}
34+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
35+
36+
permissions:
37+
contents: read
38+
39+
# Can we apply these to the entire workflow?
40+
env:
41+
# Build the kernel only for the single architecture. This should reduce
42+
# the overall compile-time significantly.
43+
EC_GPU_CUDA_NVCC_ARGS: --fatbin --gpu-architecture=sm_75 --generate-code=arch=compute_75,code=sm_75
44+
BELLMAN_CUDA_NVCC_ARGS: --fatbin --gpu-architecture=sm_75 --generate-code=arch=compute_75,code=sm_75
45+
NEPTUNE_CUDA_NVCC_ARGS: --fatbin --gpu-architecture=sm_75 --generate-code=arch=compute_75,code=sm_75
46+
DEBIAN_FRONTEND: noninteractive
47+
48+
jobs:
49+
check:
50+
name: Check code style and run linters
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
with:
55+
submodules: recursive
56+
- uses: ./.github/actions/configure-environment
57+
- if: github.event.inputs.ref != ''
58+
uses: actions/checkout@v4
59+
with:
60+
submodules: recursive
61+
ref: ${{ github.event.inputs.ref }}
62+
- name: Run shellcheck
63+
run: shellcheck ./install-filcrypto
64+
- name: Run cargo fmt
65+
run: |
66+
rustup component add rustfmt
67+
cargo fmt --manifest-path ./rust/Cargo.toml --all -- --check
68+
- name: Run cargo clippy
69+
run: cd rust && cargo clippy --all-targets --features blst-portable,opencl -- -D warnings
70+
- name: Run go fmt
71+
# `! go fmt ./... 2>&1 | read"` doesn't work, this one does, thanks
72+
# https://carsonip.me/posts/go-fmt-and-ci/
73+
run: |
74+
output=$(go fmt ./...)
75+
echo "${output}"
76+
test -z "${output}"
77+
- name: Run various linters
78+
run: |
79+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
80+
make go-lint
81+
cgo-bindings:
82+
name: Build and test CGO bindings (${{ matrix.runner }})
83+
runs-on: ${{ matrix.runner }}
84+
strategy:
85+
matrix:
86+
runner: ['ubuntu-latest', ["self-hosted", "linux", "arm64", "xlarge"], 'macos-latest']
87+
fail-fast: false
88+
steps:
89+
- run: echo "Running on $RUNNER_OS $RUNNER_ARCH"
90+
- uses: actions/checkout@v4
91+
with:
92+
submodules: recursive
93+
- uses: ./.github/actions/configure-environment
94+
- if: github.event.inputs.ref != ''
95+
uses: actions/checkout@v4
96+
with:
97+
submodules: recursive
98+
ref: ${{ github.event.inputs.ref }}
99+
- if: runner.os == 'macOS'
100+
run: cd rust && cargo fetch
101+
- name: Build project
102+
run: make
103+
- name: Build project without CGO
104+
run: env CGO_ENABLED=0 go build .
105+
- if: runner.os == 'Linux'
106+
uses: actions/cache/restore@v3
107+
with:
108+
key: v28-proof-params-${{ runner.os }}-${{ runner.arch }}
109+
path: |
110+
./filecoin-proof-parameters
111+
- if: runner.os == 'Linux'
112+
name: Obtain Filecoin parameters
113+
run: |
114+
DIR=$(pwd)
115+
cd $(mktemp -d)
116+
go install github.com/filecoin-project/go-paramfetch/paramfetch@latest
117+
$GOPATH/bin/paramfetch 2048 "${DIR}/parameters.json" "${DIR}/srs-inner-product.json"
118+
- if: runner.os == 'Linux' && ((github.event == 'push' && !startsWith(github.ref, 'refs/tags/')) || github.event.inputs.save == 'true')
119+
uses: actions/cache/save@v3
120+
with:
121+
key: v28-proof-params-${{ runner.os }}-${{ runner.arch }}
122+
path: |
123+
./filecoin-proof-parameters
124+
- if: runner.os == 'Linux'
125+
run: cd rust && rustup target add wasm32-unknown-unknown
126+
- if: github.event.inputs.run-leak-detector == 'true'
127+
run: make cgo-leakdetect
128+
- if: runner.os == 'Linux'
129+
run: cd rust && FIL_PROOFS_PARAMETER_CACHE="${GITHUB_WORKSPACE}/filecoin-proof-parameters/" RUST_LOG=info cargo test --all --release -- --test-threads 1 && cd ..
130+
- if: runner.os == 'Linux'
131+
run: GOEXPERIMENT=cgocheck2 RUST_LOG=info go test -p 1 -timeout 60m
132+
- if: runner.os == 'macOS'
133+
name: Build project and tests, but don't actually run the tests (used to verify that build/link works with Darwin)
134+
run: GOEXPERIMENT=cgocheck2 RUST_LOG=info go test -run=^$
135+
supraseal:
136+
name: Build with CUDA supraseal
137+
runs-on: ubuntu-latest
138+
steps:
139+
- uses: actions/checkout@v4
140+
with:
141+
submodules: recursive
142+
- uses: ./.github/actions/configure-environment
143+
- if: github.event.inputs.ref != ''
144+
uses: actions/checkout@v4
145+
with:
146+
submodules: recursive
147+
ref: ${{ github.event.inputs.ref }}
148+
- name: Build project with `FFI_USE_CUDA_SUPRASEAL=1`
149+
run: FFI_BUILD_FROM_SOURCE=1 FFI_USE_CUDA_SUPRASEAL=1 make
150+
publish:
151+
needs: [check, cgo-bindings, supraseal]
152+
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event.inputs.publish == 'true'
153+
name: Publish the static library (${{ matrix.runner }})
154+
runs-on: ${{ matrix.runner }}
155+
strategy:
156+
matrix:
157+
runner: ['ubuntu-latest', ['self-hosted', 'linux', 'arm64', 'xlarge'], 'macos-latest']
158+
fail-fast: false
159+
steps:
160+
- run: echo "Running on $RUNNER_OS $RUNNER_ARCH"
161+
- uses: actions/checkout@v4
162+
with:
163+
submodules: recursive
164+
- uses: ./.github/actions/configure-environment
165+
- if: github.event.inputs.ref != ''
166+
uses: actions/checkout@v4
167+
with:
168+
submodules: recursive
169+
ref: ${{ github.event.inputs.ref }}
170+
- if: runner.os == 'macOS'
171+
run: |
172+
cd rust && rustup target add x86_64-apple-darwin
173+
cd rust && cargo fetch
174+
- if: runner.os == 'Linux'
175+
name: Build and publish the standard release
176+
run: |
177+
cd rust
178+
179+
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
180+
181+
TARBALL_PATH="/tmp/${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard.tar.gz"
182+
RELEASE_NAME="${REPOSITORY_NAME}-$(uname)-$(uname -m)-standard"
183+
184+
# Note: the blst dependency uses the portable configuration for maximum compatibility
185+
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
186+
./scripts/package-release.sh $TARBALL_PATH
187+
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME
188+
- if: runner.os == 'Linux'
189+
name: Build the optimized release
190+
run: |
191+
cd rust
192+
193+
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
194+
195+
TARBALL_PATH="/tmp/${CIRCLE_PROJECT_REPONAME}-$(uname)-$(uname -m)-optimized.tar.gz"
196+
RUSTFLAGS="-C target-feature=$(cat rustc-target-features-optimized.json | jq -r '.[].rustc_target_feature' | tr '\n' ',')"
197+
198+
./scripts/build-release.sh build --verbose --no-default-features --features multicore-sdr,opencl
199+
./scripts/package-release.sh $TARBALL_PATH
200+
- if: runner.os == 'macOS'
201+
name: Build and publish the universal standard release
202+
run: |
203+
cd rust
204+
205+
REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}
206+
207+
RELEASE_NAME="${CIRCLE_PROJECT_REPONAME}-$(uname)-standard"
208+
TARBALL_PATH="/tmp/${RELEASE_NAME}.tar.gz"
209+
210+
# Note: the blst dependency uses the portable configuration for maximum compatibility
211+
./scripts/build-release.sh lipo --verbose --no-default-features --features multicore-sdr,opencl,blst-portable
212+
./scripts/package-release.sh $TARBALL_PATH
213+
./scripts/publish-release.sh $TARBALL_PATH $RELEASE_NAME

bls_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,10 @@ func BenchmarkBLSVerifyBatch(b *testing.B) {
121121
func benchmarkBLSVerifyBatchSize(size int) func(b *testing.B) {
122122
return func(b *testing.B) {
123123
var digests []Digest
124-
var msgs []Message
125124
var sigs []Signature
126125
var pubks []PublicKey
127126
for i := 0; i < size; i++ {
128127
msg := Message(fmt.Sprintf("cats cats cats cats %d %d %d dogs", i, i, i))
129-
msgs = append(msgs, msg)
130128
digests = append(digests, Hash(msg))
131129
priv := PrivateKeyGenerate()
132130
sig := PrivateKeySign(priv, msg)

0 commit comments

Comments
 (0)