Skip to content

Commit

Permalink
Add check CI workflow and format sources (#14)
Browse files Browse the repository at this point in the history
* Add check CI workflow

* Fix license-eye configuration and some license headers

* Install cppcheck from repo

* Revert "Install cppcheck from repo"

This reverts commit 806b108.

* Format sources
  • Loading branch information
artemgavrilov authored Aug 12, 2024
1 parent 5d45d4a commit e6a88a0
Show file tree
Hide file tree
Showing 9 changed files with 991 additions and 844 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Checks
on:
pull_request:

jobs:
cppcheck:
name: Cppcheck
runs-on: ubuntu-22.04

steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
path: src/percona_pg_telemetry

- name: Checkout cppcheck sources
uses: actions/checkout@v4
with:
repository: "danmar/cppcheck"
ref: "2.13.4"
path: src/cppcheck

- name: Build and install cppcheck
working-directory: src/cppcheck
run: |
mkdir build
cd build
cmake ..
cmake --build .
sudo cmake --install .
- name: Execute linter check with cppcheck
working-directory: src/percona_pg_telemetry
run: |
set -x
cppcheck --enable=all --inline-suppr --template='{file}:{line},{severity},{id},{message}' --error-exitcode=1 --suppress=missingIncludeSystem --suppress=missingInclude --suppress=unmatchedSuppression:percona_pg_telemetry.c --check-config .
format:
name: Format
runs-on: ubuntu-22.04

steps:
- name: Clone postgres repository
uses: actions/checkout@v4
with:
repository: 'postgres/postgres'
ref: 'REL_17_STABLE'

- name: Checkout sources
uses: actions/checkout@v4
with:
path: 'contrib/percona_pg_telemetry'

- name: Configure postgres
run: ./configure

- name: Install perltidy
run: sudo cpan -T SHANCOCK/Perl-Tidy-20230309.tar.gz

- name: Install pg_bsd_indent
working-directory: src/tools/pg_bsd_indent
run: sudo make install

- name: Add pg_bsd_indent and pgindent to path
run: |
echo "/usr/local/pgsql/bin" >> $GITHUB_PATH
echo "${{ github.workspace }}/src/tools/pgindent" >> $GITHUB_PATH
- name: Format sources
working-directory: contrib/percona_pg_telemetry
run: |
make update-typedefs
make indent
- name: Check files are formatted and no source code changes
working-directory: contrib/percona_pg_telemetry
run: |
git status
git diff --exit-code
license:
name: License
runs-on: ubuntu-22.04

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Check license headers
uses: apache/skywalking-eyes/[email protected]
with:
token: "" # Prevent comments
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
## .vscode
.vscode/
.vscode/*

# tools files
typedefs-full.list
13 changes: 13 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
header:
paths:
- "**/*.c"
- "**/*.h"
license:
pattern: |
.*\.(c|h)
.*
IDENTIFICATION
contrib/percona_pg_telemetry/.*\.(c|h)
comment: never
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

# Fetches typedefs list for PostgreSQL core and merges it with typedefs defined in this project.
# https://wiki.postgresql.org/wiki/Running_pgindent_on_non-core_code_or_development_code
update-typedefs:
wget -q -O - "https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?branch=REL_17_STABLE" | cat - typedefs.list | sort | uniq > typedefs-full.list

# Indents projects sources.
indent:
pgindent --typedefs=typedefs-full.list .

.PHONY: update-typedefs indent
Loading

0 comments on commit e6a88a0

Please sign in to comment.