Skip to content

Commit 27d5d9f

Browse files
authored
Use our docker test infrastructure on GitHub Actions. (#937)
* Use our docker test infrastructure on GitHub Actions. This simplifies the maintenance of our test infra, allowing to run the same tests on the local development environment and in the automated CI. Because citus_indent depends on a local git checkout to be able to run correctly, we still need a special target for this test, and we still need to manually install citusdata/tools in the test VM directly. * Tests run in docker do not need an interactive environment. * Fix running "linting" and "tablespaces" tests. * Install missing linting tools (Python black). * Improve ci testing integration, use more of the Makefile.
1 parent dbd7ea1 commit 27d5d9f

2 files changed

Lines changed: 54 additions & 35 deletions

File tree

.github/workflows/build-package.yml

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ jobs:
3434
include:
3535
- PGVERSION: 14
3636
TEST: tablespaces
37-
DOCKERTEST: true
3837
- PGVERSION: 14
3938
TEST: linting
40-
LINTING: true
4139
steps:
4240
- name: Checkout repository
4341
uses: actions/checkout@v2
@@ -46,44 +44,21 @@ jobs:
4644
run: |
4745
echo "PGVERSION=${{ matrix.PGVERSION }}" >> $GITHUB_ENV
4846
echo "TEST=${{ matrix.TEST }}" >> $GITHUB_ENV
49-
echo "DOCKERTEST=${{ matrix.DOCKERTEST }}" >> $GITHUB_ENV
5047
echo "LINTING=${{ matrix.LINTING }}" >> $GITHUB_ENV
5148
echo "TRAVIS_BUILD_DIR=$(pwd)" >> $GITHUB_ENV
5249
53-
- name: Clone and install tools branch
50+
- name: Clone and install linting tools
5451
run: |
52+
sudo apt-get install python3-pip
53+
pip3 install --user black
54+
black --version
5555
gcc --version
5656
git clone -b v0.8.19 --depth 1 https://github.com/citusdata/tools.git ../tools
5757
sudo make -C ../tools install
58+
install_uncrustify
59+
rm -rf uncrustify*
5860
59-
- name: Pre Install steps
60-
run: |
61-
if [ -z "${LINTING}" ]; then setup_apt; fi
62-
if [ -z "${LINTING}" ]; then nuke_pg; fi
63-
python --version
64-
python3 --version
65-
sudo apt-get install liblz4-1 liblz4-dev bridge-utils python3-pip python3-nose python3-psycopg2 libxslt1-dev libzstd-dev
66-
sudo apt-get install libkrb5-dev python3-setuptools
67-
sudo -H pip3 install pyroute2>=0.5.17
68-
pip3 install --user black
69-
70-
- name: Install steps
71-
run: |
72-
if [ -n "${LINTING}" ]; then install_uncrustify; fi
73-
if [ -n "${LINTING}" ]; then rm -rf uncrustify*; fi
74-
if [ -z "${LINTING}" ]; then install_pg; fi
75-
if [ -z "${LINTING}" ]; then install_custom_pg; fi
76-
env
77-
if [ -z "${LINTING}" ]; then pg_config; fi
78-
if [ -z "${LINTING}" ]; then PATH=`pg_config --bindir`:$PATH which pg_ctl; fi
79-
80-
- name: Script steps
61+
- name: Run Test
8162
timeout-minutes: 15
8263
run: |
83-
echo "Travis build dir: ${TRAVIS_BUILD_DIR}"
84-
if [ -n "${LINTING}" ]; then citus_indent --check; fi
85-
if [ -n "${LINTING}" ]; then black --check .; fi
86-
if [ -n "${LINTING}" ]; then ci/banned.h.sh; fi
87-
if [ -z "${LINTING}" ]; then make -j5 CFLAGS=-Werror; fi
88-
if [ -z "${LINTING}" ]; then sudo make install; fi
89-
if [ -z "${LINTING}" ]; then PATH=`pg_config --bindir`:$PATH make test; fi
64+
make ci-test

Makefile

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TOP := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
66
CONTAINER_NAME = pg_auto_failover
77
BUILD_CONTAINER_NAME = pg_auto_failover_build
88
TEST_CONTAINER_NAME = pg_auto_failover_test
9-
DOCKER_RUN_OPTS = --privileged -ti --rm
9+
DOCKER_RUN_OPTS = --privileged --rm
1010

1111
PGVERSION ?= 10
1212
NOSETESTS = $(shell which nosetests3 || which nosetests)
@@ -132,10 +132,31 @@ clean-bin:
132132
install-bin: bin
133133
$(MAKE) -C src/bin/ install
134134

135+
#
136+
# make ci-test; is run on the GitHub Action workflow
137+
#
138+
# In that environment we have a local git checkout of the code, and docker
139+
# is available too. We run our tests in docker, except for the code linting
140+
# parts which requires full access to the git repository, so linter tooling
141+
# is installed directly on the CI vm.
142+
#
143+
ci-test:
144+
ifeq ($(TEST),tablespaces)
145+
$(MAKE) -C tests/tablespaces run-test
146+
else ifeq ($(TEST),linting)
147+
$(MAKE) spellcheck
148+
else
149+
$(MAKE) run-test
150+
endif
135151

152+
#
153+
# make test; is run from inside the testing Docker image.
154+
#
136155
test:
137156
ifeq ($(TEST),tablespaces)
138157
$(MAKE) -C tests/tablespaces run-test
158+
else ifeq ($(TEST),linting)
159+
$(MAKE) spellcheck
139160
else
140161
sudo -E env "PATH=${PATH}" USER=$(shell whoami) \
141162
$(NOSETESTS) \
@@ -146,10 +167,29 @@ else
146167
${TEST_ARGUMENT}
147168
endif
148169

170+
#
171+
# make indent; edits the code when necessary
172+
#
149173
indent:
150174
citus_indent
151175
black .
152176

177+
#
178+
# make lint; is an alias for make spellcheck
179+
# make linting; is an alias for make spellcheck
180+
#
181+
lint: spellcheck ;
182+
linting: spellcheck ;
183+
184+
#
185+
# make spellcheck; runs our linting tools without editing the code, only
186+
# reports compliance with the rules.
187+
#
188+
spellcheck:
189+
citus_indent --check
190+
black --check .
191+
ci/banned.h.sh
192+
153193
docs: $(FSM)
154194
$(MAKE) -C docs html
155195

@@ -177,6 +217,10 @@ build-test-pg14:
177217
build-test-pg15:
178218
docker build --build-arg PGVERSION=15 --target test -t $(TEST_CONTAINER_NAME):pg15 .
179219

220+
#
221+
# make run-test; is the main testing entry point used to run tests inside
222+
# our testing Docker container. The docker container depends on PGVERSION.
223+
#
180224
run-test: build-test-pg$(PGVERSION)
181225
docker run \
182226
--name $(TEST_CONTAINER_NAME) \
@@ -330,7 +374,7 @@ azdrop: all
330374
.PHONY: all clean check install docs
331375
.PHONY: monitor clean-monitor check-monitor install-monitor
332376
.PHONY: bin clean-bin install-bin
333-
.PHONY: build-test run-test
377+
.PHONY: build-test run-test spellcheck lint linting
334378
.PHONY: tmux-clean cluster compose
335379
.PHONY: azcluster azdrop az
336380
.PHONY: build-image

0 commit comments

Comments
 (0)