Skip to content

Commit dd941fd

Browse files
committed
feat: reusable action, housekeeping
1 parent 29e41b0 commit dd941fd

5 files changed

Lines changed: 105 additions & 152 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Reusable Build Workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
description: 'Git reference to checkout'
8+
required: false
9+
type: string
10+
11+
# workflow_dispatch: # Allows manual triggering
12+
13+
jobs:
14+
format:
15+
runs-on: ubuntu-latest
16+
container:
17+
image: ghcr.io/milsanore/tradercppbuild:v1.6
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
# if commit ref not set, revert to github-set commit
23+
ref: ${{ inputs.ref || github.ref }}
24+
- name: clang-format
25+
run: hooks/check_clang_format.sh
26+
27+
build_and_test:
28+
needs: format
29+
runs-on: ubuntu-latest
30+
container:
31+
image: ghcr.io/milsanore/tradercppbuild:v1.6
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
- name: Restore Conan cache
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.conan2
41+
key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.*') }}
42+
restore-keys: |
43+
${{ runner.os }}-conan-
44+
- name: Install conan dependencies
45+
run: |
46+
set -e
47+
rm -rf build
48+
conan profile detect --force
49+
conan install . --build=missing -s build_type=Debug
50+
- name: Build
51+
run: |
52+
set -e
53+
cmake --preset=debug
54+
cmake --build --preset=debug
55+
ctest --preset=debug
56+
- name: Test
57+
run: |
58+
set -e
59+
# `lcov` FOR CODECOV
60+
lcov --gcov-tool gcov \
61+
--capture \
62+
--directory . \
63+
--output-file lcov.info \
64+
--rc geninfo_unexecuted_blocks=1 \
65+
--ignore-errors mismatch
66+
lcov --remove lcov.info '/home/*' '/usr/*' 'tests/*' --output-file lcov_filtered.info
67+
# `gcovr` FOR SONARQUBE
68+
gcovr -r . --exclude 'tests/*' --sonarqube -o sonar-coverage.xml
69+
- name: clang-tidy (delta)
70+
run: hooks/check_clang_tidy.sh
71+
- name: Upload coverage to Codecov
72+
uses: codecov/codecov-action@v5
73+
with:
74+
token: ${{ secrets.CODECOV_TOKEN }}
75+
files: lcov_filtered.info
76+
continue-on-error: true
77+
- name: SonarQube Scan
78+
uses: SonarSource/sonarqube-scan-action@v6.0.0
79+
env:
80+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
81+
with:
82+
args: >
83+
-Dsonar.coverageReportPaths=sonar-coverage.xml
84+
-Dsonar.projectBaseDir=.
85+
-Dsonar.sources=src
86+
-Dsonar.tests=tests
87+
continue-on-error: true

.github/workflows/commits.yml

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -7,82 +7,7 @@ on:
77
pull_request:
88
branches: [ master ]
99

10+
1011
jobs:
11-
format:
12-
runs-on: ubuntu-latest
13-
container:
14-
image: ghcr.io/milsanore/tradercppbuild:v1.6
15-
steps:
16-
- name: Checkout repository
17-
uses: actions/checkout@v4
18-
- name: clang-format
19-
run: hooks/check_clang_format.sh
20-
21-
build_and_test:
22-
needs: format
23-
runs-on: ubuntu-latest
24-
container:
25-
image: ghcr.io/milsanore/tradercppbuild:v1.6
26-
steps:
27-
- name: Checkout full history
28-
uses: actions/checkout@v4
29-
with:
30-
fetch-depth: 0
31-
- name: Restore Conan cache
32-
uses: actions/cache@v4
33-
with:
34-
path: ~/.conan2
35-
key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.*') }}
36-
restore-keys: |
37-
${{ runner.os }}-conan-
38-
- name: Install conan dependencies
39-
run: |
40-
set -e
41-
rm -rf build
42-
conan profile detect --force
43-
conan install . --build=missing -s build_type=Debug
44-
- name: Build
45-
run: |
46-
set -e
47-
cmake --preset=debug
48-
cmake --build --preset=debug
49-
- name: Test
50-
run: |
51-
set -e
52-
ctest --preset=debug
53-
# `lcov` FOR CODECOV
54-
lcov --gcov-tool gcov --capture --directory . --output-file lcov.info \
55-
--rc geninfo_unexecuted_blocks=1 \
56-
--ignore-errors mismatch
57-
lcov --remove lcov.info '/home/*' '/usr/*' 'tests/*' --output-file lcov_filtered.info
58-
# `gcovr` FOR SONARQUBE
59-
gcovr -r . --exclude 'tests/*' --sonarqube -o sonar-coverage.xml
60-
- name: Configure git safe directory
61-
run: git config --global --add safe.directory $(pwd)
62-
- name: clang-tidy (delta)
63-
run: |
64-
set -e
65-
git fetch --no-tags origin master
66-
diff=$(git diff -U0 origin/master...HEAD -- '*.cpp')
67-
if [ -z "$diff" ]; then
68-
echo "No changes to lint."
69-
exit 0
70-
fi
71-
echo "$diff" | clang-tidy-diff-18.py -p1 -path build/Debug
72-
- name: Upload coverage to Codecov
73-
uses: codecov/codecov-action@v5
74-
with:
75-
token: ${{ secrets.CODECOV_TOKEN }}
76-
files: lcov_filtered.info
77-
continue-on-error: true
78-
- name: SonarQube Scan
79-
uses: SonarSource/sonarqube-scan-action@v6.0.0
80-
env:
81-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
82-
with:
83-
args: >
84-
-Dsonar.coverageReportPaths=sonar-coverage.xml
85-
-Dsonar.projectBaseDir=.
86-
-Dsonar.sources=src
87-
-Dsonar.tests=tests
88-
continue-on-error: true
12+
call-reusable:
13+
uses: ./.github/workflows/clean_build_test.yml

.github/workflows/cron.yml

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,10 @@ on:
44
schedule:
55
- cron: '0 0 * * *' # Runs every day at midnight UTC
66

7-
workflow_dispatch: # Allows manual triggering
7+
# workflow_dispatch: # Allows manual triggering
88

99
jobs:
10-
format:
11-
runs-on: ubuntu-latest
12-
container:
13-
image: ghcr.io/milsanore/tradercppbuild:v1.6
14-
steps:
15-
- name: Checkout repository
16-
uses: actions/checkout@v4
17-
with:
18-
ref: master
19-
- name: clang-format
20-
run: hooks/check_clang_format.sh
21-
22-
build_and_test:
23-
needs: format
24-
runs-on: ubuntu-latest
25-
container:
26-
image: ghcr.io/milsanore/tradercppbuild:v1.6
27-
steps:
28-
- name: Checkout repository
29-
uses: actions/checkout@v4
30-
- name: Restore Conan cache
31-
uses: actions/cache@v4
32-
with:
33-
path: ~/.conan2
34-
key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.*') }}
35-
restore-keys: |
36-
${{ runner.os }}-conan-
37-
- name: Install conan dependencies
38-
run: |
39-
set -e
40-
rm -rf build
41-
conan profile detect --force
42-
conan install . --build=missing -s build_type=Debug
43-
- name: Build and Test
44-
run: |
45-
set -e
46-
cmake --preset=debug
47-
cmake --build --preset=debug
48-
ctest --preset=debug
49-
# `lcov` FOR CODECOV
50-
lcov --gcov-tool gcov \
51-
--capture \
52-
--directory . \
53-
--output-file lcov.info \
54-
--rc geninfo_unexecuted_blocks=1 \
55-
--ignore-errors mismatch
56-
lcov --remove lcov.info '/home/*' '/usr/*' 'tests/*' --output-file lcov_filtered.info
57-
# `gcovr` FOR SONARQUBE
58-
gcovr -r . --exclude 'tests/*' --sonarqube -o sonar-coverage.xml
59-
- name: clang-tidy (delta)
60-
run: hooks/check_clang_tidy.sh
61-
- name: Upload coverage to Codecov
62-
uses: codecov/codecov-action@v5
63-
with:
64-
token: ${{ secrets.CODECOV_TOKEN }}
65-
files: lcov_filtered.info
66-
continue-on-error: true
67-
- name: SonarQube Scan
68-
uses: SonarSource/sonarqube-scan-action@v6.0.0
69-
env:
70-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
71-
with:
72-
args: >
73-
-Dsonar.coverageReportPaths=sonar-coverage.xml
74-
-Dsonar.projectBaseDir=.
75-
-Dsonar.sources=src
76-
-Dsonar.tests=tests
77-
continue-on-error: true
10+
call-reusable:
11+
uses: ./.github/workflows/clean_build_test.yml
12+
with:
13+
ref: ${{ 'master' }}

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
[![codecov](https://codecov.io/github/milsanore/trader.cpp/graph/badge.svg?token=C787ZTXBQC)](https://codecov.io/github/milsanore/trader.cpp)
44

55
<img src="docs/app.gif" alt="trader.cpp" width="800" />
6-
<!-- <img src="docs/stonks.png" alt="stonks" width="250" /> -->
6+
<br/>
7+
<br/>
78

89
# trader.cpp
9-
a proof-of-concept, showcasing some c++ coding combined with some fintech concepts
10+
Small trading UI connected to Binance over their FIX API.<br/>
11+
A proof-of-concept, showcasing some modern c++ and some fintech concepts.
1012

1113
## Run Requirements
1214
- a Binance account, with an Ed25519 token that has FIX read permissions enabled
@@ -27,7 +29,9 @@ a proof-of-concept, showcasing some c++ coding combined with some fintech concep
2729
- `lcov`
2830

2931
## Build and Run
30-
(NB: this app uses `make` as a task runner, but it's not essential)
32+
NB: this app uses `make` as a recipe book, but it's not essential:
33+
<img src="docs/make-menu.png" alt="trader.cpp" width="800" />
34+
3135
1. copy `.env.example` to `.env`, and set your public/private keys
3236
2. run an SSL tunnel (e.g. `stunnel binance/stunnel_prod.conf`)
3337
3. `make init`
@@ -74,6 +78,7 @@ a proof-of-concept, showcasing some c++ coding combined with some fintech concep
7478
- update balance for in-flight orders (reconcile asynchronously)
7579

7680
## Non-functional
81+
- ✅ QuickFIX
7782
- ✅ basic cpp app to start with
7883
- ✅ makefile and build chain
7984
- ✅ package management
@@ -108,7 +113,7 @@ a proof-of-concept, showcasing some c++ coding combined with some fintech concep
108113
- ✅ integrated into build pipeline
109114
- ✅ badges
110115
- ✅ sonarcloud integrated into build pipeline
111-
- sonarcloud coverage
116+
- sonarcloud coverage
112117
- diagnostics
113118
- ✅ ASan
114119
- UBSan
@@ -118,7 +123,7 @@ a proof-of-concept, showcasing some c++ coding combined with some fintech concep
118123
- ✅ custom docker build image with all dependencies (hosted on GHCR for faster pipelines)
119124
- ✅ cron
120125
- ✅ comprehensive clang-tidy & clang-format checks
121-
- sonarcloud
126+
- sonarcloud
122127
- ccache or precomiled headers
123128
- local github action runner (`act`)
124129
- containerised integration tests / dind

docs/make-menu.png

89.9 KB
Loading

0 commit comments

Comments
 (0)