Commit 71f3ec5f authored by Sidney Keese's avatar Sidney Keese
Browse files

comprehensive circleci configuration

add go/rust path to linux env

fix ineffectual assign to err

change working directory

cargo install filecoin-proofs

save pkg to tmp

install pkg-config

fetch and cache parameters

maybe we don't need arch

install jq

wrap paramfetch with with-dots

maybe spell version correctly

reorder linting

use retry script

reordering linting was a mistake

better with-dots.sh
parent 186d3b6f
version: 2.1 version: 2.1
jobs: jobs:
build_linux: build_and_test_linux:
docker: docker:
- image: circleci/golang:1.12.1-stretch - image: circleci/golang:1.12.1-stretch
working_directory: /go/src/github.com/filecoin-project/go-sectorbuilder working_directory: ~/go/src/github.com/filecoin-project/go-sectorbuilder
resource_class: xlarge resource_class: xlarge
steps:
- configure_environment_variables
- run:
name: Install Rust toolchain
command: |
(sudo apt-get update && sudo apt-get install -y clang libssl-dev && which cargo && which rustc) || (curl https://sh.rustup.rs -sSf | sh -s -- -y)
rustc --version
- run:
name: Install jq
command: |
sudo apt-get update
sudo apt-get install -y jq
jq --version
- checkout
- update_submodules
- build_project
- lint_project
- install_filecoin_proofs
- restore_parameter_cache
- fetch_filecoin_parameters
- save_parameter_cache
- test_project
build_and_test_darwin:
macos:
xcode: "10.0.0"
working_directory: ~/go/src/github.com/filecoin-project/go-sectorbuilder
resource_class: medium
steps:
- configure_environment_variables
- run:
name: Install go
command: |
curl https://dl.google.com/go/go1.12.1.darwin-amd64.pkg -o /tmp/go.pkg && \
sudo installer -pkg /tmp/go.pkg -target /
go version
- run:
name: Install pkg-config
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config
- run:
name: Install Rust toolchain
command: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
rustc --version
- run:
name: Install jq
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install jq
jq --version
- checkout
- update_submodules
- build_project
- lint_project
- install_filecoin_proofs
- restore_parameter_cache
- fetch_filecoin_parameters
- save_parameter_cache
- test_project
workflows:
version: 2
build_and_test_linux:
jobs:
- build_and_test_linux
build_and_test_darwin:
jobs:
- build_and_test_darwin
commands:
configure_environment_variables:
steps: steps:
- run: - run:
name: Configure environment variables name: Configure environment variables
command: | command: |
echo 'export PATH="/usr/local/go/bin:${HOME}/.cargo/bin:${PATH}:${HOME}/go/bin:${HOME}/.bin"' >> $BASH_ENV
echo 'export GOPATH="${HOME}/go"' >> $BASH_ENV
echo 'export FILECOIN_PARAMETER_CACHE="${HOME}/filecoin-proof-parameters/"' >> $BASH_ENV echo 'export FILECOIN_PARAMETER_CACHE="${HOME}/filecoin-proof-parameters/"' >> $BASH_ENV
echo 'export GO111MODULE=on' >> $BASH_ENV echo 'export GO111MODULE=on' >> $BASH_ENV
- checkout install_filecoin_proofs:
steps:
- run:
name: Install filecoin-proofs binaries
command: |
cargo install filecoin-proofs
fetch_filecoin_parameters:
steps:
- run:
name: Fetch filecoin groth parameters
command: |
./scripts/retry.sh 1 10 1000 ./scripts/with-dots.sh paramfetch --params-for-sector-sizes=1024 --verbose
update_submodules:
steps:
- run: - run:
name: Update submodules name: Update submodules
command: git submodule update --init --recursive command: git submodule update --init --recursive
build_project:
steps:
- run: - run:
name: Build upstream project name: Build project
command: make command: make
lint_project:
steps:
- run: - run:
name: Build project name: Lint project
command: go build . command: go run github.com/golangci/golangci-lint/cmd/golangci-lint run
test_project:
workflows: steps:
version: 2 - run:
test_all: name: Test project
jobs: command: go test
- build_linux restore_parameter_cache:
steps:
- restore_cache:
keys:
- v1-proof-params-{{ checksum "~/.cargo/bin/paramfetch" }}
save_parameter_cache:
steps:
- save_cache:
key: v1-proof-params-{{ checksum "~/.cargo/bin/paramfetch" }}
paths:
- "~/filecoin-proof-parameters/"
...@@ -52,6 +52,7 @@ func TestSectorBuilderLifecycle(t *testing.T) { ...@@ -52,6 +52,7 @@ func TestSectorBuilderLifecycle(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
stagedSectors, err := sb.GetAllStagedSectors(ptr) stagedSectors, err := sb.GetAllStagedSectors(ptr)
require.NoError(t, err)
require.Equal(t, 1, len(stagedSectors)) require.Equal(t, 1, len(stagedSectors))
stagedSector := stagedSectors[0] stagedSector := stagedSectors[0]
require.Equal(t, uint64(1), stagedSector.SectorID) require.Equal(t, uint64(1), stagedSector.SectorID)
...@@ -78,9 +79,11 @@ func TestSectorBuilderLifecycle(t *testing.T) { ...@@ -78,9 +79,11 @@ func TestSectorBuilderLifecycle(t *testing.T) {
// verify the PoSt // verify the PoSt
isValid, err = sb.VerifyPoSt(1024, [][32]byte{status.CommR}, [32]byte{}, proofs, faults) isValid, err = sb.VerifyPoSt(1024, [][32]byte{status.CommR}, [32]byte{}, proofs, faults)
require.NoError(t, err)
require.True(t, isValid) require.True(t, isValid)
sealedSectors, err := sb.GetAllSealedSectors(ptr) sealedSectors, err := sb.GetAllSealedSectors(ptr)
require.NoError(t, err)
require.Equal(t, 1, len(sealedSectors), "expected to see one sealed sector") require.Equal(t, 1, len(sealedSectors), "expected to see one sealed sector")
sealedSector := sealedSectors[0] sealedSector := sealedSectors[0]
require.Equal(t, uint64(1), sealedSector.SectorID) require.Equal(t, uint64(1), sealedSector.SectorID)
...@@ -92,6 +95,7 @@ func TestSectorBuilderLifecycle(t *testing.T) { ...@@ -92,6 +95,7 @@ func TestSectorBuilderLifecycle(t *testing.T) {
// unseal the sector and retrieve the client's piece, verifying that the // unseal the sector and retrieve the client's piece, verifying that the
// retrieved bytes match what we originally wrote to the staged sector // retrieved bytes match what we originally wrote to the staged sector
unsealedPieceBytes, err := sb.ReadPieceFromSealedSector(ptr, "snoqualmie") unsealedPieceBytes, err := sb.ReadPieceFromSealedSector(ptr, "snoqualmie")
require.NoError(t, err)
require.Equal(t, pieceBytes, unsealedPieceBytes) require.Equal(t, pieceBytes, unsealedPieceBytes)
} }
......
...@@ -3,6 +3,7 @@ module github.com/filecoin-project/go-sectorbuilder ...@@ -3,6 +3,7 @@ module github.com/filecoin-project/go-sectorbuilder
go 1.12 go 1.12
require ( require (
github.com/golangci/golangci-lint v1.17.1 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/ipfs/go-log v0.0.1 github.com/ipfs/go-log v0.0.1
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
......
This diff is collapsed.
#!/usr/bin/env bash
# Inspired by https://gist.github.com/reacocard/28611bfaa2395072119464521d48729a
set -o errexit
set -o nounset
set -o pipefail
# Retry a command on a particular exit code, up to a max number of attempts,
# with exponential backoff.
# Invocation:
# err_retry exit_code attempts sleep_multiplier <command>
# exit_code: The exit code to retry on.
# attempts: The number of attempts to make.
# sleep_millis: Multiplier for sleep between attempts. Examples:
# If multiplier is 1000, sleep intervals are 1, 4, 9, 16, etc. seconds.
# If multiplier is 5000, sleep intervals are 5, 20, 45, 80, 125, etc. seconds.
exit_code=$1
attempts=$2
sleep_millis=$3
shift 3
for attempt in `seq 1 $attempts`; do
# This weird construction lets us capture return codes under -o errexit
"$@" && rc=$? || rc=$?
if [[ ! $rc -eq $exit_code ]]; then
exit $rc
fi
if [[ $attempt -eq $attempts ]]; then
exit $rc
fi
sleep_ms="$(($attempt * $attempt * $sleep_millis))"
echo >&2 "sleeping ${sleep_ms:0:-3}.${sleep_ms: -3}s and then retrying ($((attempt + 1))/${attempts})"
sleep "${sleep_ms:0:-3}.${sleep_ms: -3}"
done
#!/usr/bin/env bash
trap cleanup EXIT
cleanup() {
kill $DOT_PID
}
(
sleep 1
while true; do
(printf "." >&2)
sleep 1
done
) &
DOT_PID=$!
$@
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment