Added a trade manager to record trades #45
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Backtesting C++ Workflow | |
# To build, test and perform SonarCloud analysis | |
name: Build | |
on: | |
push: | |
branches: | |
- main # Trigger on pushes to main branch | |
pull_request: | |
types: | |
- opened # When PR is first created | |
- synchronize # When new commits are pushed to the PR | |
- reopened # When PR is reopened after being closed | |
# Environment variables used across jobs | |
env: | |
BUILD_TYPE: Release # Set CMake build configuration | |
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Output directory for build wrapper | |
jobs: | |
build: | |
name: Build & Test | |
runs-on: macos-14 # Use macOS 14 (Sonoma) runner | |
steps: | |
# Step 1: Check out the repository code | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Step 2: Set up Homebrew package manager | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
# Step 3: Install required dependencies using Homebrew | |
- name: Install dependencies | |
run: bash ./.github/workflows/brew.sh | |
# Step 4: Build project external libraries | |
- name: Build C++ Libraries | |
run: bash ./.github/workflows/build.sh | |
# Step 5: Configure Xcode version | |
- name: Select Xcode version | |
run: | | |
sudo xcode-select -switch /Applications/Xcode_15.2.app | |
/usr/bin/xcodebuild -version | |
# Run XCode tests with specific configurations: | |
# - Builds and runs the test suite | |
# - Generates code coverage reports | |
# - Uses PostgreSQL and libpqxx external dependencies | |
# - Outputs results in JUnit format | |
- name: Run tests | |
run: > | |
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | |
xcodebuild | |
-scheme tests | |
-destination 'platform=macOS' | |
-resultBundlePath TestResult/ | |
-enableCodeCoverage YES | |
-derivedDataPath "/tmp" | |
HEADER_SEARCH_PATHS="./external/libpqxx/include/pqxx/internal ./external/libpqxx/include/ ./external/libpqxx/build/include/ ./external/" \ | |
LIBRARY_SEARCH_PATHS="./external/libpqxx/src/ ./external/libpqxx/build/src/" \ | |
OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L/opt/homebrew/Cellar/pkgconf/2.3.0_1/lib -L/opt/homebrew/Cellar/pkgconf/2.3.0_1/lib/pkgconfig -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14 -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14/pgxs -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14/pkgconfig" | |
clean build test | |
| xcpretty -r junit && exit ${PIPESTATUS[0]} | |
- name: Export coverage report | |
run: | | |
sh ./.github/workflows/cpp_coverage.sh | |
# - name: Convert coverage report to sonarqube format | |
# run: > | |
# bash ./.github/workflows/xccov-to-sonarqube-generic.sh *.xcresult/ > sonarqube-generic-coverage.xml | |
# Artifact will be available only for 1 day, this is because | |
# it's only used to pass test data to SonarCloud only | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
path: coverage.txt | |
retention-days: 1 | |
# This block takes the artifact generated from the build step and uses it for SonarCloud analysis | |
sonar-scan: | |
name: SonarCloud Scan | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository on branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.HEAD_REF }} | |
fetch-depth: 0 | |
- name: Check compiler version, for debugging | |
run: | | |
g++ --version | |
cmake --version | |
- name: Build C++ Libraries | |
run: > | |
bash ./.github/workflows/build.sh | |
- name: Install Python 3.12 for gcovr | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
# Gcovr provides a utility for managing the use of the GNU gcov utility and generating | |
# summarized code coverage results. This command is inspired by the Python coverage.py | |
# package, which provides a similar utility for Python. | |
# https://pypi.org/project/gcovr/ | |
- name: Install gcovr | |
run: | | |
pip install gcovr==8.3 | |
# SonarQube Server and Cloud (formerly SonarQube and SonarCloud) is a widely used static | |
# analysis solution for continuous code quality and security inspection. | |
# This action now supports and is the official entrypoint for scanning C++ projects via GitHub actions. | |
# https://github.com/SonarSource/sonarqube-scan-action | |
- name: Install Build Wrapper | |
uses: SonarSource/sonarqube-scan-action/[email protected] | |
# This step installs the SonarQube build wrapper, which is necessary for analyzing C/C++ projects. | |
# Downloads all artifacts generated by previous steps in the workflow | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v4 | |
- name: Check artifacts | |
run: | | |
ls -l ./ | |
ls -l ./artifact/ | |
# Configures the CMake build system, specifying the source directory and build directory, and setting the build type | |
- name: Configure CMake | |
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} | |
# Runs the build wrapper to capture build commands and outputs them to the specified directory. Then builds the project using CMake | |
- name: Run build-wrapper | |
run: | | |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} | |
# Performs the SonarQube scan using the scan action. Uses captured build commands for analysis and requires GitHub and SonarQube tokens for authentication | |
- name: SonarQube Scan | |
uses: SonarSource/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
with: | |
args: > | |
-Dsonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json | |
-Dsonar.sonar.cfamily.gcov.reportsPath=artifact/coverage.txt | |
# -Dsonar.coverageReportPaths=artifact/sonarqube-generic-coverage.xml |