# Checks that do not fit into any of the per-platform workflows, i.e. the unity build and code formatting. These all run on a stock
|
# x86_64 Linux runner.
|
name: misc
|
|
on: workflow_call
|
|
# Limit permissions on the repository
|
permissions:
|
contents: read
|
|
jobs:
|
# Run meson builds to check for errors, unused functions, unused parameters, and externed functions
|
lint:
|
runs-on: ubuntu-24.04
|
|
steps:
|
- name: Checkout Code
|
uses: actions/checkout@v6
|
with:
|
path: pgbackrest
|
|
- name: Update Apt
|
uses: ./pgbackrest/.github/action/apt
|
|
- name: Install
|
run: |
|
DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive sudo apt-get install -y zlib1g-dev libssl-dev \
|
libxml2-dev libpq-dev pkg-config meson liblz4-dev libzstd-dev libbz2-dev libssh2-1-dev
|
|
- name: Build
|
run: |
|
meson setup --unity=on -Dwerror=true build ${GITHUB_WORKSPACE?}/pgbackrest
|
ninja -vC build
|
|
# Check that a unity build leaves main as the only symbol. FN_EXTERN and friends are defined as static for the unity
|
# build, so any other symbol is a function or variable that escaped that treatment. The object is checked rather than the
|
# linked binary because the binary also has whatever the C runtime, the static libbacktrace archive, and the copy
|
# relocations for shared library variables put there, none of which is what is being tested and all of which vary by
|
# architecture and distribution.
|
- name: Check
|
run: |
|
diff - <(nm -gj --defined-only build/src/pgbackrest.p/*.o) <<'EOF'
|
main
|
EOF
|
|
# Check for unused parameters. The FUNCTION_LOG_PARAM*() macros reference each parameter they log, which counts as a use and
|
# hides parameters the function never touches, so append overrides to debug.h that compile the macros out. Nothing is lost
|
# by that here since this build is never run. Asserts are compiled out of a release build as well, so a parameter that
|
# only an assert reads is reported too and must be marked with a void cast to show that ignoring it is intended. Unused
|
# function warnings are disabled because the *ToLog() functions have nothing left to call them once the macros are gone.
|
- name: Check Unused Parameter
|
run: |
|
cat >> ${GITHUB_WORKSPACE?}/pgbackrest/src/common/debug.h <<'EOF'
|
|
#undef FUNCTION_LOG_PARAM
|
#define FUNCTION_LOG_PARAM(typeMacroPrefix, param)
|
|
#undef FUNCTION_LOG_PARAM_P
|
#define FUNCTION_LOG_PARAM_P(typeMacroPrefix, param)
|
|
#undef FUNCTION_LOG_PARAM_PP
|
#define FUNCTION_LOG_PARAM_PP(typeMacroPrefix, param)
|
EOF
|
|
meson setup --unity=on -Dwerror=true -Dc_args=-Wno-unused-function build-unused-param \
|
${GITHUB_WORKSPACE?}/pgbackrest
|
ninja -vC build-unused-param
|
|
# Check that code is correctly formatted
|
code-format:
|
runs-on: ubuntu-24.04
|
|
steps:
|
- name: Checkout Code
|
uses: actions/checkout@v6
|
with:
|
path: pgbackrest
|
|
- name: Update Apt
|
uses: ./pgbackrest/.github/action/apt
|
|
# The formatters and the PyYAML the harness needs to load. Nothing else is required since the check only reads the source.
|
- name: Install
|
run: |
|
DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive sudo apt-get install -y uncrustify black \
|
python3-yaml
|
|
# On failure the check says how to fix what it found so it can be run locally
|
- name: Check
|
run: ${GITHUB_WORKSPACE?}/pgbackrest/test/test.py code-format --check
|