From 506cb40325cc69b4f6975b28a13bea038d37116d Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Wed, 26 Mar 2025 17:58:53 +0300 Subject: [PATCH 01/20] create service --- .github/workflows/create-service.yml | 105 +++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 .github/workflows/create-service.yml diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml new file mode 100644 index 000000000000..0e5e9d1d304f --- /dev/null +++ b/.github/workflows/create-service.yml @@ -0,0 +1,105 @@ +name: Ubuntu + +'on': + pull_request: + push: + branches: + - master + - develop + - feature/** + +env: + UBSAN_OPTIONS: print_stacktrace=1 + ASAN_OPTIONS: detect_odr_violation=2 + CCACHE_DIR: /home/runner/.cache/ccache + CCACHE_NOHASHDIR: true + CPM_SOURCE_CACHE: /home/runner/.cache/CPM + +jobs: + posix: + strategy: + fail-fast: false + matrix: + include: + - cmake-flags: >- + -GNinja + -DCMAKE_CXX_COMPILER=clang++-18 + -DCMAKE_C_COMPILER=clang-18 + -DCMAKE_BUILD_TYPE=Debug + -DUSERVER_SANITIZE="ub addr" + -DUSERVER_NO_WERROR=0 + -DUSERVER_INSTALL=1 + -DUSERVER_FEATURE_CORE=1 + -DUSERVER_FEATURE_CHAOTIC=1 + -DUSERVER_FEATURE_POSTGRESQL=1 + -DUSERVER_FEATURE_MONGODB=1 + -DUSERVER_FEATURE_GRPC=1 + os: ubuntu-24.04 + info: clang-18 + debug + id: ubuntu24_clang18_debug + tests-flags: '' + tests-env: '' + + name: '${{matrix.os}}: ${{matrix.info}}' + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v4 + + - name: Restore cached directories + id: restore-cache + uses: actions/cache/restore@v4 + with: + path: | + ${{env.CCACHE_DIR}} + ${{env.CPM_SOURCE_CACHE}} + key: 'ubuntu-cache-dir ${{matrix.id}} ${{github.ref}} run-${{github.run_number}}' + restore-keys: | + ubuntu-cache-dir ${{matrix.id}} ${{github.ref}} + ubuntu-cache-dir ${{matrix.id}} + + - name: Setup ramdrive for testsuites + run: | + sudo mkdir -p "/mnt/ramdisk/$USER" + sudo chmod 777 "/mnt/ramdisk/$USER" + sudo mount -t tmpfs -o size=2048M tmpfs "/mnt/ramdisk/$USER" + + - name: Free disk space + run: | + df -h + # See https://stackoverflow.com/questions/75536771/github-runner-out-of-disk-space-after-building-docker-image + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /usr/lib/php* /opt/ghc \ + /usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \ + /opt/hostedtoolcache/CodeQL || true + sudo docker image prune --all --force + df -h + + - name: Install common deps + run: | + sudo apt update + sudo apt purge -y libpq5 libpq-dev postgresql-* + sudo apt install --allow-downgrades -y clickhouse-common-static redis-server postgresql $(cat scripts/docs/en/deps/${{matrix.os}}.md | tr '\n' ' ') + + - name: Setup ccache + run: | + ccache -M 2.0GB + ccache -s -v + + - name: Install gdb and pytest + run: | + sudo apt install -y gdb python3-pytest + + - name: Run cmake + run: | + cmake -S . -B build_debug ${{matrix.cmake-flags}} + + - name: Compile + run: | + pwd + cd build_debug + cmake --build . -j $(nproc) + + - name: Create service + run: | + cd build_debug/scripts/gdb/tests + ctest -V From 62b89ba7c5b64c304cddea5482eeea20238e6092 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Wed, 26 Mar 2025 18:00:41 +0300 Subject: [PATCH 02/20] w --- .github/workflows/create-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 0e5e9d1d304f..f45a62b94315 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -40,7 +40,7 @@ jobs: tests-flags: '' tests-env: '' - name: '${{matrix.os}}: ${{matrix.info}}' + name: 'Create service test' runs-on: ${{matrix.os}} steps: From c85f5f43276f9bb9bdc64a84386b4f39c6a3cbf3 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Wed, 26 Mar 2025 18:02:18 +0300 Subject: [PATCH 03/20] w --- .github/workflows/create-service.yml | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index f45a62b94315..5d4717cd22a2 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -1,4 +1,4 @@ -name: Ubuntu +name: Create service test 'on': pull_request: @@ -14,15 +14,7 @@ env: CCACHE_DIR: /home/runner/.cache/ccache CCACHE_NOHASHDIR: true CPM_SOURCE_CACHE: /home/runner/.cache/CPM - -jobs: - posix: - strategy: - fail-fast: false - matrix: - include: - - cmake-flags: >- - -GNinja + CMAKE_FLAGS: -GNinja -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_C_COMPILER=clang-18 -DCMAKE_BUILD_TYPE=Debug @@ -34,14 +26,12 @@ jobs: -DUSERVER_FEATURE_POSTGRESQL=1 -DUSERVER_FEATURE_MONGODB=1 -DUSERVER_FEATURE_GRPC=1 - os: ubuntu-24.04 - info: clang-18 + debug - id: ubuntu24_clang18_debug - tests-flags: '' - tests-env: '' +jobs: + posix: + strategy: + fail-fast: false - name: 'Create service test' - runs-on: ${{matrix.os}} + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 From 17454cf98330eb2aac9bfe0b0511c442bd902366 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Wed, 26 Mar 2025 19:04:23 +0300 Subject: [PATCH 04/20] -clickhouse --- .github/workflows/create-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 5d4717cd22a2..5519ce0e0aee 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -68,7 +68,7 @@ jobs: run: | sudo apt update sudo apt purge -y libpq5 libpq-dev postgresql-* - sudo apt install --allow-downgrades -y clickhouse-common-static redis-server postgresql $(cat scripts/docs/en/deps/${{matrix.os}}.md | tr '\n' ' ') + sudo apt install --allow-downgrades -y redis-server postgresql $(cat scripts/docs/en/deps/${{matrix.os}}.md | tr '\n' ' ') - name: Setup ccache run: | From b04d08c16a72f2bcf10720f29d2b56787f7d266f Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Wed, 26 Mar 2025 19:28:29 +0300 Subject: [PATCH 05/20] ccache --- .github/workflows/create-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 5519ce0e0aee..ee9e52eec217 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -68,7 +68,7 @@ jobs: run: | sudo apt update sudo apt purge -y libpq5 libpq-dev postgresql-* - sudo apt install --allow-downgrades -y redis-server postgresql $(cat scripts/docs/en/deps/${{matrix.os}}.md | tr '\n' ' ') + sudo apt install --allow-downgrades -y ccache redis-server postgresql $(cat scripts/docs/en/deps/${{matrix.os}}.md | tr '\n' ' ') - name: Setup ccache run: | From afaca060bfb5a87199cc5a170d3b0ec22f9c36ca Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 10:28:38 +0300 Subject: [PATCH 06/20] fix --- .github/workflows/create-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index ee9e52eec217..f1721c15f79b 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -68,7 +68,7 @@ jobs: run: | sudo apt update sudo apt purge -y libpq5 libpq-dev postgresql-* - sudo apt install --allow-downgrades -y ccache redis-server postgresql $(cat scripts/docs/en/deps/${{matrix.os}}.md | tr '\n' ' ') + sudo apt install --allow-downgrades -y ccache redis-server postgresql $(cat scripts/docs/en/deps/ubuntu-22.04.md | tr '\n' ' ') - name: Setup ccache run: | From 39aef8f6bca2d6febce6b91509164da42452fa06 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 10:31:41 +0300 Subject: [PATCH 07/20] 24.04 --- .github/workflows/create-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index f1721c15f79b..352b1433a527 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -68,7 +68,7 @@ jobs: run: | sudo apt update sudo apt purge -y libpq5 libpq-dev postgresql-* - sudo apt install --allow-downgrades -y ccache redis-server postgresql $(cat scripts/docs/en/deps/ubuntu-22.04.md | tr '\n' ' ') + sudo apt install --allow-downgrades -y ccache redis-server postgresql $(cat scripts/docs/en/deps/ubuntu-24.04.md | tr '\n' ' ') - name: Setup ccache run: | From 403f2be9e7c6c4160969eb6b48ffe48c9f996557 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 11:56:38 +0300 Subject: [PATCH 08/20] service --- .github/workflows/create-service.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 352b1433a527..65df36284394 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -81,7 +81,7 @@ jobs: - name: Run cmake run: | - cmake -S . -B build_debug ${{matrix.cmake-flags}} + cmake -S . -B build_debug ${{env.CMAKE_FLAGS}} - name: Compile run: | @@ -89,7 +89,14 @@ jobs: cd build_debug cmake --build . -j $(nproc) - - name: Create service + - name: Install run: | - cd build_debug/scripts/gdb/tests - ctest -V + cmake --install -B build_debug + + - name: Create service + userver-create-service myservice + + - name: Build & test service + cd myservice + make build-debug + make testsuite-debug From 612ed9304df92dc4a23b8979e1a45d0d031a5aed Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 12:08:58 +0300 Subject: [PATCH 09/20] fix --- .github/workflows/create-service.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 65df36284394..fbda46a0d10b 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -94,9 +94,11 @@ jobs: cmake --install -B build_debug - name: Create service + run: | userver-create-service myservice - name: Build & test service + run: | cd myservice make build-debug make testsuite-debug From 4cda268a05b99d9e0706e8e5c59c6eb1bf46b067 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 13:01:30 +0300 Subject: [PATCH 10/20] iinstall --- .github/workflows/create-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index fbda46a0d10b..552ee5e54dca 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -91,7 +91,7 @@ jobs: - name: Install run: | - cmake --install -B build_debug + cmake --install build_debug - name: Create service run: | From 350c494a8d1870565777347f0c903a81ad008bbc Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 13:19:20 +0300 Subject: [PATCH 11/20] sudo --- .github/workflows/create-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 552ee5e54dca..c261bad8638a 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -91,7 +91,7 @@ jobs: - name: Install run: | - cmake --install build_debug + sudo cmake --install build_debug - name: Create service run: | From afd1c06edde25a574263320f8cab33c6067fe813 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 13:55:34 +0300 Subject: [PATCH 12/20] services --- .github/workflows/create-service.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index c261bad8638a..09fd69b5b0d9 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -93,12 +93,32 @@ jobs: run: | sudo cmake --install build_debug - - name: Create service + - name: Service (empty) run: | userver-create-service myservice + cd myservice + make build-debug + make test-debug + cd .. + rm -rf myservice - - name: Build & test service + - name: Service (mongo) run: | - cd myservice + userver-create-service --mongo myservice-mongo + cd myservice-mongo + make build-debug + make test-debug + + - name: Service (grpc) + run: | + userver-create-service --grpc myservice-grpc + cd myservice-grpc + make build-debug + make test-debug + + - name: Service (postgresql) + run: | + userver-create-service --postgresql myservice-pg + cd myservice-pg make build-debug - make testsuite-debug + make test-debug From 96eb66555ea43ca6e98bb048677331a731c0c773 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 15:02:40 +0300 Subject: [PATCH 13/20] release --- .github/workflows/create-service.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 09fd69b5b0d9..5e0a08240f1e 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -17,7 +17,7 @@ env: CMAKE_FLAGS: -GNinja -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_C_COMPILER=clang-18 - -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_BUILD_TYPE=Release -DUSERVER_SANITIZE="ub addr" -DUSERVER_NO_WERROR=0 -DUSERVER_INSTALL=1 @@ -81,24 +81,24 @@ jobs: - name: Run cmake run: | - cmake -S . -B build_debug ${{env.CMAKE_FLAGS}} + cmake -S . -B build_release ${{env.CMAKE_FLAGS}} - name: Compile run: | pwd - cd build_debug + cd build_release cmake --build . -j $(nproc) - name: Install run: | - sudo cmake --install build_debug + sudo cmake --install build_release - name: Service (empty) run: | userver-create-service myservice cd myservice - make build-debug - make test-debug + make build-release + make test-release cd .. rm -rf myservice @@ -106,19 +106,19 @@ jobs: run: | userver-create-service --mongo myservice-mongo cd myservice-mongo - make build-debug - make test-debug + make build-release + make test-release - name: Service (grpc) run: | userver-create-service --grpc myservice-grpc cd myservice-grpc - make build-debug - make test-debug + make build-release + make test-release - name: Service (postgresql) run: | userver-create-service --postgresql myservice-pg cd myservice-pg - make build-debug - make test-debug + make build-release + make test-release From 172e87803c96b9149f558985ee2cf302170f20ae Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 15:50:52 +0300 Subject: [PATCH 14/20] {} --- service_template/src/greeting.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/service_template/src/greeting.cpp b/service_template/src/greeting.cpp index 2b8b5ebc6bc4..04d932d86577 100644 --- a/service_template/src/greeting.cpp +++ b/service_template/src/greeting.cpp @@ -19,6 +19,7 @@ std::string SayHelloTo(std::string_view name, UserType type) { } UASSERT(false); + return {}; } } // namespace service_template From 4ca120a4934f9d91b61bd649f2badbe8787847a3 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 16:23:19 +0300 Subject: [PATCH 15/20] pycodestyle --- .github/workflows/create-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 5e0a08240f1e..de9edf37a385 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -77,7 +77,7 @@ jobs: - name: Install gdb and pytest run: | - sudo apt install -y gdb python3-pytest + sudo apt install -y gdb python3-pytest pycodestyle - name: Run cmake run: | From 37e58715f9c3bc5c7814201badd08a728fe79ce2 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 17:35:37 +0300 Subject: [PATCH 16/20] ruff --- .github/workflows/create-service.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index de9edf37a385..7ceac0d7a3a9 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -78,6 +78,7 @@ jobs: - name: Install gdb and pytest run: | sudo apt install -y gdb python3-pytest pycodestyle + pip install ruff - name: Run cmake run: | From 998645df38b8b6087b36895ba9c73cfe3ac83dc2 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 18:04:32 +0300 Subject: [PATCH 17/20] w --- .github/workflows/create-service.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 7ceac0d7a3a9..a2606694f3ec 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -103,12 +103,12 @@ jobs: cd .. rm -rf myservice - - name: Service (mongo) - run: | - userver-create-service --mongo myservice-mongo - cd myservice-mongo - make build-release - make test-release + # - name: Service (mongo) + # run: | + # userver-create-service --mongo myservice-mongo + # cd myservice-mongo + # make build-release + # make test-release - name: Service (grpc) run: | From 2001d9cfb9605fe7a122bb2279a13cb41084f7a6 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 19:07:50 +0300 Subject: [PATCH 18/20] grpc --- .github/workflows/create-service.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index a2606694f3ec..031dff02eaef 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -110,12 +110,12 @@ jobs: # make build-release # make test-release - - name: Service (grpc) - run: | - userver-create-service --grpc myservice-grpc - cd myservice-grpc - make build-release - make test-release + # - name: Service (grpc) + # run: | + # userver-create-service --grpc myservice-grpc + # cd myservice-grpc + # make build-release + # make test-release - name: Service (postgresql) run: | From 5f70d28e605229ea751e403f945edb569a5a3d42 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 19:51:11 +0300 Subject: [PATCH 19/20] pg --- .github/workflows/create-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-service.yml b/.github/workflows/create-service.yml index 031dff02eaef..e4e5b8886465 100644 --- a/.github/workflows/create-service.yml +++ b/.github/workflows/create-service.yml @@ -119,7 +119,7 @@ jobs: - name: Service (postgresql) run: | - userver-create-service --postgresql myservice-pg + userver-create-service --postgres myservice-pg cd myservice-pg make build-release make test-release From 59052185e7e8c13af941783b7ebdc2c34a920e95 Mon Sep 17 00:00:00 2001 From: Vasily Kulikov Date: Thu, 27 Mar 2025 21:38:38 +0300 Subject: [PATCH 20/20] ruff --- service_template/tests/test_postgres.py | 36 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/service_template/tests/test_postgres.py b/service_template/tests/test_postgres.py index 9c9c5540cf32..94470452ee3b 100644 --- a/service_template/tests/test_postgres.py +++ b/service_template/tests/test_postgres.py @@ -7,33 +7,45 @@ async def test_basic(service_client): - response = await service_client.post('/hello-postgres', params={'name': 'Tester'}) + response = await service_client.post( + "/hello-postgres", + params={"name": "Tester"}, + ) assert response.status == 200 - assert response.text == 'Hello, Tester!\n' + assert response.text == "Hello, Tester!\n" async def test_db_updates(service_client): - response = await service_client.post('/hello-postgres', params={'name': 'World'}) + response = await service_client.post( + "/hello-postgres", + params={"name": "World"}, + ) assert response.status == 200 - assert response.text == 'Hello, World!\n' + assert response.text == "Hello, World!\n" - response = await service_client.post('/hello-postgres', params={'name': 'World'}) + response = await service_client.post( + "/hello-postgres", + params={"name": "World"}, + ) assert response.status == 200 - assert response.text == 'Hi again, World!\n' + assert response.text == "Hi again, World!\n" - response = await service_client.post('/hello-postgres', params={'name': 'World'}) + response = await service_client.post( + "/hello-postgres", + params={"name": "World"}, + ) assert response.status == 200 - assert response.text == 'Hi again, World!\n' + assert response.text == "Hi again, World!\n" -@pytest.mark.pgsql('db_1', files=['initial_data.sql']) +@pytest.mark.pgsql("db_1", files=["initial_data.sql"]) async def test_db_initial_data(service_client): response = await service_client.post( - '/hello-postgres', - params={'name': 'user-from-initial_data.sql'}, + "/hello-postgres", + params={"name": "user-from-initial_data.sql"}, ) assert response.status == 200 - assert response.text == 'Hi again, user-from-initial_data.sql!\n' + assert response.text == "Hi again, user-from-initial_data.sql!\n" # postgres template on