Skip to content

Commit 5d81542

Browse files
committed
fix: update CI script
1 parent 6143756 commit 5d81542

5 files changed

Lines changed: 68 additions & 3 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
echo "Adding $CODEQL_DIR to PATH"
3131
- name: Test
3232
run: |
33-
./check.sh
33+
./scripts/ci.sh
3434
- name: Setup tmate session # see https://github.com/mxschmitt/action-tmate#only-on-failure
3535
uses: mxschmitt/action-tmate@v3
3636
if: ${{ failure() }}

ci/build/malloc_test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cd $REPO_DIR
3+
go test -c -a .

ci/extgens/malloc_test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
cd $REPO_DIR
3+
go test -c -a -gcflags=-m=2 . &> $OUTPUT_DIR/m2.log
4+
go test -run ^$ -bench . -cpuprofile $OUTPUT_DIR/cpu.out -memprofile $OUTPUT_DIR/mem.out &> $OUTPUT_DIR/bench.log
5+
cd $PROJROOT
6+
go run ./cmd/escape_adapter -dir $DB_EXT_DIR -src=$REPO_DIR -movedToHeap -newEscapesToHeap $OUTPUT_DIR/m2.log
7+
go run ./cmd/pprof2qlcsv/ -dir $DB_EXT_DIR $OUTPUT_DIR/cpu.out
8+
9+
# queryLine for malloc written as external predicates
10+
# it only applies to go1.24.2. Different go version may have different lines
11+
cat <<EOF > $DB_EXT_DIR/queryLine.csv
12+
runtime.mallocgcTiny,1102,"mp := acquirem"
13+
runtime.mallocgc,1060,"x, elemsize = mallocgcSmallScanNoHeader(size, typ, needzero)"
14+
runtime.mallocgc,1049,"// Actually do the allocation."
15+
EOF

ci/malloc_test.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
logRoot: logs
2+
repoRoot: repos # repoRoot stores all repositories
3+
dbRoot: codeql-db # dbRoot stores all databases created by codeql indexed by repository name
4+
5+
# clone
6+
sources:
7+
- prefix: https://test/ # clone url prefix
8+
fullnames:
9+
- malloc_test
10+
- batchmalloc
11+
12+
# build
13+
language: go # language to analyze
14+
buildTimeout: 3600 # timeout for building repository
15+
buildGrps:
16+
- buildRepos: # "*" means all repositories. "-" means repositories defined in "sources" attribute. You can also specify fullname of repositories to force re-build. Note that repositories with same fullname in different source will be re-built also.
17+
- malloc_test
18+
buildCmd: ci/build/malloc_test.sh
19+
extgenScript: ci/extgens/malloc_test.sh
20+
- buildRepos:
21+
- batchmalloc
22+
extgenScript: ci/extgens/batchmalloc.sh
23+
24+
# query
25+
queryconfig:
26+
resultRoot: codeqlResult # resultRoot stores all query results. Example: <resultRoot>/<path/to/query>/<repo>.csv
27+
parallelCore: 20 # parallel cores to run query
28+
queryRoot: qlsrc # query root. There should be codeql-pack.yaml in queryRoot directory
29+
queryGrps:
30+
- queryDBs:
31+
- batchmalloc
32+
queries:
33+
- escape_ext/new_expr_escapes_to_heap_test.ql
34+
- escape_ext/malloc_test.ql
35+
externalFiles:
36+
- yaml-template/escape.yaml
37+
- queryDBs:
38+
- malloc_test
39+
queries:
40+
- pprof_ext/malloc_time.ql
41+
- pprof_ext/malloc_line.ql
42+
externals:
43+
- queryLine
44+
externalFiles:
45+
- yaml-template/pprof.yaml
46+

check.sh renamed to scripts/ci.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash -x
2+
## Run in project root
23

34
function splitline {
45
echo "-----------------"
@@ -20,7 +21,7 @@ fi
2021
splitline
2122
echo "External Verify Test"
2223

23-
go run ./cmd/batch_clone_build yaml-examples/malloc_test.yaml
24+
go run ./cmd/batch_clone_build ci/malloc_test.yaml
2425
# check number of lines in pprof ext csv file is equal to count of external predicates
2526
if ! go run ./cmd/pprof-external-verify codeql-db/malloc_test/ use_ext_directly_count ; then
2627
echo "External Verify Test(use_ext_directly_count) for malloc_test Failed"
@@ -32,7 +33,7 @@ if ! go run ./cmd/pprof-external-verify codeql-db/malloc_test/ instance_count ;
3233
exit 1
3334
fi
3435

35-
go run ./cmd/codeql_qdriver -collect yaml-examples/malloc_test.yaml
36+
go run ./cmd/codeql_qdriver -collect ci/malloc_test.yaml
3637
# check mallocgc time is mapped to CodeQL class instances
3738
malloc_time_csv="codeqlResult/pprof_ext/malloc_time/malloc_test.csv"
3839
if [ ! -f "$malloc_time_csv" ]; then

0 commit comments

Comments
 (0)