Skip to content

Commit 0e717c1

Browse files
committed
work work work
1 parent 4c93861 commit 0e717c1

31 files changed

+822
-261
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: ⚙️ CodeQL - Run Unit Tests (cpp)
2+
3+
4+
on:
5+
push:
6+
branches:
7+
- '**'
8+
pull_request:
9+
branches:
10+
- '**'
11+
workflow_dispatch:
12+
13+
jobs:
14+
create-unit-test-matrix:
15+
name: Create CodeQL Unit Test Matrix
16+
runs-on: ubuntu-latest
17+
outputs:
18+
matrix: ${{ steps.export-unit-test-matrix.outputs.matrix }}
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- name: Install QLT
24+
id: install-qlt
25+
uses: ./.github/actions/install-qlt
26+
with:
27+
qlt-version: 'latest'
28+
add-to-path: true
29+
30+
- name: Export unit test matrix
31+
id: export-unit-test-matrix
32+
run: |
33+
qlt test run get-matrix --os-version ubuntu-latest --base example/
34+
35+
run-test-suites:
36+
name: Run Unit Tests
37+
needs: create-unit-test-matrix
38+
39+
runs-on: ${{ matrix.os }}
40+
strategy:
41+
fail-fast: false
42+
matrix: ${{ fromJSON(needs.create-unit-test-matrix.outputs.matrix) }}
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v3
47+
48+
- name: Install QLT
49+
id: install-qlt
50+
uses: ./.github/actions/install-qlt
51+
with:
52+
qlt-version: 'latest'
53+
add-to-path: true
54+
55+
- name: Install CodeQL
56+
id: install-codeql
57+
uses: ./.github/actions/install-codeql
58+
with:
59+
codeql-cli-version: ${{ matrix.codeql_cli }}
60+
codeql-stdlib-version: ${{ matrix.codeql_standard_library }}
61+
add-to-path: true
62+
63+
- name: Verify Versions of Tooling
64+
shell: bash
65+
run: |
66+
echo "CodeQL Home: ${{ steps.install-codeql.outputs.codeql-home }}"
67+
echo -e "Checking CodeQL Version:"
68+
codeql --version
69+
70+
echo -e "Checking QLT Version:"
71+
echo "QLT Home: ${{ steps.install-qlt.outputs.qlt-home }}"
72+
qlt version
73+
74+
- name: Install QL Packs
75+
shell: bash
76+
run: |
77+
qlt query run install-packs --base example/
78+
79+
- name: Run test suites
80+
id: run-test-suites
81+
env:
82+
RUNNER_OS: ${{ runner.os }}
83+
CODEQL_CLI: ${{ matrix.codeql_cli }}
84+
CODEQL_STDLIB: ${{ matrix.codeql_standard_library }}
85+
CODEQL_STDLIB_IDENT: ${{matrix.codeql_standard_library_ident}}
86+
RUNNER_TMP: ${{ runner.temp }}
87+
shell: bash
88+
run: |
89+
qlt run test unit-tests \
90+
--num-threads 4 \
91+
--language cpp \
92+
--runner-os $RUNNER_OS \
93+
--cli-version $CODEQL_CLI \
94+
--stdlib-ident $CODEQL_STDLIB_IDENT \
95+
--work-dir $RUNNER_TMP \
96+
--base example/
97+
98+
99+
- name: Upload test results
100+
uses: actions/upload-artifact@v2
101+
with:
102+
name: test-results-${{ runner.os }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}
103+
path: |
104+
${{ runner.temp }}/test_report_${{ runner.os }}_${{ matrix.codeql_cli }}_${{ matrix.codeql_standard_library_ident }}_slice_*.json
105+
if-no-files-found: error
106+
107+
validate-test-results:
108+
name: Validate test results
109+
needs: [run-test-suites]
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: Collect test results
113+
uses: actions/download-artifact@v2
114+
115+
- name: Validate test results
116+
run: |
117+
for json_report in test-results-*/test_report_*
118+
do
119+
jq --raw-output '"PASS \(map(select(.pass == true)) | length)/\(length)'" $json_report\"" "$json_report"
120+
done
121+
FAILING_TESTS=$(jq --raw-output '.[] | select(.pass == false)' test-results-*/test_report_*.json)
122+
if [[ ! -z "$FAILING_TESTS" ]]; then
123+
echo "ERROR: The following tests failed:"
124+
echo $FAILING_TESTS | jq .
125+
exit 1
126+
fi
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @id cpp/stuff/TestQuery
3+
* @name TestQuery
4+
* @description Replace this text with a description of your query.
5+
* @kind problem
6+
* @precision medium
7+
* @problem.severity error
8+
* @tags stuff
9+
*/
10+
11+
import cpp
12+
13+
from Expr e
14+
select e, "Replace this with your query."

example/cpp/stuff/src/qlpack.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: qlt55/stuff
2+
version: 0.0.0
3+
description: Default description
4+
suites:
5+
license:
6+
dependencies:
7+
codeql/cpp-all: 0.3.5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// replace with your test file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// not implemented
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TestQuery/TestQuery.ql

example/cpp/stuff/test/qlpack.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: qlt55/stuff-tests
2+
version: 0.0.0
3+
description: Default description
4+
suites:
5+
license:
6+
extractor: cpp
7+
dependencies:
8+
qlt55/stuff: '*'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @id cpp/stuff2/TestQuery
3+
* @name TestQuery
4+
* @description Replace this text with a description of your query.
5+
* @kind problem
6+
* @precision medium
7+
* @problem.severity error
8+
* @tags stuff2
9+
*/
10+
11+
import cpp
12+
13+
from Expr e
14+
select e, "Replace this with your query."

example/cpp/stuff2/src/qlpack.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: qlt2/stuff2
2+
version: 0.0.0
3+
description: Default description
4+
suites:
5+
license:
6+
dependencies:
7+
codeql/cpp-all: 0.3.5
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// replace with your test file

0 commit comments

Comments
 (0)