Compare commits

...

9 Commits

Author SHA1 Message Date
Ken Matsui
366311c196
Avoid using well-known ports for demoMain (#1761) 2023-08-28 19:31:17 +08:00
Ken Matsui
5df9b48998
main -> master in C++ CI 2023-08-28 02:59:39 -07:00
Ken Matsui
8d4c17702a
Use ninja to build faster (#1755) 2023-08-28 17:59:14 +08:00
dependabot[bot]
9337571e1a
Bump actions/checkout from 2 to 3 (#1760)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-28 02:58:11 -07:00
frank10gm
816684e15d
Replace sprintf with snprintf (#1758)
Co-authored-by: francesco.laplaca <francesco.laplaca@enhancers.it>
Co-authored-by: Ken Matsui <26405363+ken-matsui@users.noreply.github.com>
2023-08-28 17:18:12 +08:00
Ken Matsui
40aa034595
Add dependabot.yml for GH actions (#1756) 2023-08-28 17:17:08 +08:00
Ken Matsui
de4c811772
Set concurrency for CodeQL (#1759) 2023-08-28 02:12:34 -07:00
Ken Matsui
3ecb8b4917
Split macOS and Ubuntu CIs for readability (#1754) 2023-08-28 17:07:52 +08:00
Ken Matsui
f761c54aa8
Extract format action into distinct job (#1751) 2023-08-28 13:50:22 +08:00
7 changed files with 183 additions and 124 deletions

11
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"

View File

@ -1,4 +1,4 @@
name: Build Drogon
name: Build & Test
on:
push:
@ -21,10 +21,10 @@ jobs:
strategy:
fail-fast: false
matrix:
link: [ 'STATIC', 'SHARED' ]
link: ["STATIC", "SHARED"]
steps:
- name: Checkout Drogon source code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
@ -64,97 +64,35 @@ jobs:
shell: bash
run: ./test.sh -w
unix:
name: ${{ matrix.buildname }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
buildname: 'ubuntu-22.04/gcc'
link: SHARED
triplet: x64-linux
compiler: gcc_64
- os: ubuntu-22.04
buildname: 'ubuntu-22.04/gcc'
link: STATIC
triplet: x64-linux
compiler: gcc_64
- os: ubuntu-22.04
buildname: 'ubuntu-22.04/gcc-10'
link: STATIC
triplet: x64-linux
- os: macos-latest
buildname: 'macos/clang'
link: STATIC
triplet: x64-osx
compiler: clang_64
macos:
name: macos/clang
runs-on: macos-latest
steps:
- name: Checkout Drogon source code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: (macOS) Install dependencies
if: runner.os == 'macOS'
- name: Install dependencies
# Already installed: brotli, zlib, postgresql@14, lz4, sqlite3
run: brew install jsoncpp mariadb hiredis redis
- name: (Linux) Install dependencies
if: runner.os == 'Linux'
run: |
# Installing packages might fail as the github image becomes outdated
sudo apt update
# These aren't available or don't work well in vcpkg
sudo apt-get install -y libjsoncpp-dev uuid-dev libssl-dev zlib1g-dev libsqlite3-dev
sudo apt-get install -y libbrotli-dev
- name: (Linux) Install gcc-10
if: matrix.buildname == 'ubuntu-22.04/gcc-10'
run: sudo apt-get install -y gcc-10 g++-10
- name: (Linux) Install postgresql
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get --purge remove postgresql postgresql-doc postgresql-common postgresql-client-common
sudo apt-get -y install postgresql-all
- name: Export `shared`
run: |
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
echo "shared=$shared" >> $GITHUB_ENV
run: brew install ninja jsoncpp mariadb hiredis redis
- name: Create Build Environment & Configure Cmake
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
if: matrix.buildname != 'ubuntu-22.04/gcc-10'
run: |
cmake -B build \
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_TESTING=on \
-DBUILD_SHARED_LIBS=$shared
- name: Create Build Environment & Configure Cmake (gcc-10)
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
if: matrix.buildname == 'ubuntu-22.04/gcc-10'
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_TESTING=on \
-DCMAKE_CXX_FLAGS="-fcoroutines" \
-DBUILD_SHARED_LIBS=$shared
env:
CC: gcc-10
CXX: g++-10
-DBUILD_SHARED_LIBS=OFF
- name: Build
working-directory: ./build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: make -j $(nproc) && sudo make install
run: ninja && sudo ninja install
- name: (macOS) Prepare for testing
if: runner.os == 'macOS'
- name: Prepare for testing
run: |
brew tap homebrew/services
brew services restart postgresql@14
@ -168,8 +106,75 @@ jobs:
sleep 4
psql -c 'create user postgres superuser;' postgres
- name: (Linux) Prepare for testing
if: runner.os == 'Linux'
- name: Test
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./test.sh -t
ubuntu:
name: ${{ matrix.buildname }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- buildname: "ubuntu-22.04/gcc"
link: SHARED
- buildname: "ubuntu-22.04/gcc"
link: STATIC
- buildname: "ubuntu-22.04/coroutines"
link: STATIC
steps:
- name: Checkout Drogon source code
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Install dependencies
run: |
# Installing packages might fail as the github image becomes outdated
sudo apt update
# These aren't available or don't work well in vcpkg
sudo apt-get install -y libjsoncpp-dev uuid-dev libssl-dev zlib1g-dev libsqlite3-dev
sudo apt-get install -y ninja-build libbrotli-dev
- name: Install postgresql
run: |
sudo apt-get --purge remove postgresql postgresql-doc postgresql-common postgresql-client-common
sudo apt-get -y install postgresql-all
- name: Export `shared`
run: |
[[ ${{ matrix.link }} == "SHARED" ]] && shared="ON" || shared="OFF"
echo "shared=$shared" >> $GITHUB_ENV
- name: Create Build Environment & Configure Cmake
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
if: matrix.buildname != 'ubuntu-22.04/coroutines'
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_TESTING=on \
-DBUILD_SHARED_LIBS=$shared
- name: Create Build Environment & Configure Cmake (coroutines)
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
if: matrix.buildname == 'ubuntu-22.04/coroutines'
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_TESTING=on \
-DCMAKE_CXX_FLAGS="-fcoroutines" \
-DBUILD_SHARED_LIBS=$shared
- name: Build
working-directory: ./build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: ninja && sudo ninja install
- name: Prepare for testing
run: |
sudo systemctl start postgresql
sleep 1
@ -179,9 +184,3 @@ jobs:
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ./test.sh -t
- name: Lint
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt install -y dos2unix
./format.sh && git diff --exit-code

View File

@ -9,6 +9,10 @@ on:
schedule:
- cron: '46 7 * * 5'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
@ -36,7 +40,7 @@ jobs:
steps:
- name: Checkout Drogon source code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
@ -45,11 +49,11 @@ jobs:
run: |
sudo apt update
sudo apt-get install -y libjsoncpp-dev uuid-dev libssl-dev zlib1g-dev libsqlite3-dev
sudo apt-get install -y libbrotli-dev
sudo apt-get install -y ninja-build libbrotli-dev
- name: Create Build Environment & Configure Cmake
run: |
cmake -B build \
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_TESTING=on \
-DBUILD_SHARED_LIBS=$SHARED
@ -68,7 +72,7 @@ jobs:
- name: Build
working-directory: ./build
run: make -j $(nproc) && sudo make install
run: ninja && sudo ninja install
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

21
.github/workflows/cpp.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: C++
on:
push:
branches: [master]
pull_request:
permissions:
contents: read
jobs:
format:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install dos2unix
run: sudo apt-get install -y dos2unix
- name: Check formatting
run: ./format.sh && git diff --exit-code

View File

@ -1,7 +1,7 @@
#include <drogon/drogon.h>
int main() {
//Set HTTP listener address and port
drogon::app().addListener("0.0.0.0",80);
drogon::app().addListener("0.0.0.0", 5555);
//Load config file
//drogon::app().loadConfigFile("../config.json");
//drogon::app().loadConfigFile("../config.yaml");

View File

@ -508,7 +508,7 @@ if(@@.get<std::string>("rdbms")=="postgresql")
if(@@.get<std::string>("rdbms")=="postgresql")
{
%>
n = sprintf(placeholderStr,"$%d,",placeholder++);
n = snprintf(placeholderStr,sizeof(placeholderStr),"$%d,",placeholder++);
sql.append(placeholderStr, n);
<%c++
}else

View File

@ -352,43 +352,67 @@ class Users
size_t n = 0;
if (dirtyFlag_[0])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[1])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[2])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[3])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[4])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[5])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
sql += "default,";
if (dirtyFlag_[7])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
if (dirtyFlag_[8])
{
n = sprintf(placeholderStr, "$%d,", placeholder++);
n = snprintf(placeholderStr,
sizeof(placeholderStr),
"$%d,",
placeholder++);
sql.append(placeholderStr, n);
}
else