build_and_test.yml: ensure tests & ./run_clippy.sh pass for build in the Dockerfile

This patch adds a third build type to the build-neon build matrix.
This build type corresponds to what we do in Dockerfile, i.e.,
a `--release` build without `--features testing`.

The advantage of doing it this way is that we can re-use the
steps from the fine-grained & richer build-neon workflow job.

The disadvantage is that we duplicate the build arguments from the
Dockerfile.

The alternative is to do it the other way around, i.e.,
from the Dockerfile, invoke `cargo test` and `./run_clippy.sh`.

However, that would duplicate all the CARGO_FLAGS and CARGO_FEATURES
logic that we have in the build-neon workflow job.
Which seems worse to me.
This commit is contained in:
Christian Schwarz
2023-04-25 16:36:56 +02:00
parent dbbe032c39
commit 031a3040d3

View File

@@ -139,7 +139,7 @@ jobs:
strategy:
fail-fast: false
matrix:
build_type: [ debug, release ]
build_type: [ debug, release, image ]
env:
BUILD_TYPE: ${{ matrix.build_type }}
GIT_VERSION: ${{ github.sha }}
@@ -181,18 +181,38 @@ jobs:
# corresponding Cargo.toml files for their descriptions.
- name: Set env variables
run: |
CARGO_FEATURES="--features testing"
if [[ $BUILD_TYPE == "debug" ]]; then
cov_prefix="scripts/coverage --profraw-prefix=$GITHUB_JOB --dir=/tmp/coverage run"
CARGO_FLAGS="--locked"
elif [[ $BUILD_TYPE == "release" ]]; then
cov_prefix=""
CARGO_FLAGS="--locked --release"
fi
case "$BUILD_TYPE" in
debug)
cov_prefix="scripts/coverage --profraw-prefix=$GITHUB_JOB --dir=/tmp/coverage run"
CARGO_FEATURES="--features testing"
CARGO_FLAGS="--locked"
TARGET_DIR_NAME="debug"
;;
release)
cov_prefix=""
CARGO_FEATURES="--features testing"
CARGO_FLAGS="--locked --release"
TARGET_DIR_NAME="release"
;;
image)
# Like we do in the Dockerfile built by the neon-image stage.
# The Dockerfile doesn't do cargo test & clippy, though.
# That's why we have it here.
cov_prefix=""
CARGO_FEATURES=""
CARGO_FLAGS="--locked --release"
TARGET_DIR_NAME="release"
;;
*)
echo "Unknown BUILD_TYPE: $BUILD_TYPE"
exit 1
;;
esac
echo "cov_prefix=${cov_prefix}" >> $GITHUB_ENV
echo "CARGO_FEATURES=${CARGO_FEATURES}" >> $GITHUB_ENV
echo "CARGO_FLAGS=${CARGO_FLAGS}" >> $GITHUB_ENV
echo "CARGO_HOME=${GITHUB_WORKSPACE}/.cargo" >> $GITHUB_ENV
echo "TARGET_DIR_NAME=${TARGET_DIR_NAME}" >> $GITHUB_ENV
# Disabled for now
# Don't include the ~/.cargo/registry/src directory. It contains just
@@ -262,7 +282,7 @@ jobs:
jq -r '.packages[].targets[] | select(.kind | index("bin")) | .name'
)
for bin in $binaries; do
SRC=target/$BUILD_TYPE/$bin
SRC=target/$TARGET_DIR_NAME/$bin
DST=/tmp/neon/bin/$bin
cp "$SRC" "$DST"
done
@@ -291,6 +311,11 @@ jobs:
for bin in $binaries; do
echo "/tmp/neon/bin/$bin" >> /tmp/coverage/binaries.list
done
else
if [ "$cov_prefix" != "" ]; then
echo "expecting coverage prefix to be empty for all build types except debug, got BUILD_TYPE=$BUILD_TYPE"
exit 1
fi
fi
- name: Install postgres binaries