Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 25 additions & 37 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,42 @@ name: Run Tests
on:
push:
branches:
- main
- main
pull_request:
branches:
- main
- main

workflow_dispatch:

jobs:
style_checker:
name: Style check
runs-on: ubuntu-latest
container: citus/stylechecker:no-py
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2

- name: Set safe directory for git
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}

- name: Check C formatting
run: citus_indent --check

- name: Check banned functions
run: ci/banned.h.sh

run_tests:
name: Run test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
PGVERSION:
- 13
- 14
- 15
- 16
- 17
- 18
TEST:
- multi
- single
Expand All @@ -33,46 +48,19 @@ jobs:
include:
- PGVERSION: 14
TEST: tablespaces
- PGVERSION: 14
TEST: linting
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4.2.2

- name: Set environment variables
run: |
echo "PGVERSION=${{ matrix.PGVERSION }}" >> $GITHUB_ENV
echo "TEST=${{ matrix.TEST }}" >> $GITHUB_ENV
echo "LINTING=${{ matrix.LINTING }}" >> $GITHUB_ENV
echo "TRAVIS_BUILD_DIR=$(pwd)" >> $GITHUB_ENV

- name: Clone and install linting tools
if: ${{ env.TEST == 'linting' }}
run: |
sudo apt-get install python3-pip
pip3 install --user black
black --version
gcc --version
# Install uncrustify the Citus way
make -C ci -f tools.mk tools

- name: Check code formatting and banned function
if: ${{ env.TEST == 'linting' }}
run: |
make lint

- name: Build documentation
if: ${{ env.TEST == 'linting' }}
run: |
make build-docs
echo "PGVERSION=${{ matrix.PGVERSION }}" >> $GITHUB_ENV
echo "TEST=${{ matrix.TEST }}" >> $GITHUB_ENV
echo "TRAVIS_BUILD_DIR=$(pwd)" >> $GITHUB_ENV

- name: Build Docker Test Image
if: ${{ env.TEST != 'linting' }}
run: |
make build-test-image
run: make build-test-image

- name: Run Test
if: ${{ env.TEST != 'linting' }}
timeout-minutes: 15
run: |
make ci-test
run: make ci-test
32 changes: 22 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,10 @@ $(VERSION_FILE):
#
# make ci-test; is run on the GitHub Action workflow
#
# In that environment we have a local git checkout of the code, and docker
# is available too. We run our tests in docker, except for the code linting
# parts which requires full access to the git repository, so linter tooling
# is installed directly on the CI vm.
#
.PHONY: ci-test
ci-test:
ifeq ($(TEST),tablespaces)
$(MAKE) -C tests/tablespaces run-test
else ifeq ($(TEST),linting)
$(MAKE) spellcheck
else
$(MAKE) run-test
endif
Expand All @@ -172,8 +165,6 @@ endif
test:
ifeq ($(TEST),tablespaces)
$(MAKE) -C tests/tablespaces run-test
else ifeq ($(TEST),linting)
$(MAKE) spellcheck
else
sudo -E env "PATH=${PATH}" USER=$(shell whoami) \
$(NOSETESTS) \
Expand All @@ -187,12 +178,33 @@ endif
#
# INDENT/LINT/SPELLCHECK
#
# citus_indent is run via its official Docker image (citus/stylechecker:no-py)
# so that the local version exactly matches CI. When the local citus_indent
# binary is already in PATH (e.g. inside the stylechecker container) the plain
# binary is used instead, which is equally authoritative there.
#
# To check or auto-fix locally without installing citus_indent:
# make docker-check # check only
# make docker-indent # auto-fix
CITUS_INDENT_DOCKER = docker run --rm \
-v "$(CURDIR):/workdir" \
-w /workdir \
citus/stylechecker:no-py \
citus_indent

# make indent; edits the code when necessary
.PHONY: indent
indent:
citus_indent
black --exclude=ci/tools .

# make docker-indent / make docker-check — use Docker image locally
.PHONY: docker-indent docker-check
docker-indent:
$(CITUS_INDENT_DOCKER)
docker-check:
$(CITUS_INDENT_DOCKER) --check

# make lint; is an alias for make spellcheck
# make linting; is an alias for make spellcheck
.PHONY: lint linting
Expand All @@ -202,7 +214,7 @@ lint linting: spellcheck ;
# reports compliance with the rules.
.PHONY: spellcheck
spellcheck:
citus_indent --check
$(CITUS_INDENT_DOCKER) --check
black --exclude=ci/tools --check .
ci/banned.h.sh

Expand Down
Loading