|
| 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 |
0 commit comments