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
7 changes: 6 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
permissions:
contents: read

env:
CMAKE_INSTALL_MESSAGE: NEVER
CMAKE_LOG_LEVEL: WARNING
MAKEFLAGS: --silent

jobs:
lint:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -40,7 +45,7 @@ jobs:
if: steps.python-tools-cache.outputs.cache-hit != 'true'
run: |
python -m venv .ci-tools
.ci-tools/bin/python -m pip install "clang-format==22.1.8" "poetry==2.4.1"
.ci-tools/bin/python -m pip install --quiet --disable-pip-version-check "clang-format==22.1.8" "poetry==2.4.1"
- name: Add Python tools to PATH
run: echo "$GITHUB_WORKSPACE/.ci-tools/bin" >> "$GITHUB_PATH"
- name: Lint
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
permissions:
contents: read

env:
CMAKE_INSTALL_MESSAGE: NEVER
CMAKE_LOG_LEVEL: WARNING
MAKEFLAGS: --silent

jobs:
test-linux:
runs-on: ubuntu-24.04
Expand All @@ -23,6 +28,10 @@ jobs:
with:
context: .
file: Dockerfile
build-args: |
CMAKE_INSTALL_MESSAGE=NEVER
CMAKE_LOG_LEVEL=WARNING
MAKEFLAGS=--silent
load: true
tags: reo7sp/tgbot-cpp
cache-from: type=gha,scope=runtime
Expand All @@ -32,6 +41,10 @@ jobs:
with:
context: .
file: Dockerfile_test
build-args: |
CMAKE_INSTALL_MESSAGE=NEVER
CMAKE_LOG_LEVEL=WARNING
MAKEFLAGS=--silent
load: true
tags: reo7sp/tgbot-cpp-test
cache-from: type=gha,scope=test
Expand All @@ -45,6 +58,7 @@ jobs:
runs-on: windows-2022
timeout-minutes: 30
env:
CMAKE_BUILD_ARGS: -- --quiet
POETRY_VIRTUALENVS_IN_PROJECT: "true"
steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -76,7 +90,7 @@ jobs:
shell: pwsh
run: |
python -m venv .ci-tools
.ci-tools/Scripts/python -m pip install "clang-format==22.1.8" "conan==2.31.1" "poetry==2.4.1"
.ci-tools/Scripts/python -m pip install --quiet --disable-pip-version-check "clang-format==22.1.8" "conan==2.31.1" "poetry==2.4.1"
- name: Add Python tools to PATH
shell: pwsh
run: Resolve-Path .ci-tools/Scripts | Out-File -FilePath $env:GITHUB_PATH -Append
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
FROM debian:trixie AS dependencies

RUN apt-get -qq update && \
apt-get -qq install -y \
DEBIAN_FRONTEND=noninteractive apt-get -qq install -y \
build-essential \
cmake \
libboost-dev \
libcurl4-openssl-dev \
nlohmann-json3-dev && \
nlohmann-json3-dev >/dev/null && \
rm -rf /var/lib/apt/lists/*


FROM dependencies AS builder

ARG MAKEFLAGS
ARG CMAKE_INSTALL_MESSAGE
ARG CMAKE_LOG_LEVEL

WORKDIR /usr/src/tgbot-cpp

COPY include include
Expand Down
10 changes: 7 additions & 3 deletions Dockerfile_test
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
FROM ubuntu:24.04
LABEL org.opencontainers.image.authors="Oleg Morozenkov <m@oleg.rocks>"

ARG MAKEFLAGS
ARG CMAKE_INSTALL_MESSAGE
ARG CMAKE_LOG_LEVEL

RUN apt-get -qq update && \
apt-get -qq install -y \
DEBIAN_FRONTEND=noninteractive apt-get -qq install -y \
build-essential \
cmake \
python3 \
python3-pip \
python3-venv && \
python3-venv >/dev/null && \
rm -rf /var/lib/apt/lists/*

ENV CONAN_BUILD_ARGS="--build=missing:gtest/*"

RUN python3 -m venv /opt/conan && \
/opt/conan/bin/pip install --no-cache-dir \
/opt/conan/bin/pip install --quiet --disable-pip-version-check --no-cache-dir \
"clang-format==22.1.8" \
"conan==2.31.1" \
"poetry==2.4.1"
Expand Down
43 changes: 29 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ BUILD_TYPE ?= Release
BUILD_DIR ?= build/$(BUILD_TYPE)
NPROC ?= $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
CONAN_BUILD_ARGS ?= --build=missing
CONAN_VERBOSITY ?= quiet
CONAN_RECIPE_VERSION ?= $(shell git describe --tags --abbrev=0 --match 'v*' 2>/dev/null | sed 's/^v//')
CONAN_RECIPE_ARGS ?=
CMAKE_LOG_LEVEL ?= STATUS
CMAKE_INSTALL_MESSAGE ?= ALWAYS
CMAKE_BUILD_ARGS ?=
POETRY_INSTALL_ARGS ?= --no-interaction --quiet
INSTALL_PREFIX ?=
CPP_FILES = $(shell find include src tests examples -type f \( -name '*.h' -o -name '*.cpp' \) ! -name '*.inc.h' | sort)
API_METHODS_CPP = src/ApiMethods.cpp
API_METHODS_INC = include/tgbot/ApiMethods.inc.h
API_METHODS_CLANG_FORMAT_CONFIG = api_codegen/clang-format-api-methods.yaml
CPP_FILES = $(shell find include src tests examples -type f \( -name '*.h' -o -name '*.cpp' \) ! -name '*.inc.h' ! -path '$(API_METHODS_CPP)' | sort)
PYTHON_FILES = conanfile.py api_codegen
DOCKER_IMAGE ?= reo7sp/tgbot-cpp
DOCKER_TEST_IMAGE ?= reo7sp/tgbot-cpp-test
Expand Down Expand Up @@ -71,44 +79,47 @@ endif
all: build

dependencies:
conan profile detect --exist-ok
conan install . $(CONAN_BUILD_ARGS) -s build_type=$(BUILD_TYPE) -s compiler.cppstd=20
conan profile detect --exist-ok -v$(CONAN_VERBOSITY)
conan install . $(CONAN_BUILD_ARGS) -v$(CONAN_VERBOSITY) -s build_type=$(BUILD_TYPE) -s compiler.cppstd=20

dependencies-python:
poetry install --no-interaction
poetry install $(POETRY_INSTALL_ARGS)

dependencies-with-test: dependencies-python
conan profile detect --exist-ok
conan install . $(CONAN_BUILD_ARGS) -s build_type=$(BUILD_TYPE) -s compiler.cppstd=20 -o '&:with_tests=True'
conan profile detect --exist-ok -v$(CONAN_VERBOSITY)
conan install . $(CONAN_BUILD_ARGS) -v$(CONAN_VERBOSITY) -s build_type=$(BUILD_TYPE) -s compiler.cppstd=20 -o '&:with_tests=True'

configure: dependencies
cmake -S . -B $(BUILD_DIR) \
cmake --log-level=$(CMAKE_LOG_LEVEL) -S . -B $(BUILD_DIR) \
-DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR)/generators/conan_toolchain.cmake) \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_INSTALL_MESSAGE=$(CMAKE_INSTALL_MESSAGE) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_TESTS=OFF

configure-with-system:
cmake -S . -B $(BUILD_DIR) \
cmake --log-level=$(CMAKE_LOG_LEVEL) -S . -B $(BUILD_DIR) \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_INSTALL_MESSAGE=$(CMAKE_INSTALL_MESSAGE) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_TESTS=OFF

configure-with-test: dependencies-with-test
cmake -S . -B $(BUILD_DIR) \
cmake --log-level=$(CMAKE_LOG_LEVEL) -S . -B $(BUILD_DIR) \
-DCMAKE_TOOLCHAIN_FILE=$(abspath $(BUILD_DIR)/generators/conan_toolchain.cmake) \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_INSTALL_MESSAGE=$(CMAKE_INSTALL_MESSAGE) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_TESTS=ON

build: configure
cmake --build $(BUILD_DIR) --parallel $(NPROC)
cmake --build $(BUILD_DIR) --parallel $(NPROC) $(CMAKE_BUILD_ARGS)

build-with-system: configure-with-system
cmake --build $(BUILD_DIR) --parallel $(NPROC)
cmake --build $(BUILD_DIR) --parallel $(NPROC) $(CMAKE_BUILD_ARGS)

build-with-test: configure-with-test
cmake --build $(BUILD_DIR) --parallel $(NPROC)
cmake --build $(BUILD_DIR) --parallel $(NPROC) $(CMAKE_BUILD_ARGS)

compile-commands: configure-with-test
cmake -E copy_if_different $(BUILD_DIR)/compile_commands.json compile_commands.json
Expand Down Expand Up @@ -156,6 +167,8 @@ format: format-cpp format-python

format-cpp:
clang-format -i $(CPP_FILES)
clang-format -i --style='file:$(API_METHODS_CLANG_FORMAT_CONFIG)' $(API_METHODS_CPP)
sh api_codegen/format-api-methods-inc.sh --write $(API_METHODS_INC) $(API_METHODS_CLANG_FORMAT_CONFIG)

format-python:
poetry run ruff check --fix $(PYTHON_FILES)
Expand All @@ -165,6 +178,8 @@ lint: lint-cpp lint-python

lint-cpp:
clang-format --dry-run --Werror $(CPP_FILES)
clang-format --dry-run --Werror --style='file:$(API_METHODS_CLANG_FORMAT_CONFIG)' $(API_METHODS_CPP)
sh api_codegen/format-api-methods-inc.sh --check $(API_METHODS_INC) $(API_METHODS_CLANG_FORMAT_CONFIG)

lint-python:
poetry run ruff check $(PYTHON_FILES)
Expand All @@ -184,10 +199,10 @@ docker-test: docker-test-image
$(MAKE) docker-test-api-codegen

docker-test-only:
docker run --rm -t --platform=$(DOCKER_PLATFORM) $(DOCKER_TEST_IMAGE) make test-only
docker run --rm -t --platform=$(DOCKER_PLATFORM) -e MAKEFLAGS $(DOCKER_TEST_IMAGE) make test-only

docker-test-api-codegen:
docker run --rm -t --platform=$(DOCKER_PLATFORM) $(DOCKER_TEST_IMAGE) make test-api-codegen
docker run --rm -t --platform=$(DOCKER_PLATFORM) -e MAKEFLAGS $(DOCKER_TEST_IMAGE) make test-api-codegen

docker-push:
@set -eu; \
Expand Down
Loading
Loading