Skip to content

Commit

Permalink
Testare postgres pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Duta-Sebastian committed Dec 20, 2024
1 parent d601de8 commit c5c264e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
27 changes: 13 additions & 14 deletions .github/actions/configure-PostgreSQL/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@ runs:
shell: bash
if: runner.os == 'Linux'
run: |
sudo service postgresql start
- name: Start MacOS PostgreSQL service
shell: bash
if: runner.os == 'macOS'
run: |
brew install postgresql
brew services start postgresql
sudo pg_ctl -D /usr/local/var/postgres start
brew install postgresql && \
brew services start postgresql@14 && \
sleep 3 && \
psql postgres -c "CREATE USER oop WITH PASSWORD 'ooppa55'; ALTER USER oop CREATEDB;" && \
psql postgres -c "CREATE DATABASE oop_db WITH OWNER oop;"
- name: Start Windows PostgreSQL service
shell: bash
shell: powershell
if: runner.os == 'windows'
run: |
$serviceName = 'postgresql-x64-14'
Set-Service -Name $serviceName -StartupType Manual
net start postgresql-x64-14
- name: Initialize database
shell: bash
run: |
PGPASSWORD=$POSTGRES_PASSWORD psql -h $POSTGRES_HOST -U $POSTGRES_USER -c "CREATE DATABASE oop;"
env:
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: root
Start-Process "C:\Program Files\PostgreSQL\14\bin\psql.exe" -ArgumentList "-h localhost", "-U postgres", "-W root", "-c CREATE USER oop WITH PASSWORD 'ooppa55';"
Start-Process "C:\Program Files\PostgreSQL\14\bin\psql.exe" -ArgumentList "-h localhost", "-U postgres", "-W root", "-c ALTER USER oop CREATEDB;"
Start-Process "C:\Program Files\PostgreSQL\14\bin\psql.exe" -ArgumentList "-h localhost", "-U postgres", "-W root", "-c CREATE DATABASE oop_db WITH OWNER oop;"
12 changes: 2 additions & 10 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ jobs:
name: "MSan: Ubuntu 22.04 Clang 18"
cmake_flags: "-DUSE_MSAN=ON"
cmake_generator: Ninja
# This env runs memory sanitizers
runs_msan: true
# This env is supposed to run memory sanitizers,
# but they are incompatible with pqxx

- os: ubuntu-22.04
c: gcc-12
Expand Down Expand Up @@ -220,15 +221,6 @@ jobs:
- name: Runtime checks
uses: ./.github/actions/runtime-checks

- name: Connect to PostgreSQL and list tables
run: |
PGPASSWORD=$POSTGRES_PASSWORD psql -h $POSTGRES_HOST -U $POSTGRES_USER -d $POSTGRES_DB -c "\dt"
env:
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: root
POSTGRES_DB: oop

- name: Create release
uses: ./.github/actions/create-release
if: startsWith(github.ref, 'refs/tags/')
5 changes: 4 additions & 1 deletion cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ endif()
# custom compiler flags
message("Compiler: ${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION}")
if(MSVC)
target_compile_options(pqxx PRIVATE /W4 /permissive- /wd4244 /wd4267 /wd4996 /external:anglebrackets /external:W0 /utf-8 /MP)
target_compile_options(${MAIN_EXECUTABLE_NAME} PRIVATE /W4 /permissive- /wd4244 /wd4267 /wd4996 /external:anglebrackets /external:W0 /utf-8 /MP)
else()
target_compile_options(${MAIN_EXECUTABLE_NAME} PRIVATE -Wall -Wextra -pedantic)
target_compile_options(pqxx PRIVATE -Wall -Wextra -pedantic -Wno-pre-c++2b-compat)
target_compile_options(${MAIN_EXECUTABLE_NAME} PRIVATE -Wall -Wextra -pedantic -Wno-pre-c++2b-compat)
endif()

###############################################################################
Expand All @@ -25,3 +27,4 @@ endif()
include(cmake/CustomStdlibAndSanitizers.cmake)

set_custom_stdlib_and_sanitizers(${MAIN_EXECUTABLE_NAME} true)
set_custom_stdlib_and_sanitizers(pqxx true)
2 changes: 1 addition & 1 deletion cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ set(is_debug "$<CONFIG:Debug>")
set(is_rel_with_deb "$<CONFIG:RelWithDebInfo>")
set(debug_mode "$<OR:${is_debug},${is_rel_with_deb}>")
# disable pqxx build tests
set(SKIP_BUILD_TEST ON CACHE BOOL "Disable pqxx build tests")
set(SKIP_BUILD_TEST ON CACHE BOOL "Disable pqxx build tests")
2 changes: 1 addition & 1 deletion database/Database.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Database.h"

Database::Database(const bool& with_create_tables, const bool& with_delete_tables) {
connString = "Host=localhost;Username=postgres;Password=root;Database=oop";
connString = "Host=localhost;Username=oop;Password=ooppa55;Database=oop";
connection = std::make_unique<pqxx::connection>(connString);
if (!connection->is_open())
throw std::runtime_error("Database exists but a connection couldn't be established");
Expand Down

0 comments on commit c5c264e

Please sign in to comment.