Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 102 additions & 83 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,31 @@ jobs:

complete:
if: always()
needs: [fmt, cargo-deny, rust-check-git-rev-deps, build]
runs-on: ubuntu-22.04
needs: [fmt, cargo-deny, rust-check-git-rev-deps, build-linux, build-mac]
runs-on:
- namespace-profile-jammy-1-stellar-core
- nscloud-cache-exp-do-not-commit
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1

fmt:
runs-on: ubuntu-22.04
runs-on:
- namespace-profile-jammy-1-stellar-core
- nscloud-cache-exp-do-not-commit
steps:
- uses: actions/checkout@v4
- run: rustup component add rustfmt
- run: rustup update
- run: cargo fmt --all --check
- uses: namespacelabs/nscloud-checkout-action@v7
with:
fetch-depth: 1
submodules: recursive
- run: rustup component add rustfmt
- run: rustup update
- run: cargo fmt --all --check

cargo-deny:
runs-on: ubuntu-22.04
runs-on:
- namespace-profile-jammy-1-stellar-core
- nscloud-cache-exp-do-not-commit
strategy:
matrix:
checks:
Expand All @@ -38,100 +47,69 @@ jobs:
# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: ${{ matrix.checks == 'advisories' }}
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@8d73959fce1cdc8989f23fdf03bec6ae6a6576ef
with:
command: check ${{ matrix.checks }}
# leave arguments empty so we don't test --all-features
# which will see conflicting env versions
arguments:
- uses: namespacelabs/nscloud-checkout-action@v7
with:
fetch-depth: 1
submodules: recursive
- uses: EmbarkStudios/cargo-deny-action@8d73959fce1cdc8989f23fdf03bec6ae6a6576ef
with:
command: check ${{ matrix.checks }}
# leave arguments empty so we don't test --all-features
# which will see conflicting env versions
arguments:

rust-check-git-rev-deps:
runs-on: ubuntu-22.04
runs-on:
- namespace-profile-jammy-1-stellar-core
- nscloud-cache-exp-do-not-commit
steps:
- uses: actions/checkout@v4
- uses: stellar/actions/rust-check-git-rev-deps@main

build:
runs-on: ubuntu-jammy-16-cores-amd64
env:
CACHED_PATHS: |
~/.ccache
~/.cargo
target
- uses: namespacelabs/nscloud-checkout-action@v7
with:
fetch-depth: 1
submodules: recursive
- uses: stellar/actions/rust-check-git-rev-deps@main

build-linux:
runs-on:
- namespace-profile-jammy-32-stellar-core;overrides.cache-tag=config-${{ matrix.toolchain }}-${{ matrix.protocol }}
strategy:
fail-fast: false
matrix:
toolchain: [ "gcc", "clang"]
protocol: ["current", "next"]
scenario: ["", "--check-test-tx-meta"]
steps:
- name: Fix kernel mmap rnd bits
# Asan in llvm provided in ubuntu 22.04 is incompatible with
# high-entropy ASLR in much newer kernels that GitHub runners are
# using leading to random crashes: https://reviews.llvm.org/D148280
run: sudo sysctl vm.mmap_rnd_bits=28

# We start with as cheap as possible a cache probe to see if we have an exact hit on this
# git commit ID (for a given OS/toolchain/protocol). If so we can skip all subsequent
# steps: we already tested this exact SHA.
#
# Unfortunately due to the way github actions control flow works, we have to repeat the
# step 'if' condition in each step, and cannot actually "exit early" and skip the job.
# There are a lot of duplicate bug reports filed on this aspect of github actions, don't
# bother filing another.
- name: Probe Cache
id: cache
uses: actions/cache/restore@v4
- name: Checkout with Namespace Git mirrors cache
uses: namespacelabs/nscloud-checkout-action@v7
with:
path: ${{ env.CACHED_PATHS }}
key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.protocol }}-${{ github.sha }}
lookup-only: true

# When we have a cache miss on the exact commit SHA, we restore from the prefix without it.
# This will restore the most-recently-written cache (github does this date ordering itself).
- name: Restore Cache
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: ${{ env.CACHED_PATHS }}
key: ${{ steps.cache.outputs.cache-primary-key }}
restore-keys: |
${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.protocol }}
fetch-depth: 1
submodules: recursive

- uses: actions/checkout@v4
if: steps.cache.outputs.cache-hit != 'true'
- name: Configure Namespace cache volume
uses: namespacelabs/nscloud-cache-action@v1
with:
fetch-depth: 200
submodules: true
- name: install core packages
if: steps.cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get -y install --no-install-recommends apt-utils dialog git iproute2 procps lsb-release
- name: install tool chain
if: steps.cache.outputs.cache-hit != 'true'
run: |
sudo apt-get -y install libstdc++-10-dev clang-format-12 ccache lldb
if test "${{ matrix.toolchain }}" = "gcc" ; then
sudo apt-get -y install cpp-10 gcc-10 g++-10
else
sudo apt-get -y install clang-12 llvm-12
fi
path: |
~/.cargo
build-${{matrix.toolchain}}-${{matrix.protocol}}

- name: install rustup
run: ./install-rust.sh

- name: install rustup components
if: steps.cache.outputs.cache-hit != 'true'
run: rustup component add rustfmt

- name: install cargo-cache
if: steps.cache.outputs.cache-hit != 'true'
run: cargo install --locked cargo-cache --version 0.8.3

- name: install cargo-sweep
if: steps.cache.outputs.cache-hit != 'true'
run: cargo install --locked cargo-sweep --version 0.7.0
- name: install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: sudo apt-get -y install postgresql git build-essential pkg-config autoconf automake libtool bison flex libpq-dev parallel libunwind-dev sed perl

- name: Build
if: steps.cache.outputs.cache-hit != 'true'
run: |
if test "${{ matrix.toolchain }}" = "gcc" ; then
export CC='gcc'
Expand All @@ -141,11 +119,52 @@ jobs:
export CXX='clang++'
fi
echo Build with $CC and $CXX
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }} ${{ matrix.scenario }}
./ci-build.sh --use-temp-db --protocol ${{ matrix.protocol }}

build-mac:
runs-on:
- namespace-profile-macos-sequoia;overrides.cache-tag=config-macos-sequoia
steps:

- name: Checkout with Namespace Git mirrors cache
uses: namespacelabs/nscloud-checkout-action@v7
with:
fetch-depth: 1
submodules: recursive

# We only _save_ to the cache when we had a cache miss, are running on master, and are the non-txmeta scenario.
- uses: actions/cache/save@v4
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.ref_name == 'master' && matrix.scenario == ''}}
- name: Configure Namespace cache volume
uses: namespacelabs/nscloud-cache-action@v1
with:
path: ${{ env.CACHED_PATHS }}
key: ${{ steps.cache.outputs.cache-primary-key }}
path: |
~/.cargo
build-clang-current

- name: install prerequisites and uninstall brew rust, add rustup
run: |
brew install libsodium libtool autoconf automake pkg-config libpq openssl parallel ccache bison gnu-sed perl coreutils
brew uninstall rust rustup
brew install rustup

- name: install rustup components
run: |
rustup-init -y
rustup component add rustfmt rustc cargo clippy rust-src rust-std

- name: install cargo-cache
run: |
cargo install --locked cargo-cache --version 0.8.3

- name: install cargo-sweep
run: |
cargo install --locked cargo-sweep --version 0.7.0

- name: Build
run: |
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix)/opt/libpq/lib/pkgconfig"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix)/opt/openssl@3/lib/pkgconfig"
export PATH="$(brew --prefix bison)/bin:$PATH"
export CC='clang'
export CXX='clang++'
export CLANG_VERSION=none
export SKIP_FORMAT_CHECK=1
./ci-build.sh --disable-postgres --protocol current
46 changes: 21 additions & 25 deletions ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ while [[ -n "$1" ]]; do
export TEMP_POSTGRES=1
echo Using temp database
;;
"--check-test-tx-meta")
if [[ -z "${PROTOCOL}" ]]; then
echo 'must specify --protocol before --check-test-tx-meta'
exit 1
fi
export TEST_SPEC='[tx]'
export STELLAR_CORE_TEST_PARAMS="--ll fatal -r simple --all-versions --rng-seed 12345 --check-test-tx-meta ${PWD}/test-tx-meta-baseline-${PROTOCOL}"
;;
"--protocol")
PROTOCOL="$1"
shift
Expand Down Expand Up @@ -61,15 +53,16 @@ while [[ -n "$1" ]]; do

done

echo $TRAVIS_PULL_REQUEST

NPROCS=$(getconf _NPROCESSORS_ONLN)

echo "Found $NPROCS processors"
date

mkdir -p "build-${CC}-${PROTOCOL}"
cd "build-${CC}-${PROTOCOL}"

# Try to ensure we're using the real g++ and clang++ versions we want
mkdir bin
mkdir -p bin

export PATH=`pwd`/bin:$PATH
echo "PATH is $PATH"
Expand All @@ -80,19 +73,19 @@ if test $CXX = 'clang++'; then
# Use CLANG_VERSION environment variable if set, otherwise default to 12
CLANG_VER=${CLANG_VERSION:-12}
which clang-${CLANG_VER}
ln -s `which clang-${CLANG_VER}` bin/clang
ln -sf `which clang-${CLANG_VER}` bin/clang
which clang++-${CLANG_VER}
ln -s `which clang++-${CLANG_VER}` bin/clang++
ln -sf `which clang++-${CLANG_VER}` bin/clang++
which llvm-symbolizer-${CLANG_VER}
ln -s `which llvm-symbolizer-${CLANG_VER}` bin/llvm-symbolizer
ln -sf `which llvm-symbolizer-${CLANG_VER}` bin/llvm-symbolizer
clang -v
llvm-symbolizer --version || true
elif test $CXX = 'g++'; then
RUN_PARTITIONS=$(seq $NPROCS $((2*NPROCS-1)))
which gcc-10
ln -s `which gcc-10` bin/gcc
ln -sf `which gcc-10` bin/gcc
which g++-10
ln -s `which g++-10` bin/g++
ln -sf `which g++-10` bin/g++
which g++
g++ -v
fi
Expand All @@ -111,11 +104,11 @@ export ASAN_OPTIONS="quarantine_size_mb=100:malloc_context_size=4:detect_leaks=0
echo "config_flags = $config_flags"

#### ccache config
export CCACHE_DIR=$HOME/.ccache
export CCACHE_DIR=$(pwd)/.ccache
export CCACHE_COMPRESS=true
export CCACHE_COMPRESSLEVEL=9
# cache size should be large enough for a full build
export CCACHE_MAXSIZE=500M
export CCACHE_MAXSIZE=800M
export CCACHE_CPP2=true

# periodically check to see if caches are old and purge them if so
Expand All @@ -127,11 +120,10 @@ if [ -d "$CCACHE_DIR" ] ; then
fi

ccache -p

ccache -s
date
time ./autogen.sh
time ./configure $config_flags
time (cd .. && ./autogen.sh)
time ../configure $config_flags
if [ -z "${SKIP_FORMAT_CHECK}" ]; then
make format
d=`git diff | wc -l`
Expand All @@ -155,9 +147,8 @@ date
time make -j$(($NPROCS - 1))

ccache -s
### incrementally purge old content from cargo source cache and target directory
cargo cache trim --limit 100M
cargo sweep --maxsize 500MB
### incrementally purge old content from target directory
(cd .. && CARGO_TARGET_DIR="build-${CC}-${PROTOCOL}/target" cargo sweep --maxsize 800MB)

if [ $WITH_TESTS -eq 0 ] ; then
echo "Build done, skipping tests"
Expand All @@ -182,7 +173,12 @@ export NUM_PARTITIONS=$((NPROCS*2))
export RUN_PARTITIONS
export RND_SEED=$(($(date +%s) / 86400)) # Convert to days since epoch
echo "Using RND_SEED: $RND_SEED"
ulimit -n 256
ulimit -n 4096
time make check

echo Running fixed check-test-tx-meta tests
export TEST_SPEC='[tx]'
export STELLAR_CORE_TEST_PARAMS="--ll fatal -r simple --all-versions --rng-seed 12345 --check-test-tx-meta ${PWD}/../test-tx-meta-baseline-${PROTOCOL}"
time make check

echo All done
Expand Down
Loading
Loading