Skip to content

Commit

Permalink
CI improvements for static check
Browse files Browse the repository at this point in the history
 * Make static check a separate CI workflow
 * Rename "build" workflow to "check"
 * Use verbose mode for cppcheck
 * Fix the errors cppcheck reports in the verbose mode
  • Loading branch information
homper authored and akorotkov committed Jul 17, 2024
1 parent e2310ae commit 25e0323
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 60 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/antithesis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout extension code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
pg_version: [13, 14, 15]
steps:
- name: Checkout extension code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get the required tag name
shell: bash
Expand Down Expand Up @@ -168,4 +168,3 @@ jobs:
- name: fault-tolerance-test testgres
run: |
curl -X POST https://orioledb.antithesis.com/api/v1/launch_experiment/${{ env.ENDPOINT }}${{ matrix.pg_version }}-latest -u '${{ secrets.ANTITHESIS_API_USER }}'
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ jobs:
COMPILER: ${{ github.event.inputs.compiler }}
steps:
- name: Checkout extension code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: orioledb
- name: Get the required tag name
shell: bash
run: |
echo "PGTAG=$(grep '^${{ github.event.inputs.pg_version }}: ' orioledb/.pgtags | cut -d' ' -f2-)" >> $GITHUB_ENV
- name: Checkout PostgreSQL code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: orioledb/postgres
ref: ${{ env.PGTAG }}
Expand Down
47 changes: 7 additions & 40 deletions .github/workflows/build.yml → .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
name: build
name: check

on:
push:
pull_request:

jobs:
test:
check:
runs-on:
- ubuntu-22.04
- ubuntu-22.04
strategy:
fail-fast: false
matrix:
pg_version: [15, 16]
compiler: [clang, gcc]
check_type: [normal, debug, alignment, check_page, valgrind_1, valgrind_2]
check_type:
[normal, debug, alignment, check_page, valgrind_1, valgrind_2]
env:
LLVM_VER: 12
CPU: ${{ matrix.cpu }}
CHECK_TYPE: ${{ matrix.check_type }}
COMPILER: ${{ matrix.compiler }}
steps:
- name: Checkout extension code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: orioledb
- name: Get the required tag name
shell: bash
run: |
echo "PGTAG=$(grep '^${{ matrix.pg_version }}: ' orioledb/.pgtags | cut -d' ' -f2-)" >> $GITHUB_ENV
- name: Checkout PostgreSQL code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: orioledb/postgres
ref: ${{ env.PGTAG }}
Expand All @@ -51,37 +52,3 @@ jobs:
run: bash ./orioledb/ci/codecov.sh
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
static:
runs-on:
- ubuntu-20.04
strategy:
fail-fast: false
matrix:
pg_version: [15, 16]
compiler: [clang, gcc]
env:
LLVM_VER: 12
CPU: ${{ matrix.cpu }}
CHECK_TYPE: static
COMPILER: ${{ matrix.compiler }}
steps:
- name: Checkout extension code into workspace directory
uses: actions/checkout@v3
with:
path: orioledb
- name: Get the required tag name
shell: bash
run: |
echo "PGTAG=$(grep '^${{ matrix.pg_version }}: ' orioledb/.pgtags | cut -d' ' -f2-)" >> $GITHUB_ENV
- name: Checkout PostgreSQL code into workspace directory
uses: actions/checkout@v3
with:
repository: orioledb/postgres
ref: ${{ env.PGTAG }}
path: postgresql
- name: Setup prerequisites
run: bash ./orioledb/ci/prerequisites.sh
- name: Build
run: bash ./orioledb/ci/build.sh
- name: Static analysis
run: bash ./orioledb/ci/static.sh
3 changes: 1 addition & 2 deletions .github/workflows/dockertest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
postgres: [16, 15]
compiler: [clang]
distr: [alpine, ubuntu]
distr: [alpine, ubuntu]
include:
- distr-version: 3.19
distr: alpine
Expand All @@ -27,7 +27,6 @@ jobs:
continue-on-error: ${{ matrix.alpine == 'edge' }}

steps:

- name: Checkout source
uses: actions/checkout@v4

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pgindent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
pgindent:
runs-on:
- ubuntu-20.04
- ubuntu-20.04
strategy:
fail-fast: false
matrix:
Expand All @@ -19,15 +19,15 @@ jobs:
COMPILER: gcc
steps:
- name: Checkout extension code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: orioledb
- name: Get the required tag name
shell: bash
run: |
echo "PGTAG=$(grep '^${{ matrix.pg_version }}: ' orioledb/.pgtags | cut -d' ' -f2-)" >> $GITHUB_ENV
- name: Checkout PostgreSQL code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: orioledb/postgres
ref: ${{ env.PGTAG }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ jobs:
openssl-devel systemd-devel llvm-toolset-7-clang \
llvm5.0-devel gcc gcc-c++ libzstd-devel lz4-devel
- name: Checkout PGRPMs into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: orioledb/pgrpms
ref: orioledb
- name: Checkout extension code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: orioledb
- name: Get the required tag name
shell: bash
run: |
echo "PGTAG=$(grep '^${{ github.event.inputs.version }}: ' orioledb/.pgtags | cut -d' ' -f2-)" >> $GITHUB_ENV
- name: Checkout PostgreSQL code into workspace directory
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: orioledb/postgres
ref: ${{ env.PGTAG }}
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: static

on:
push:
pull_request:

jobs:
static:
runs-on:
- ubuntu-22.04
strategy:
fail-fast: false
matrix:
pg_version: [15, 16]
compiler: [clang, gcc]
env:
LLVM_VER: 12
CPU: ${{ matrix.cpu }}
CHECK_TYPE: static
COMPILER: ${{ matrix.compiler }}
steps:
- name: Checkout extension code into workspace directory
uses: actions/checkout@v4
with:
path: orioledb
- name: Get the required tag name
shell: bash
run: |
echo "PGTAG=$(grep '^${{ matrix.pg_version }}: ' orioledb/.pgtags | cut -d' ' -f2-)" >> $GITHUB_ENV
- name: Checkout PostgreSQL code into workspace directory
uses: actions/checkout@v4
with:
repository: orioledb/postgres
ref: ${{ env.PGTAG }}
path: postgresql
- name: Setup prerequisites
run: bash ./orioledb/ci/prerequisites.sh
- name: Build
run: bash ./orioledb/ci/build.sh
- name: Static analysis
run: bash ./orioledb/ci/static.sh
4 changes: 2 additions & 2 deletions ci/static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ if [ "$COMPILER" = "clang" ]; then
make USE_PGXS=1 USE_ASSERT_CHECKING=1 || status=$?

elif [ "$COMPILER" = "gcc" ]; then
cppcheck --template "{file} ({line}): {severity} ({id}): {message}" \
cppcheck \
--enable=warning,portability,performance \
--suppress=redundantAssignment \
--suppress=uselessAssignmentPtrArg \
--suppress=incorrectStringBooleanError \
--suppress=nullPointerRedundantCheck \
--std=c89 src/*.c src/*/*.c include/*.h include/*/*.h 2> cppcheck.log
--std=c89 --inline-suppr --verbose src/*.c src/*/*.c include/*.h include/*/*.h 2> cppcheck.log

if [ -s cppcheck.log ]; then
cat cppcheck.log
Expand Down
2 changes: 1 addition & 1 deletion src/btree/undo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ get_prev_leaf_header_and_tuple_from_undo(BTreeLeafTuphdr *tuphdr,
OTuple *tuple,
LocationIndex sizeAvailable)
{
BTreeModifyUndoStackItem item;
BTreeModifyUndoStackItem item = {0};
LocationIndex tupleSize;
UndoLocation undoLocation = tuphdr->undoLocation;

Expand Down
4 changes: 2 additions & 2 deletions src/catalog/indices.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ build_secondary_index(OTable *o_table, OTableDescr *descr, OIndexNumber ix_num,

/* Infrastructure for parallel build corresponds to _bt_spools_heapscan */
oIdxSpool *btspool = NULL;
oIdxBuildState buildstate;
oIdxBuildState buildstate = {0};
SortCoordinate coordinate = NULL;
uint64 ctid;
double heap_tuples;
Expand Down Expand Up @@ -1699,7 +1699,7 @@ rebuild_indices(OTable *old_o_table, OTableDescr *old_descr,
double *index_tuples;
uint64 ctid;
CheckpointFileHeader *fileHeaders;
oIdxBuildState buildstate;
oIdxBuildState buildstate = {0};
oIdxSpool *btspool = NULL;
SortCoordinate *coordinate = NULL;
S3TaskLocation maxLocation = 0,
Expand Down
6 changes: 5 additions & 1 deletion src/s3/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ s3_backup_scan_dir(S3BackupState *state, const char *path,
char pathbuf[MAXPGPATH * 2];
struct stat statbuf;
int64 size = 0;
const char *lastDir; /* Split last dir from parent path. */
const char *lastDir = NULL; /* Split last dir from parent path. */
bool isDbDir = false; /* Does this directory contain relations? */

/*
Expand All @@ -310,6 +310,7 @@ s3_backup_scan_dir(S3BackupState *state, const char *path,
strspn(lastDir + 1, "0123456789") == strlen(lastDir + 1))
{
/* Part of path that contains the parent directory. */
/* cppcheck-suppress uninitvar */
int parentPathLen = lastDir - path;

/*
Expand Down Expand Up @@ -487,10 +488,13 @@ s3_backup_scan_dir(S3BackupState *state, const char *path,

rllen = readlink(pathbuf, linkpath, sizeof(linkpath));
if (rllen < 0)
{
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not read symbolic link \"%s\": %m",
pathbuf)));
return 0; /* keep cppcheck quiet */
}
if (rllen >= sizeof(linkpath))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
Expand Down
2 changes: 1 addition & 1 deletion src/transam/oxid.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static TransactionId
acquire_logical_xid(void)
{
int i = MyProc->pgprocno,
mynum;
mynum = 0;
int nloops = 0;
TransactionId result;
uint32 divider = max_procs * 32;
Expand Down

0 comments on commit 25e0323

Please sign in to comment.