Merge branch 'devel' into 4230-data-fixes-improvements

This commit is contained in:
Aleksandar Fabijanic 2023-11-10 12:18:25 +01:00 committed by GitHub
commit bda0cd1a07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 27479 additions and 194 deletions

54
.github/actions/retry-action/action.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Retry Step
description: 'Retry a step on failure or timeout'
inputs:
timeout_minutes:
description: Minutes to wait before attempt times out. Must only specify either minutes or seconds
required: false
timeout_seconds:
description: Seconds to wait before attempt times out. Must only specify either minutes or seconds
required: false
max_attempts:
description: Number of attempts to make before failing the step
required: true
default: 3
command:
description: The command to run
required: true
retry_wait_seconds:
description: Number of seconds to wait before attempting the next retry
required: false
default: 10
shell:
description: Alternate shell to use (defaults to powershell on windows, bash otherwise). Supports bash, python, pwsh, sh, cmd, and powershell
required: false
polling_interval_seconds:
description: Number of seconds to wait for each check that command has completed running
required: false
default: 1
retry_on:
description: Event to retry on. Currently supported [any, timeout, error]
warning_on_retry:
description: Whether to output a warning on retry, or just output to info. Defaults to true
default: true
on_retry_command:
description: Command to run before a retry (such as a cleanup script). Any error thrown from retry command is caught and surfaced as a warning.
required: false
continue_on_error:
description: Exits successfully even if an error occurs. Same as native continue-on-error behavior, but for use in composite actions. Default is false
default: false
new_command_on_retry:
description: Command to run if the first attempt fails. This command will be called on all subsequent attempts.
required: false
retry_on_exit_code:
description: Specific exit code to retry on. This will only retry for the given error code and fail immediately other error codes.
required: false
outputs:
total_attempts:
description: The final number of attempts made
exit_code:
description: The final exit code returned by the command
exit_error:
description: The final error returned by the command
runs:
using: 'node16'
main: 'dist/index.js'

26403
.github/actions/retry-action/dist/index.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,67 @@
{
"name": "retry",
"version": "0.0.0-managed-by-semantic-release",
"description": "Retries a GitHub Action step on failure or timeout.",
"scripts": {
"lint:base": "eslint --config ./.config/.eslintrc.js ",
"lint": "npm run lint:base -- .",
"local": "npm run prepare && node -r dotenv/config ./dist/index.js",
"prepare": "ncc build src/index.ts",
"style:base": "prettier --config ./.config/.prettierrc.yml --ignore-path ./.config/.prettierignore --write ",
"style": "npm run style:base -- .",
"test": "jest -c ./.config/jest.config.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nick-invision/retry.git"
},
"keywords": [],
"author": "Nick Fields",
"license": "ISC",
"bugs": {
"url": "https://github.com/nick-invision/retry/issues"
},
"homepage": "https://github.com/nick-invision/retry#readme",
"dependencies": {
"@actions/core": "^1.10.0",
"milliseconds": "^1.0.3",
"tree-kill": "^1.2.2"
},
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@types/babel-generator": "^6.25.7",
"@types/jest": "^28.1.6",
"@types/milliseconds": "0.0.30",
"@types/node": "^16.11.7",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"@vercel/ncc": "^0.38.1",
"dotenv": "8.2.0",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"husky": "^8.0.1",
"jest": "^28.1.3",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"semantic-release": "19.0.3",
"ts-jest": "^28.0.7",
"ts-node": "9.0.0",
"typescript": "^4.7.4",
"yaml-lint": "^1.7.0"
},
"lint-staged": {
"**/*.ts": [
"npm run style:base --",
"npm run lint:base --"
],
"**/*.{md,yaml,yml}": [
"npm run style:base --"
],
"**/*.{yaml,yml}": [
"npx yamllint "
]
}
}

View File

@ -0,0 +1,191 @@
import { error, warning, info, debug, setOutput } from '@actions/core';
import { execSync, spawn } from 'child_process';
import ms from 'milliseconds';
import { getInputs, getTimeout, Inputs, validateInputs } from './inputs';
import { retryWait, wait } from './util';
const OS = process.platform;
const OUTPUT_TOTAL_ATTEMPTS_KEY = 'total_attempts';
const OUTPUT_EXIT_CODE_KEY = 'exit_code';
const OUTPUT_EXIT_ERROR_KEY = 'exit_error';
let exit: number;
let done: boolean;
function getExecutable(inputs: Inputs): string {
if (!inputs.shell) {
return OS === 'win32' ? 'powershell' : 'bash';
}
let executable: string;
const shellName = inputs.shell.split(' ')[0];
switch (shellName) {
case 'bash':
case 'python':
case 'pwsh': {
executable = inputs.shell;
break;
}
case 'sh': {
if (OS === 'win32') {
throw new Error(`Shell ${shellName} not allowed on OS ${OS}`);
}
executable = inputs.shell;
break;
}
case 'cmd':
case 'powershell': {
if (OS !== 'win32') {
throw new Error(`Shell ${shellName} not allowed on OS ${OS}`);
}
executable = shellName + '.exe' + inputs.shell.replace(shellName, '');
break;
}
default: {
throw new Error(
`Shell ${shellName} not supported. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell for supported shells`
);
}
}
return executable;
}
async function runRetryCmd(inputs: Inputs): Promise<void> {
// if no retry script, just continue
if (!inputs.on_retry_command) {
return;
}
try {
await execSync(inputs.on_retry_command, { stdio: 'inherit' });
// eslint-disable-next-line
} catch (error: any) {
info(`WARNING: Retry command threw the error ${error.message}`);
}
}
async function runCmd(attempt: number, inputs: Inputs) {
const end_time = Date.now() + getTimeout(inputs);
const executable = getExecutable(inputs);
exit = 0;
done = false;
let timeout = false;
debug(`Running command ${inputs.command} on ${OS} using shell ${executable}`);
const child =
attempt > 1 && inputs.new_command_on_retry
? spawn(inputs.new_command_on_retry, { shell: executable })
: spawn(inputs.command, { shell: executable });
child.stdout?.on('data', (data) => {
process.stdout.write(data);
});
child.stderr?.on('data', (data) => {
process.stdout.write(data);
});
child.on('exit', (code, signal) => {
debug(`Code: ${code}`);
debug(`Signal: ${signal}`);
// timeouts are killed manually
if (signal === 'SIGTERM') {
return;
}
// On Windows signal is null.
if (timeout) {
return;
}
if (code && code > 0) {
exit = code;
}
done = true;
});
do {
await wait(ms.seconds(inputs.polling_interval_seconds));
} while (Date.now() < end_time && !done);
if (!done && child.pid) {
timeout = true;
try {
child.kill();
}
catch(e) {
//ignore if process can't be killed
}
await retryWait(ms.seconds(inputs.retry_wait_seconds));
throw new Error(`Timeout of ${getTimeout(inputs)}ms hit`);
} else if (exit > 0) {
await retryWait(ms.seconds(inputs.retry_wait_seconds));
throw new Error(`Child_process exited with error code ${exit}`);
} else {
return;
}
}
async function runAction(inputs: Inputs) {
await validateInputs(inputs);
for (let attempt = 1; attempt <= inputs.max_attempts; attempt++) {
try {
// just keep overwriting attempts output
setOutput(OUTPUT_TOTAL_ATTEMPTS_KEY, attempt);
await runCmd(attempt, inputs);
info(`Command completed after ${attempt} attempt(s).`);
break;
// eslint-disable-next-line
} catch (error: any) {
if (attempt === inputs.max_attempts) {
throw new Error(`Final attempt failed. ${error.message}`);
} else if (!done && inputs.retry_on === 'error') {
// error: timeout
throw error;
} else if (inputs.retry_on_exit_code && inputs.retry_on_exit_code !== exit) {
throw error;
} else if (exit > 0 && inputs.retry_on === 'timeout') {
// error: error
throw error;
} else {
await runRetryCmd(inputs);
if (inputs.warning_on_retry) {
warning(`Attempt ${attempt} failed. Reason: ${error.message}`);
} else {
info(`Attempt ${attempt} failed. Reason: ${error.message}`);
}
}
}
}
}
const inputs = getInputs();
runAction(inputs)
.then(() => {
setOutput(OUTPUT_EXIT_CODE_KEY, 0);
process.exit(0); // success
})
.catch((err) => {
// exact error code if available, otherwise just 1
const exitCode = exit > 0 ? exit : 1;
if (inputs.continue_on_error) {
warning(err.message);
} else {
error(err.message);
}
// these can be helpful to know if continue-on-error is true
setOutput(OUTPUT_EXIT_ERROR_KEY, err.message);
setOutput(OUTPUT_EXIT_CODE_KEY, exitCode);
// if continue_on_error, exit with exact error code else exit gracefully
// mimics native continue-on-error that is not supported in composite actions
process.exit(inputs.continue_on_error ? 0 : exitCode);
});

View File

@ -0,0 +1,94 @@
import { getInput } from '@actions/core';
import ms from 'milliseconds';
export interface Inputs {
timeout_minutes: number | undefined;
timeout_seconds: number | undefined;
max_attempts: number;
command: string;
retry_wait_seconds: number;
shell: string | undefined;
polling_interval_seconds: number;
retry_on: string | undefined;
warning_on_retry: boolean;
on_retry_command: string | undefined;
continue_on_error: boolean;
new_command_on_retry: string | undefined;
retry_on_exit_code: number | undefined;
}
export function getInputNumber(id: string, required: boolean): number | undefined {
const input = getInput(id, { required });
const num = Number.parseInt(input);
// empty is ok
if (!input && !required) {
return;
}
if (!Number.isInteger(num)) {
throw `Input ${id} only accepts numbers. Received ${input}`;
}
return num;
}
export function getInputBoolean(id: string): boolean {
const input = getInput(id);
if (!['true', 'false'].includes(input.toLowerCase())) {
throw `Input ${id} only accepts boolean values. Received ${input}`;
}
return input.toLowerCase() === 'true';
}
export async function validateInputs(inputs: Inputs) {
if (
(!inputs.timeout_minutes && !inputs.timeout_seconds) ||
(inputs.timeout_minutes && inputs.timeout_seconds)
) {
throw new Error('Must specify either timeout_minutes or timeout_seconds inputs');
}
}
export function getTimeout(inputs: Inputs): number {
if (inputs.timeout_minutes) {
return ms.minutes(inputs.timeout_minutes);
} else if (inputs.timeout_seconds) {
return ms.seconds(inputs.timeout_seconds);
}
throw new Error('Must specify either timeout_minutes or timeout_seconds inputs');
}
export function getInputs(): Inputs {
const timeout_minutes = getInputNumber('timeout_minutes', false);
const timeout_seconds = getInputNumber('timeout_seconds', false);
const max_attempts = getInputNumber('max_attempts', true) || 3;
const command = getInput('command', { required: true });
const retry_wait_seconds = getInputNumber('retry_wait_seconds', false) || 10;
const shell = getInput('shell');
const polling_interval_seconds = getInputNumber('polling_interval_seconds', false) || 1;
const retry_on = getInput('retry_on') || 'any';
const warning_on_retry = getInput('warning_on_retry').toLowerCase() === 'true';
const on_retry_command = getInput('on_retry_command');
const continue_on_error = getInputBoolean('continue_on_error');
const new_command_on_retry = getInput('new_command_on_retry');
const retry_on_exit_code = getInputNumber('retry_on_exit_code', false);
return {
timeout_minutes,
timeout_seconds,
max_attempts,
command,
retry_wait_seconds,
shell,
polling_interval_seconds,
retry_on,
warning_on_retry,
on_retry_command,
continue_on_error,
new_command_on_retry,
retry_on_exit_code,
};
}

View File

@ -0,0 +1,12 @@
import { debug } from '@actions/core';
export async function wait(ms: number) {
return new Promise((r) => setTimeout(r, ms));
}
export async function retryWait(retryWaitSeconds: number) {
const waitStart = Date.now();
await wait(retryWaitSeconds);
debug(`Waited ${Date.now() - waitStart}ms`);
debug(`Configured wait: ${retryWaitSeconds}ms`);
}

View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"noEmit": true /* Do not emit outputs. */,
/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
/* Advanced Options */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"exclude": ["**/__tests__", "**/__mocks__"]
}

View File

@ -1,5 +1,11 @@
name: poco-ci
on: [push, pull_request]
# To enable retrying a job on failure or a specific timeout, instead of the run step, use uses: nick-fields/retry@v2.9.0(see the linux-gcc-make-tsan jsob)
# To retry only on timeout set retry_on: timeout
# To retry only on error set retry_on: error
# For more information on the retry action see https://github.com/nick-fields/retry
on:
pull_request:
types: [opened]
push:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
@ -7,24 +13,19 @@ concurrency:
jobs:
linux-gcc-make:
runs-on: ubuntu-22.04
services:
mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_USER: pocotest
MYSQL_PASSWORD: pocotest
MYSQL_DATABASE: pocotest
ports:
- 3306:3306
steps:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev redis-server libmysqlclient-dev
- run: ./configure --everything --omit=PDF && make all -s -j4 && sudo make install
- run: >-
sudo -s
EXCLUDE_TESTS="Data/ODBC Data/PostgreSQL MongoDB"
./ci/runtests.sh
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
EXCLUDE_TESTS="Data/ODBC Data/MySQL Data/PostgreSQL MongoDB"
./ci/runtests.sh
linux-gcc-make-cxx20:
runs-on: ubuntu-22.04
@ -32,31 +33,31 @@ jobs:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev redis-server libmysqlclient-dev
- run: ./configure --config=Linux-c++20 --everything --omit=PDF && make all -s -j4 && sudo make install
- run: >-
sudo -s
EXCLUDE_TESTS="Data/ODBC Data/MySQL Data/PostgreSQL MongoDB"
./ci/runtests.sh
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
EXCLUDE_TESTS="Data/ODBC Data/MySQL Data/PostgreSQL MongoDB"
./ci/runtests.sh
linux-gcc-make-asan:
runs-on: ubuntu-22.04
services:
mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_USER: pocotest
MYSQL_PASSWORD: pocotest
MYSQL_DATABASE: pocotest
ports:
- 3306:3306
steps:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev redis-server
- run: ./configure --everything --no-samples --omit=PDF && make all -s -j4 SANITIZEFLAGS=-fsanitize=address && sudo make install
- run: >-
sudo -s
EXCLUDE_TESTS="Data/ODBC Data/PostgreSQL MongoDB"
./ci/runtests.sh
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
EXCLUDE_TESTS="Data/ODBC Data/PostgreSQL Data/MySQL MongoDB"
./ci/runtests.sh
linux-gcc-make-asan-no-soo:
runs-on: ubuntu-22.04
@ -64,10 +65,15 @@ jobs:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev redis-server
- run: ./configure --everything --no-samples --omit=PDF --no-soo && make all -s -j4 SANITIZEFLAGS=-fsanitize=address && sudo make install
- run: >-
sudo -s
EXCLUDE_TESTS="Data/MySQL Data/ODBC Data/PostgreSQL MongoDB"
./ci/runtests.sh
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
EXCLUDE_TESTS="Data/MySQL Data/ODBC Data/PostgreSQL MongoDB"
./ci/runtests.sh
linux-gcc-make-ubsan:
runs-on: ubuntu-22.04
@ -75,10 +81,15 @@ jobs:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev redis-server
- run: ./configure --everything --no-samples --omit=PDF && make all -s -j4 SANITIZEFLAGS=-fsanitize=undefined && sudo make install
- run: >-
sudo -s
EXCLUDE_TESTS="Data/MySQL Data/ODBC Data/PostgreSQL MongoDB"
./ci/runtests.sh
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
EXCLUDE_TESTS="Data/MySQL Data/ODBC Data/PostgreSQL MongoDB"
./ci/runtests.sh
linux-gcc-make-tsan:
runs-on: ubuntu-22.04
@ -86,9 +97,14 @@ jobs:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev redis-server
- run: ./configure --everything --no-samples --omit=CppParser,Encodings,Data/MySQL,Data/ODBC,Data/PostgreSQL,MongoDB,PageCompiler,PDF,PocoDoc,ProGen,Redis,SevenZip && make all -s -j4 SANITIZEFLAGS=-fsanitize=thread && sudo make install
- run: >-
sudo -s
./ci/runtests.sh TSAN
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
./ci/runtests.sh TSAN
linux-gcc-cmake:
runs-on: ubuntu-22.04
@ -96,11 +112,16 @@ jobs:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install cmake ninja-build libssl-dev unixodbc-dev libmysqlclient-dev redis-server
- run: cmake -H. -Bcmake-build -GNinja -DENABLE_PDF=OFF -DENABLE_TESTS=ON && cmake --build cmake-build --target all
- run: >-
cd cmake-build &&
sudo -s
PWD=`pwd`
ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(PostgreSQL)|(MongoDB)"
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
cd cmake-build &&
sudo -s
PWD=`pwd`
ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(PostgreSQL)|(MongoDB)"
linux-gcc-make-cross-armhf:
runs-on: ubuntu-22.04
@ -109,9 +130,14 @@ jobs:
- run: >-
sudo apt-get -y update &&
sudo apt-get -y install crossbuild-essential-armhf
- run: >-
./configure --config=ARM-Linux --everything --omit=PDF,Crypto,NetSSL_OpenSSL,JWT,Data/MySQL,Data/ODBC,Data/PostgreSQL,PageCompiler,PageCompiler/File2Page &&
make all -s -j4 ARCHFLAGS="-mcpu=cortex-a8 -mfloat-abi=hard -mfpu=neon" TOOL=arm-linux-gnueabihf
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
./configure --config=ARM-Linux --everything --omit=PDF,Crypto,NetSSL_OpenSSL,JWT,Data/MySQL,Data/ODBC,Data/PostgreSQL,PageCompiler,PageCompiler/File2Page &&
make all -s -j4 ARCHFLAGS="-mcpu=cortex-a8 -mfloat-abi=hard -mfpu=neon" TOOL=arm-linux-gnueabihf
macos-clang-make:
runs-on: macos-12
@ -123,18 +149,23 @@ jobs:
--odbc-include=/usr/local/opt/unixodbc/include --odbc-lib=/usr/local/opt/unixodbc/lib
--mysql-include=/usr/local/opt/mysql-client/include --mysql-lib=/usr/local/opt/mysql-client/lib &&
make all -s -j4
- run: >-
sudo -s
CPPUNIT_IGNORE="
CppUnit::TestCaller<ThreadTest>.testTrySleep,
CppUnit::TestCaller<TimestampTest>.testTimestamp,
CppUnit::TestCaller<ExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<UniqueExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<SyslogTest>.testOldBSD"
EXCLUDE_TESTS="Redis Data/MySQL Data/ODBC Data/PostgreSQL MongoDB PDF"
./ci/runtests.sh
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
CPPUNIT_IGNORE="
CppUnit::TestCaller<ThreadTest>.testTrySleep,
CppUnit::TestCaller<TimestampTest>.testTimestamp,
CppUnit::TestCaller<ExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<UniqueExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<SyslogTest>.testOldBSD"
EXCLUDE_TESTS="Redis Data/MySQL Data/ODBC Data/PostgreSQL MongoDB PDF"
./ci/runtests.sh
macos-clang-cmake:
runs-on: macos-12
@ -142,19 +173,24 @@ jobs:
- uses: actions/checkout@v3
- run: brew install openssl@1.1 mysql-client unixodbc libpq
- run: cmake -H. -Bcmake-build -DENABLE_PDF=OFF -DENABLE_TESTS=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 -DMYSQL_ROOT_DIR=/usr/local/opt/mysql-client && cmake --build cmake-build --target all
- run: >-
cd cmake-build &&
sudo -s
CPPUNIT_IGNORE="
CppUnit::TestCaller<ThreadTest>.testTrySleep,
CppUnit::TestCaller<TimestampTest>.testTimestamp,
CppUnit::TestCaller<ExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<UniqueExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<PollSetTest>.testPollClosedServer"
PWD=`pwd`
ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(PostgreSQL)|(MongoDB)|(Redis)"
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
cd cmake-build &&
sudo -s
CPPUNIT_IGNORE="
CppUnit::TestCaller<ThreadTest>.testTrySleep,
CppUnit::TestCaller<TimestampTest>.testTimestamp,
CppUnit::TestCaller<ExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<UniqueExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<PollSetTest>.testPollClosedServer"
PWD=`pwd`
ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(PostgreSQL)|(MongoDB)|(Redis)"
macos-clang-cmake-openssl3:
runs-on: macos-12
@ -162,54 +198,69 @@ jobs:
- uses: actions/checkout@v3
- run: brew install openssl@3 mysql-client unixodbc libpq
- run: cmake -H. -Bcmake-build -DENABLE_PDF=OFF -DENABLE_TESTS=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 -DMYSQL_ROOT_DIR=/usr/local/opt/mysql-client && cmake --build cmake-build --target all
- run: >-
cd cmake-build &&
sudo -s
CPPUNIT_IGNORE="
CppUnit::TestCaller<ThreadTest>.testTrySleep,
CppUnit::TestCaller<TimestampTest>.testTimestamp,
CppUnit::TestCaller<ExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<UniqueExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<PollSetTest>.testPollClosedServer"
PWD=`pwd`
ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(PostgreSQL)|(MongoDB)|(Redis)"
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
cd cmake-build &&
sudo -s
CPPUNIT_IGNORE="
CppUnit::TestCaller<ThreadTest>.testTrySleep,
CppUnit::TestCaller<TimestampTest>.testTimestamp,
CppUnit::TestCaller<ExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<UniqueExpireLRUCacheTest>.testExpireN,
CppUnit::TestCaller<ExpireLRUCacheTest>.testAccessExpireN,
CppUnit::TestCaller<PollSetTest>.testPollClosedServer"
PWD=`pwd`
ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(PostgreSQL)|(MongoDB)|(Redis)"
windows-2019-msvc-cmake:
runs-on: windows-2019
env:
CPPUNIT_IGNORE: >-
class CppUnit::TestCaller<class PathTest>.testFind,
class CppUnit::TestCaller<class ICMPSocketTest>.testSendToReceiveFrom,
class CppUnit::TestCaller<class ICMPClientTest>.testPing,
class CppUnit::TestCaller<class ICMPClientTest>.testBigPing,
class CppUnit::TestCaller<class ICMPSocketTest>.testMTU,
class CppUnit::TestCaller<class HTTPSClientSessionTest>.testProxy,
class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy,
class CppUnit::TestCaller<class PollSetTest>.testPollClosedServer
steps:
- uses: actions/checkout@v3
- run: cmake -S. -Bcmake-build -DENABLE_NETSSL_WIN=ON -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_JWT=OFF -DENABLE_DATA=ON -DENABLE_DATA_ODBC=ON -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_TESTS=ON
- run: cmake --build cmake-build --config Release
- run: >-
cd cmake-build;
ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(Redis)|(MongoDB)" -C Release
windows-2019-msvc-buildwin-x64:
runs-on: windows-2019
env:
CPPUNIT_IGNORE: >-
class CppUnit::TestCaller<class PathTest>.testFind,
class CppUnit::TestCaller<class ICMPSocketTest>.testSendToReceiveFrom,
class CppUnit::TestCaller<class ICMPClientTest>.testPing,
class CppUnit::TestCaller<class ICMPClientTest>.testBigPing,
class CppUnit::TestCaller<class ICMPSocketTest>.testMTU,
class CppUnit::TestCaller<class HTTPSClientSessionTest>.testProxy,
class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy
steps:
- uses: actions/checkout@v3
- run: .\buildwin.ps1 -poco_base . -vs 160 -action build -linkmode all -config release -platform x64 -samples -tests -omit "Crypto,NetSSL_OpenSSL,Data/MySQL,Data/PostgreSQL,JWT"
# windows-2019-msvc-cmake:
# runs-on: windows-2019
# env:
# CPPUNIT_IGNORE: >-
# class CppUnit::TestCaller<class PathTest>.testFind,
# class CppUnit::TestCaller<class ICMPSocketTest>.testSendToReceiveFrom,
# class CppUnit::TestCaller<class ICMPClientTest>.testPing,
# class CppUnit::TestCaller<class ICMPClientTest>.testBigPing,
# class CppUnit::TestCaller<class ICMPSocketTest>.testMTU,
# class CppUnit::TestCaller<class HTTPSClientSessionTest>.testProxy,
# class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy,
# class CppUnit::TestCaller<class PollSetTest>.testPollClosedServer
# steps:
# - uses: actions/checkout@v3
# - run: cmake -S. -Bcmake-build -DENABLE_NETSSL_WIN=ON -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_JWT=OFF -DENABLE_DATA=ON -DENABLE_DATA_ODBC=ON -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_TESTS=ON
# - run: cmake --build cmake-build --config Release
# - uses: ./.github/actions/retry-action
# with:
# timeout_minutes: 90
# max_attempts: 3
# retry_on: any
# command: >-
# cd cmake-build;
# ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(Redis)|(MongoDB)" -C Release
# windows-2019-msvc-buildwin-x64:
# runs-on: windows-2019
# env:
# CPPUNIT_IGNORE: >-
# class CppUnit::TestCaller<class PathTest>.testFind,
# class CppUnit::TestCaller<class ICMPSocketTest>.testSendToReceiveFrom,
# class CppUnit::TestCaller<class ICMPClientTest>.testPing,
# class CppUnit::TestCaller<class ICMPClientTest>.testBigPing,
# class CppUnit::TestCaller<class ICMPSocketTest>.testMTU,
# class CppUnit::TestCaller<class HTTPSClientSessionTest>.testProxy,
# class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy
# steps:
# - uses: actions/checkout@v3
# - uses: ./.github/actions/retry-action
# with:
# timeout_minutes: 90
# max_attempts: 3
# retry_on: any
# command: .\buildwin.ps1 -poco_base . -vs 160 -action build -linkmode all -config release -platform x64 -samples -tests -omit "Crypto,NetSSL_OpenSSL,Data/MySQL,Data/PostgreSQL,JWT"
# windows-2019-msvc-buildwin-win32:
# runs-on: windows-2019
@ -217,7 +268,12 @@ jobs:
# CPPUNIT_IGNORE: class CppUnit::TestCaller<class PathTest>.testFind,class CppUnit::TestCaller<class ICMPSocketTest>.testSendToReceiveFrom,class CppUnit::TestCaller<class ICMPClientTest>.testPing,class CppUnit::TestCaller<class ICMPClientTest>.testBigPing,class CppUnit::TestCaller<class ICMPSocketTest>.testMTU,class CppUnit::TestCaller<class HTTPSClientSessionTest>.testProxy,class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy
# steps:
# - uses: actions/checkout@v3
# - run: .\buildwin.ps1 -poco_base . -vs 160 -action build -linkmode all -config release -platform Win32 -samples -tests -omit "Crypto,NetSSL_OpenSSL,Data/MySQL,Data/PostgreSQL,JWT"
# - uses: ./.github/actions/retry-action
# with:
# timeout_minutes: 90
# max_attempts: 3
# retry_on: any
# command: .\buildwin.ps1 -poco_base . -vs 160 -action build -linkmode all -config release -platform Win32 -samples -tests -omit "Crypto,NetSSL_OpenSSL,Data/MySQL,Data/PostgreSQL,JWT"
windows-2022-msvc-buildwin-x64:
runs-on: windows-2022
@ -232,7 +288,12 @@ jobs:
class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy
steps:
- uses: actions/checkout@v3
- run: .\buildwin.ps1 -poco_base . -vs 170 -action build -linkmode all -config release -platform x64 -samples -tests -omit "Crypto,NetSSL_OpenSSL,Data/MySQL,Data/PostgreSQL,JWT"
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: .\buildwin.ps1 -poco_base . -vs 170 -action build -linkmode all -config release -platform x64 -samples -tests -omit "Crypto,NetSSL_OpenSSL,Data/MySQL,Data/PostgreSQL,JWT"
# windows-2022-msvc-buildwin-win32:
# runs-on: windows-2022
@ -247,7 +308,12 @@ jobs:
# class CppUnit::TestCaller<class HTTPSStreamFactoryTest>.testProxy
# steps:
# - uses: actions/checkout@v3
# - run: .\buildwin.ps1 -poco_base . -vs 170 -action build -linkmode all -config release -platform Win32 -samples -tests -omit "Crypto,NetSSL_OpenSSL,Data/MySQL,Data/PostgreSQL,JWT"
# - uses: ./.github/actions/retry-action
# with:
# timeout_minutes: 90
# max_attempts: 3
# retry_on: any
# command: .\buildwin.ps1 -poco_base . -vs 170 -action build -linkmode all -config release -platform Win32 -samples -tests -omit "Crypto,NetSSL_OpenSSL,Data/MySQL,Data/PostgreSQL,JWT"
windows-2022-msvc-cmake:
runs-on: windows-2022
@ -264,9 +330,14 @@ jobs:
- uses: actions/checkout@v3
- run: cmake -S. -Bcmake-build -DENABLE_NETSSL_WIN=ON -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_JWT=OFF -DENABLE_DATA=ON -DENABLE_DATA_ODBC=ON -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_TESTS=ON
- run: cmake --build cmake-build --config Release
- run: >-
cd cmake-build;
ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(Redis)|(MongoDB)" -C Release
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
cd cmake-build;
ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(Redis)|(MongoDB)" -C Release
# missing asan dll path
# windows-2022-msvc-cmake-asan:
@ -284,6 +355,168 @@ jobs:
# - uses: actions/checkout@v3
# - run: cmake -S. -Bcmake-build -DPOCO_SANITIZE_ASAN=ON -DENABLE_NETSSL_WIN=ON -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_JWT=OFF -DENABLE_DATA=ON -DENABLE_DATA_ODBC=ON -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_TESTS=ON
# - run: cmake --build cmake-build --config Debug
# - run: >-
# - uses: ./.github/actions/retry-action
# with:
# timeout_minutes: 90
# max_attempts: 3
# retry_on: any
# command: >-
# cd cmake-build;
# ctest --output-on-failure -E "(DataMySQL)|(DataODBC)|(Redis)|(MongoDB)" -C Debug
linux-gcc-make-mysql:
runs-on: ubuntu-22.04
services:
mysql:
image: mysql:8.1.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_USER: pocotest
MYSQL_PASSWORD: pocotest
MYSQL_DATABASE: pocotest
ports:
- 3306:3306
steps:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev mysql-client
- run: ./configure --everything --no-samples --omit=ActiveRecord,ApacheConnector,CppParser,Crypto,Data/PostgreSQL,Data/SQLite,Data/ODBC,Encodings,JSON,JWT,MongoDB,Net,NetSSL_OpenSSL,NetSSL_Win,PDF,PageCompiler,PocoDoc,ProGen,Prometheus,Redis,SevenZip,Util,XML,Zip && make all -s -j4 && sudo make install
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
EXCLUDE_TESTS="ActiveRecord ApacheConnector CppParser CppUnit Crypto Data Data/PostgreSQL Data/ODBC Data/SQLite Encodings Foundation JSON JWT MongoDB Net NetSSL_OpenSSL NetSSL_Win PDF PageCompiler PocoDoc ProGen Prometheus Redis SevenZip Util XML Zip"
./ci/runtests.sh
# TODO tests sometimes failling on testTransaction and testReconnect
# linux-gcc-make-postgres:
# runs-on: ubuntu-22.04
# services:
# postgres:
# image: postgres:16.0
# env:
# POSTGRES_PASSWORD: postgres
# ports:
# - 5432:5432
# steps:
# - uses: actions/checkout@v3
# - run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev odbc-postgresql
# - run: ./configure --everything --no-samples --omit=ActiveRecord,ApacheConnector,CppParser,Crypto,Data/MySQL,Data/ODBC,Data/SQLite,Encodings,JSON,JWT,MongoDB,Net,NetSSL_OpenSSL,NetSSL_Win,PDF,PageCompiler,PocoDoc,ProGen,Prometheus,Redis,SevenZip,Util,XML,Zip && make all -s -j4 && sudo make install
# - uses: ./.github/actions/retry-action
# with:
# timeout_minutes: 90
# max_attempts: 3
# retry_on: any
# command: >-
# sudo -s
# EXCLUDE_TESTS="ActiveRecord ApacheConnector CppParser CppUnit Crypto Data Data/ODBC Data/MySQL Data/SQLite Encodings Foundation JSON JWT MongoDB Net NetSSL_OpenSSL NetSSL_Win PDF PageCompiler PocoDoc ProGen Prometheus Redis SevenZip Util XML Zip"
# ./ci/runtests.sh
linux-gcc-make-redis:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev
- run: |
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get -y update
sudo apt-get -y install redis
- run: ./configure --everything --no-samples --omit=ActiveRecord,ApacheConnector,CppParser,Crypto,Data/ODBC,Data/MySQL,Data/SQLite,Data/PostgreSQL,Encodings,JSON,JWT,MongoDB,Net,NetSSL_OpenSSL,NetSSL_Win,PDF,PageCompiler,PocoDoc,ProGen,Prometheus,SevenZip,Util,XML,Zip && make all -s -j4 && sudo make install
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
EXCLUDE_TESTS="ActiveRecord ApacheConnector CppParser CppUnit Crypto Data Data/ODBC Data/MySQL Data/SQLite Data/PostgreSQL Encodings Foundation JSON JWT MongoDB Net NetSSL_OpenSSL NetSSL_Win PDF PageCompiler PocoDoc ProGen Prometheus SevenZip Util XML Zip"
./ci/runtests.sh
linux-gcc-make-mongodb:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: supercharge/mongodb-github-action@1.10.0
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev
- run: ./configure --everything --no-samples --omit=ActiveRecord,ApacheConnector,CppParser,Crypto,Data/ODBC,Data/MySQL,Data/SQLite,Data/PostgreSQL,Encodings,JSON,JWT,Net,NetSSL_OpenSSL,NetSSL_Win,PDF,PageCompiler,PocoDoc,ProGen,Prometheus,Redis,SevenZip,Util,XML,Zip && make all -s -j4 && sudo make install
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
EXCLUDE_TESTS="ActiveRecord ApacheConnector CppParser CppUnit Crypto Data Data/ODBC Data/MySQL Data/SQLite Data/PostgreSQL Encodings Foundation JSON JWT Net NetSSL_OpenSSL NetSSL_Win PDF PageCompiler PocoDoc ProGen Prometheus Redis SevenZip Util XML Zip"
./ci/runtests.sh
linux-gcc-make-odbc:
runs-on: ubuntu-22.04
services:
mysql:
image: mysql:8.1.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_USER: pocotest
MYSQL_PASSWORD: pocotest
MYSQL_DATABASE: pocotest
ports:
- 3306:3306
postgres:
image: postgres:16.0
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
oracle:
image: container-registry.oracle.com/database/express:21.3.0-xe
env:
ORACLE_PWD: poco
ports:
- 1521:1521
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
MSSQL_PID: Express
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: Pocopoco1
ports:
- 1433:1433
steps:
- uses: actions/checkout@v3
- run: sudo apt -y update && sudo apt -y install libssl-dev unixodbc-dev libmysqlclient-dev mysql-client alien libaio1 gnupg2 curl #odbc-postgresql
- run: ./configure --everything --no-samples --omit=ActiveRecord,ApacheConnector,CppParser,Crypto,Data/MySQL,Data/PostgreSQL,Data/SQLite,Encodings,JSON,JWT,MongoDB,Net,NetSSL_OpenSSL,NetSSL_Win,PDF,PageCompiler,PocoDoc,ProGen,Prometheus,Redis,SevenZip,Util,XML,Zip && make all -s -j4 && sudo make install
# - name: Setup MySQL ODBC connector
# run: |
# wget https://dev.mysql.com/get/Downloads/Connector-ODBC/8.2/mysql-connector-odbc_8.2.0-1ubuntu22.04_amd64.deb
# wget https://dev.mysql.com/get/Downloads/MySQL-8.2/mysql-community-client-plugins_8.2.0-1ubuntu22.04_amd64.deb
# sudo dpkg -i mysql-community-client-plugins_8.2.0-1ubuntu22.04_amd64.deb mysql-connector-odbc_8.2.0-1ubuntu22.04_amd64.deb
# - name: Setup Oracle ODBC connector
# run: |
# wget https://download.oracle.com/otn_software/linux/instantclient/2112000/oracle-instantclient-basic-21.12.0.0.0-1.x86_64.rpm
# wget https://download.oracle.com/otn_software/linux/instantclient/2112000/oracle-instantclient-sqlplus-21.12.0.0.0-1.x86_64.rpm
# wget https://download.oracle.com/otn_software/linux/instantclient/2112000/oracle-instantclient-odbc-21.12.0.0.0-1.x86_64.rpm
# sudo alien --scripts ./oracle-instantclient-basic-21.12.0.0.0-1.x86_64.rpm
# sudo alien --scripts ./oracle-instantclient-sqlplus-21.12.0.0.0-1.x86_64.rpm
# sudo alien --scripts ./oracle-instantclient-odbc-21.12.0.0.0-1.x86_64.rpm
# sudo apt install ./oracle-instantclient-basic_21.12.0.0.0-2_amd64.deb
# sudo apt install ./oracle-instantclient-sqlplus_21.12.0.0.0-2_amd64.deb
# sudo apt install ./oracle-instantclient-odbc_21.12.0.0.0-2_amd64.deb
# sudo /usr/lib/oracle/21/client64/bin/odbc_update_ini.sh / "/usr/lib/oracle/21/client64/lib" "" "" "/etc/odbc.ini"
- name: Setup SQL Server ODBC connector
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
- uses: ./.github/actions/retry-action
with:
timeout_minutes: 90
max_attempts: 3
retry_on: any
command: >-
sudo -s
EXCLUDE_TESTS="ActiveRecord ApacheConnector CppParser CppUnit Crypto Data Data/MySQL Data/PostgreSQL Data/SQLite Encodings Foundation JSON JWT MongoDB Net NetSSL_OpenSSL NetSSL_Win PDF PageCompiler PocoDoc ProGen Prometheus Redis SevenZip Util XML Zip"
./ci/runtests.sh

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
sudo apt-get -y update && sudo apt-get -y install cmake ninja-build libssl-dev unixodbc-dev libmysqlclient-dev redis-server
cmake -H. -Bcmake-build -GNinja -DENABLE_PDF=OFF -DENABLE_TESTS=ON && cmake --build cmake-build --target all

129
.github/workflows/codeql.yml vendored Normal file
View File

@ -0,0 +1,129 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "main", "master" ]
schedule:
- cron: '0 0 * * *'
pull_request:
branches: '*'
jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-20.04' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
queries: security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
#- name: Autobuild
# uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
- run: |
./.github/workflows/codeql-buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
upload: false
id: step1
# Filter out rules with low severity or high false positve rate
# Also filter out warnings in third-party code
- name: Filter out unwanted errors and warnings
uses: advanced-security/filter-sarif@v1
with:
patterns: |
-**:cpp/path-injection
-**:cpp/world-writable-file-creation
-**:cpp/poorly-documented-function
-**:cpp/potentially-dangerous-function
-**:cpp/use-of-goto
-**:cpp/integer-multiplication-cast-to-long
-**:cpp/comparison-with-wider-type
-**:cpp/leap-year/*
-**:cpp/ambiguously-signed-bit-field
-**:cpp/suspicious-pointer-scaling
-**:cpp/suspicious-pointer-scaling-void
-**:cpp/unsigned-comparison-zero
-**/cmake*/Modules/**
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
- name: Upload CodeQL results to code scanning
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.step1.outputs.sarif-output }}
category: "/language:${{matrix.language}}"
- name: Upload CodeQL results as an artifact
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: codeql-results
path: ${{ steps.step1.outputs.sarif-output }}
retention-days: 5
- name: Setup Python
uses: actions/setup-python@v4
# - name: Fail if an error is found
# run: |
# python ./.github/workflows/fail_on_error.py \
# ${{ steps.step1.outputs.sarif-output }}/cpp.sarif

34
.github/workflows/fail_on_error.py vendored Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env python3
import json
import sys
# Return whether SARIF file contains error-level results
def codeql_sarif_contain_error(filename):
with open(filename, 'r') as f:
s = json.load(f)
for run in s.get('runs', []):
rules_metadata = run['tool']['driver']['rules']
if not rules_metadata:
rules_metadata = run['tool']['extensions'][0]['rules']
for res in run.get('results', []):
if 'ruleIndex' in res:
rule_index = res['ruleIndex']
elif 'rule' in res and 'index' in res['rule']:
rule_index = res['rule']['index']
else:
continue
try:
rule_level = rules_metadata[rule_index]['defaultConfiguration']['level']
except IndexError as e:
print(e, rule_index, len(rules_metadata))
else:
if rule_level == 'error':
return True
return False
if __name__ == "__main__":
if codeql_sarif_contain_error(sys.argv[1]):
sys.exit(1)

5
.gitignore vendored
View File

@ -152,3 +152,8 @@ poco_build_stderr.out
*.swp
*.vim
tags
# Javascript #
##############
package-lock.json
node_modules

View File

@ -38,13 +38,13 @@ using Poco::Tuple;
using Poco::NotFoundException;
#define MYSQL_ODBC_DRIVER "MySQL ODBC 5.3 Unicode Driver"
#define MYSQL_ODBC_DRIVER "MySQL ODBC 8.2 Unicode Driver"
#define MYSQL_DSN "PocoDataMySQLTest"
#define MYSQL_SERVER POCO_ODBC_TEST_DATABASE_SERVER
#define MYSQL_DB "test"
#define MYSQL_UID "root"
#define MYSQL_PWD "poco"
#define MYSQL_DB "test"
#define MYSQL_DB "pocotest"
#define MYSQL_UID "pocotest"
#define MYSQL_PWD "pocotest"
#define MYSQL_DB "pocotest"
ODBCTest::SessionPtr ODBCMySQLTest::_pSession;

View File

@ -41,12 +41,12 @@ using Poco::DynamicAny;
using Poco::DateTime;
#define ORACLE_ODBC_DRIVER "Oracle in XE"
#define ORACLE_ODBC_DRIVER "Oracle 21 ODBC driver"
#define ORACLE_DSN "PocoDataOracleTest"
#define ORACLE_SERVER POCO_ODBC_TEST_DATABASE_SERVER
#define ORACLE_PORT "1521"
#define ORACLE_SID "XE"
#define ORACLE_UID "poco"
#define ORACLE_UID "SYSTEM"
#define ORACLE_PWD "poco"

View File

@ -44,7 +44,7 @@ using Poco::DateTime;
#define POSTGRESQL_DSN "PocoDataPgSQLTestW"
#else
#ifdef POCO_PTR_IS_64_BIT
#define POSTGRESQL_ODBC_DRIVER "PostgreSQL ANSI(x64)"
#define POSTGRESQL_ODBC_DRIVER "PostgreSQL ANSI"
#else
#define POSTGRESQL_ODBC_DRIVER "PostgreSQL ANSI"
#endif
@ -59,8 +59,8 @@ using Poco::DateTime;
#define POSTGRESQL_PORT "5432"
#define POSTGRESQL_DB "postgres"
#define POSTGRESQL_UID "postgres"
#define POSTGRESQL_PWD "poco"
#define POSTGRESQL_VERSION "10"
#define POSTGRESQL_PWD "postgres"
#define POSTGRESQL_VERSION "16"
#ifdef POCO_OS_FAMILY_WINDOWS
const std::string ODBCPostgreSQLTest::_libDir = "C:\\\\Program Files\\\\PostgreSQL\\\\pg" POSTGRESQL_VERSION "\\\\lib\\\\";

View File

@ -68,9 +68,9 @@ using Poco::DateTime;
#define MS_SQL_SERVER_DSN "PocoDataSQLServerTest"
#define MS_SQL_SERVER_SERVER POCO_ODBC_TEST_DATABASE_SERVER
#define MS_SQL_SERVER_PORT "1433"
#define MS_SQL_SERVER_DB "poco"
#define MS_SQL_SERVER_UID "poco"
#define MS_SQL_SERVER_PWD "poco"
#define MS_SQL_SERVER_DB "model"
#define MS_SQL_SERVER_UID "sa"
#define MS_SQL_SERVER_PWD "Pocopoco1"
ODBCTest::SessionPtr ODBCSQLServerTest::_pSession;
@ -88,6 +88,7 @@ std::string ODBCSQLServerTest::_connectString = "DRIVER=" MS_SQL_SERVER_ODBC_DRI
"DATABASE=" MS_SQL_SERVER_DB ";"
"SERVER=" MS_SQL_SERVER_SERVER ";"
"PORT=" MS_SQL_SERVER_PORT ";"
"TrustServerCertificate=yes;"
"Encrypt=no"
#ifdef FREE_TDS_VERSION
"TDS_Version=" FREE_TDS_VERSION ";"

View File

@ -47,27 +47,12 @@ class Foundation_API FileIOS: public virtual std::ios
/// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled.
{
public:
FileIOS(std::ios::openmode defaultMode);
FileIOS();
/// Creates the basic stream.
~FileIOS();
/// Destroys the stream.
void open(const std::string& path, std::ios::openmode mode);
/// Opens the file specified by path, using the given mode.
///
/// Throws a FileException (or a similar exception) if the file
/// does not exist or is not accessible for other reasons and
/// a new file cannot be created.
void open(const std::string& path);
/// Opens the file specified by path, using the default mode given
/// in the constructor.
///
/// Throws a FileException (or a similar exception) if the file
/// does not exist or is not accessible for other reasons and
/// a new file cannot be created.
void close();
/// Closes the file stream.
///
@ -80,7 +65,6 @@ public:
protected:
FileStreamBuf _buf;
std::ios::openmode _defaultMode;
};
@ -111,6 +95,14 @@ public:
~FileInputStream();
/// Destroys the stream.
void open(const std::string& path, std::ios::openmode mode = std::ios::in);
/// Opens the file specified by path, using the given mode, which
/// will always include std::ios::in (even if not specified).
///
/// Throws a FileException (or a similar exception) if the file
/// does not exist or is not accessible for other reasons and
/// a new file cannot be created.
};
@ -139,9 +131,25 @@ public:
/// Throws a FileException (or a similar exception) if the file
/// does not exist or is not accessible for other reasons and
/// a new file cannot be created.
///
/// NOTE: The default mode std::ios::out | std::ios::trunc is different from the default
/// for std::ofstream, which is std::ios::out only. This is for backwards compatibility
/// with earlier POCO versions.
~FileOutputStream();
/// Destroys the FileOutputStream.
void open(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::trunc);
/// Opens the file specified by path, using the given mode, which
/// always includes std::ios::out, even if not specified.
///
/// Throws a FileException (or a similar exception) if the file
/// does not exist or is not accessible for other reasons and
/// a new file cannot be created.
///
/// NOTE: The default mode std::ios::out | std::ios::trunc is different from the default
/// for std::ostream, which is std::ios::out only. This is for backwards compatibility
/// with earlier POCO versions.
};
@ -168,9 +176,20 @@ public:
FileStream(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::in);
/// Creates the FileStream for the file given by path, using
/// the given mode.
///
/// NOTE: The default mode std::ios::in | std::ios::out is different from the default
/// for std::fstream, which is std::ios::out only. This is for backwards compatibility
/// with earlier POCO versions.
~FileStream();
/// Destroys the FileOutputStream.
void open(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::in);
/// Opens the file specified by path, using the given mode.
///
/// Throws a FileException (or a similar exception) if the file
/// does not exist or is not accessible for other reasons and
/// a new file cannot be created.
};

View File

@ -24,8 +24,7 @@
namespace Poco {
FileIOS::FileIOS(std::ios::openmode defaultMode):
_defaultMode(defaultMode)
FileIOS::FileIOS()
{
poco_ios_init(&_buf);
}
@ -36,20 +35,6 @@ FileIOS::~FileIOS()
}
void FileIOS::open(const std::string& path, std::ios::openmode mode)
{
clear();
_buf.open(path, mode);
}
void FileIOS::open(const std::string& path)
{
clear();
_buf.open(path, _defaultMode);
}
void FileIOS::close()
{
if (!_buf.close())
@ -66,14 +51,12 @@ FileStreamBuf* FileIOS::rdbuf()
FileInputStream::FileInputStream():
FileIOS(std::ios::in),
std::istream(&_buf)
{
}
FileInputStream::FileInputStream(const std::string& path, std::ios::openmode mode):
FileIOS(mode | std::ios::in),
std::istream(&_buf)
{
open(path, mode | std::ios::in);
@ -85,15 +68,20 @@ FileInputStream::~FileInputStream()
}
void FileInputStream::open(const std::string& path, std::ios::openmode mode)
{
clear();
_buf.open(path, mode | std::ios::in);
}
FileOutputStream::FileOutputStream():
FileIOS(std::ios::out),
std::ostream(&_buf)
{
}
FileOutputStream::FileOutputStream(const std::string& path, std::ios::openmode mode):
FileIOS(mode | std::ios::out),
std::ostream(&_buf)
{
open(path, mode | std::ios::out);
@ -105,15 +93,20 @@ FileOutputStream::~FileOutputStream()
}
void FileOutputStream::open(const std::string& path, std::ios::openmode mode)
{
clear();
_buf.open(path, mode | std::ios::out);
}
FileStream::FileStream():
FileIOS(std::ios::in | std::ios::out),
std::iostream(&_buf)
{
}
FileStream::FileStream(const std::string& path, std::ios::openmode mode):
FileIOS(mode),
std::iostream(&_buf)
{
open(path, mode);
@ -125,4 +118,11 @@ FileStream::~FileStream()
}
void FileStream::open(const std::string& path, std::ios::openmode mode)
{
clear();
_buf.open(path, mode);
}
} // namespace Poco

View File

@ -15,6 +15,7 @@
#include "Poco/Thread.h"
#include "Poco/Event.h"
#include "Poco/AutoPtr.h"
#include <iostream>
using Poco::Task;
@ -34,20 +35,42 @@ namespace
void runTask()
{
_event.wait();
if (sleep(10))
return;
setProgress(0.5);
_event.wait();
if (isCancelled())
return;
setProgress(1.0);
_event.wait();
try
{
_event.wait();
if (sleep(10))
return;
setProgress(0.5);
_event.wait();
if (isCancelled())
return;
setProgress(1.0);
_event.wait();
}
catch(const Poco::Exception& e)
{
std::cerr << "TestTask::run(): " << e.displayText() << '\n';
}
catch(const std::exception& e)
{
std::cerr << "TestTask::run(): " << e.what() << '\n';
}
catch(...)
{
std::cerr << "TestTask::run(): unknown exception." << '\n';
}
}
void cont()
{
_event.set();
try
{
_event.set();
}
catch(const Poco::SystemException& e)
{
std::cerr << "TestTask::cont(): " << e.displayText() << '\n';
}
}
private: