Skip to content

Commit 8012a52

Browse files
First GitHub action for checking code formatting
1 parent 0c6fd6f commit 8012a52

File tree

3 files changed

+61
-22
lines changed

3 files changed

+61
-22
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Build and Test
2+
on: [push, pull_request]
3+
4+
jobs:
5+
check-format:
6+
name: Check Formatting
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v4
11+
- name: Get UV
12+
uses: astral-sh/setup-uv@v6
13+
with:
14+
version: 0.8.15
15+
- name: Check Formatting
16+
run: make format-check PYTHON_RUN="uv run --group=format"

Makefile

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
# *** Build Parameters ***
2+
# Whether to use PMM for the build process
3+
USE_PMM := TRUE
4+
# Whether to build tests
5+
BUILD_TESTING := TRUE
6+
# Sanitizers to request (Comma-separated list)
7+
SANITIZE :=
8+
# The configurations to build (Semicolon-separated, or "all")
9+
CONFIGS := Debug
10+
# If running tests, the configuration to test
11+
TEST_CONFIG := Debug
12+
# Set the CMAKE_INSTALL_PREFIX and the `--prefix` arg for installs
13+
INSTALL_PREFIX :=
14+
15+
# *** Execution Parameters ***
16+
# Set the LAUNCHER parameter to prefix all executed commands
17+
LAUNCHER :=
18+
19+
# Update the shell to be executed by the launching command. Make will use
20+
# this to execute all commands in the Makefile:
21+
SHELL := $(LAUNCHER) $(SHELL)
22+
123
.SILENT:
224
.PHONY: docs-html docs-serve default build test format format-check packages
325

@@ -12,45 +34,51 @@ THIS_DIR := $(shell dirname $(THIS_FILE))
1234
# Directory where we will scribble build files
1335
BUILD_DIR ?= $(THIS_DIR)/_build/auto
1436

15-
# uv commands used in this file
16-
UV_RUN := uv run
17-
DOCS_RUN := $(UV_RUN) --isolated --group=docs
18-
FORMAT_RUN := $(UV_RUN) --isolated --group=format
19-
# Build is not isolated, because CMake caches paths to certain files
20-
BUILD_RUN := $(UV_RUN) --group=build
37+
PYTHON_RUN :=
2138
# Run CMake within the uv environment
22-
CMAKE_RUN := $(BUILD_RUN) cmake
39+
CMAKE_RUN := cmake
2340

2441
SPHINX_JOBS ?= auto
2542
SPHINX_ARGS := -W -j "$(SPHINX_JOBS)" -aT -b dirhtml
2643

2744
DOCS_SRC := $(THIS_DIR)/docs
2845
DOCS_OUT := $(BUILD_DIR)/docs/dev/html
2946
docs-html:
30-
$(DOCS_RUN) sphinx-build $(SPHINX_ARGS) $(DOCS_SRC) $(DOCS_OUT)
47+
sphinx-build $(SPHINX_ARGS) $(DOCS_SRC) $(DOCS_OUT)
3148

3249
docs-serve:
33-
$(DOCS_RUN) sphinx-autobuild $(SPHINX_ARGS) $(DOCS_SRC) $(DOCS_OUT)
50+
sphinx-autobuild $(SPHINX_ARGS) $(DOCS_SRC) $(DOCS_OUT)
3451

35-
build:
52+
configure:
3653
$(CMAKE_RUN) \
3754
-S "$(THIS_DIR)" \
3855
-B "$(BUILD_DIR)" \
39-
--fresh \
40-
-D CMAKE_CROSS_CONFIGS="Debug" \
56+
-D CMAKE_CROSS_CONFIGS="$(CONFIGS)" \
4157
-D CMAKE_DEFAULT_CONFIGS=all \
58+
-D AMONGOC_USE_PMM=$(USE_PMM) \
59+
-D BUILD_TESTING=$(BUILD_TESTING) \
60+
-D MONGO_SANITIZE="$(SANITIZE)" \
61+
-D CMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX) \
4262
-G "Ninja Multi-Config"
63+
64+
build: configure
65+
$(MAKE) build-fast
66+
67+
build-fast:
4368
$(CMAKE_RUN) --build "$(BUILD_DIR)"
4469

4570
test: build
71+
$(MAKE) test-fast
72+
73+
test-fast:
4674
$(CMAKE_RUN) -E chdir "$(BUILD_DIR)" \
47-
ctest -C Debug -j4 --output-on-failure
75+
ctest -C $(TEST_CONFIG) -j4 --output-on-failure --progress -E CMake/\|URI/spec/
4876

4977
format-check:
50-
$(UV_RUN) --group format tools/format.py --mode=check
78+
$(PYTHON_RUN) tools/format.py --mode=check
5179

5280
format:
53-
$(UV_RUN) --group format tools/format.py
81+
$(PYTHON_RUN) tools/format.py
5482

5583
packages:
5684
bash $(THIS_DIR)/tools/earthly.sh -a +build-multi/ _build/pkgs

pyproject.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@ requires-python = ">=3.11"
1111
package = false
1212

1313
[dependency-groups]
14-
build = [
15-
"cmake~=3.25.0",
16-
"ninja~=1.13.0",
17-
]
14+
build = ["cmake~=3.25.0", "ninja~=1.13.0"]
1815

19-
format = [
20-
"clang-format~=20.1.0"
21-
]
16+
format = ["clang-format~=20.1.0"]
2217

2318
docs = [
2419
"sphinx~=8.0.2",

0 commit comments

Comments
 (0)