Compare commits

...

6 Commits

Author SHA1 Message Date
Christian Schwarz
e4ba83fe3b fixup 2023-04-25 19:15:25 +02:00
Christian Schwarz
865f08012a fixup: undefined VARIANT variable 2023-04-25 19:07:33 +02:00
Christian Schwarz
90b672ec00 fixup 2023-04-25 19:06:16 +02:00
Christian Schwarz
0a251e824a refactor + separate job for clippy
- rename MATRIX_BUILD_TYPE to "variant"
- extract build variables into separate action
- move clippy to separate action, use build vars from the new action
- build-neon: use build vars from the new action
2023-04-25 19:00:17 +02:00
Christian Schwarz
f42aedeedd fix: distinguish build matrix build type from Makefile's BUILD_TYPE
build-neon uses `make postgres-...`.

The Makefile expects BUILD_TYPE to be debug or release.

Before this PR, the build matrix's BUILD_TYPE would be just that.
Now the build matrix's build type is something different than the
Makefile's BUILD_TYPE.

Make the difference explicit.
2023-04-25 17:20:16 +02:00
Christian Schwarz
031a3040d3 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.
2023-04-25 16:43:09 +02:00
2 changed files with 96 additions and 32 deletions

View File

@@ -0,0 +1,51 @@
name: "Set build env vars"
description: "Set various env vars for building neon.git, depending on the build variant"
inputs:
variant:
description: "One of debug, release, or image"
required: true
runs:
using: "composite"
steps:
- name: Determine build vars
shell: bash -euxo pipefail {0}
env:
VARIANT: ${{ inputs.variant }}
run: |
case "$VARIANT" 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"
BUILD_TYPE="debug"
;;
release)
cov_prefix=""
CARGO_FEATURES="--features testing"
CARGO_FLAGS="--locked --release"
TARGET_DIR_NAME="release"
BUILD_TYPE="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"
BUILD_TYPE="release"
;;
*)
echo "Unknown VARIANT: $VARIANT"
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
echo "BUILD_TYPE=${BUILD_TYPE}" >> $GITHUB_ENV
echo "VARIANT=${VARIANT}" >> $GITHUB_ENV

View File

@@ -111,9 +111,6 @@ jobs:
- name: Get postgres headers
run: make postgres-headers -j$(nproc)
- name: Run cargo clippy
run: ./run_clippy.sh
# Use `${{ !cancelled() }}` to run quck tests after the longer clippy run
- name: Check formatting
if: ${{ !cancelled() }}
@@ -131,6 +128,36 @@ jobs:
if: ${{ !cancelled() }}
run: cargo deny check
clippy:
runs-on: [ self-hosted, gen3, large ]
container:
image: 369495373322.dkr.ecr.eu-central-1.amazonaws.com/rust:pinned
options: --init
strategy:
fail-fast: false
matrix:
variant:
- debug
- release
- image
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 1
- uses: ./.github/actions/set-build-env-vars
with:
variant: ${{ matrix.variant }}
- name: Get postgres headers
run: make postgres-headers -j$(nproc)
- name: Run clippy
run: cargo clippy --workspace --all-targets $CARGO_FLAGS $CARGO_FEATURES -- -A unknown_lints -D warnings
build-neon:
runs-on: [ self-hosted, gen3, large ]
container:
@@ -139,9 +166,11 @@ jobs:
strategy:
fail-fast: false
matrix:
build_type: [ debug, release ]
variant:
- debug
- release
- image
env:
BUILD_TYPE: ${{ matrix.build_type }}
GIT_VERSION: ${{ github.sha }}
steps:
@@ -161,6 +190,10 @@ jobs:
submodules: true
fetch-depth: 1
- uses: ./.github/actions/set-build-env-vars
with:
variant: ${{ matrix.variant }}
- name: Set pg 14 revision for caching
id: pg_v14_rev
run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-v14) >> $GITHUB_OUTPUT
@@ -169,31 +202,6 @@ jobs:
id: pg_v15_rev
run: echo pg_rev=$(git rev-parse HEAD:vendor/postgres-v15) >> $GITHUB_OUTPUT
# Set some environment variables used by all the steps.
#
# CARGO_FLAGS is extra options to pass to "cargo build", "cargo test" etc.
# It also includes --features, if any
#
# CARGO_FEATURES is passed to "cargo metadata". It is separate from CARGO_FLAGS,
# because "cargo metadata" doesn't accept --release or --debug options
#
# We run tests with addtional features, that are turned off by default (e.g. in release builds), see
# 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
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
# Disabled for now
# Don't include the ~/.cargo/registry/src directory. It contains just
# uncompressed versions of the crates in ~/.cargo/registry/cache
@@ -262,13 +270,13 @@ 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
# Install test executables and write list of all binaries (for code coverage)
if [[ $BUILD_TYPE == "debug" ]]; then
if [[ $VARIANT == "debug" ]]; then
# Keep bloated coverage data files away from the rest of the artifact
mkdir -p /tmp/coverage/
@@ -291,6 +299,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 variants except 'debug', got VARIANT=$VARIANT"
exit 1
fi
fi
- name: Install postgres binaries