@@ -22,144 +22,54 @@ jobs:
22
22
steps :
23
23
# ## Build the queries ###
24
24
- uses : actions/checkout@v3
25
- - name : Find latest bundle
26
- id : find-latest-bundle
27
- uses : ./.github/actions/find-latest-bundle
28
25
- name : Find codeql
29
26
id : find-codeql
30
- uses : github/codeql-action/init@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
27
+ uses : github/codeql-action/init@v2
31
28
with :
32
29
languages : javascript # does not matter
33
- tools : ${{ steps.find-latest-bundle.outputs.url }}
34
- - name : Get CodeQL version
35
- id : get-codeql-version
36
- run : |
37
- echo "version=$("${CODEQL}" --version | head -n 1 | rev | cut -d " " -f 1 | rev)" >> $GITHUB_OUTPUT
38
- shell : bash
39
- env :
40
- CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
41
30
- uses : ./.github/actions/os-version
42
31
id : os_version
43
- - name : Cache entire pack
44
- id : cache-pack
45
- uses : actions/cache@v3
46
- with :
47
- path : ${{ runner.temp }}/pack
48
- key : ${{ runner.os }}-${{ steps.os_version.outputs.version }}-pack-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }}
49
- - name : Cache queries
50
- if : steps.cache-pack.outputs.cache-hit != 'true'
51
- id : cache-queries
52
- uses : actions/cache@v3
53
- with :
54
- path : ${{ runner.temp }}/queries
55
- key : queries-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }}
56
- - name : Build query pack
57
- if : steps.cache-queries.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
58
- run : |
59
- cd ql/ql/src
60
- "${CODEQL}" pack create -j 16
61
- mv .codeql/pack/codeql/ql/0.0.0 ${{ runner.temp }}/queries
62
- env :
63
- CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
64
- - name : Move cache queries to pack
65
- if : steps.cache-pack.outputs.cache-hit != 'true'
66
- run : |
67
- cp -r ${{ runner.temp }}/queries ${{ runner.temp }}/pack
68
- env :
69
- CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
70
-
71
32
# ## Build the extractor ###
72
33
- name : Cache entire extractor
73
- if : steps.cache-pack.outputs.cache-hit != 'true'
74
34
id : cache-extractor
75
35
uses : actions/cache@v3
76
36
with :
77
- path : |
78
- ql/target/release/ql-autobuilder
79
- ql/target/release/ql-autobuilder.exe
80
- ql/target/release/ql-extractor
81
- ql/target/release/ql-extractor.exe
37
+ path : ql/extractor-pack/
82
38
key : ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
83
39
- name : Cache cargo
84
- if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
40
+ if : steps.cache-extractor.outputs.cache-hit != 'true'
85
41
uses : actions/cache@v3
86
42
with :
87
43
path : |
88
44
~/.cargo/registry
89
45
~/.cargo/git
90
46
ql/target
91
47
key : ${{ runner.os }}-${{ steps.os_version.outputs.version }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
92
- - name : Check formatting
93
- if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
94
- run : cd ql; cargo fmt --all -- --check
95
- - name : Build
96
- if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
97
- run : cd ql; cargo build --verbose
98
- - name : Run tests
99
- if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
100
- run : cd ql; cargo test --verbose
101
48
- name : Release build
102
- if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
103
- run : cd ql; cargo build --release
104
- - name : Generate dbscheme
105
- if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
106
- run : ql/target/release/ql-generator --dbscheme ql/ql/src/ql.dbscheme --library ql/ql/src/codeql_ql/ast/internal/TreeSitter.qll
107
-
108
- # ## Package the queries and extractor ###
109
- - name : Package pack
110
- if : steps.cache-pack.outputs.cache-hit != 'true'
111
- run : |
112
- cp -r ql/codeql-extractor.yml ql/tools ql/ql/src/ql.dbscheme.stats ${PACK}/
113
- mkdir -p ${PACK}/tools/linux64
114
- cp ql/target/release/ql-autobuilder ${PACK}/tools/linux64/autobuilder
115
- cp ql/target/release/ql-extractor ${PACK}/tools/linux64/extractor
116
- chmod +x ${PACK}/tools/linux64/autobuilder
117
- chmod +x ${PACK}/tools/linux64/extractor
118
- env :
119
- PACK : ${{ runner.temp }}/pack
120
-
121
- # ## Run the analysis ###
122
- - name : Hack codeql-action options
123
- run : |
124
- JSON=$(jq -nc --arg pack "${PACK}" '.database."run-queries"=["--search-path", $pack] | .resolve.queries=["--search-path", $pack] | .resolve.extractor=["--search-path", $pack] | .resolve.languages=["--search-path", $pack] | .database.init=["--search-path", $pack]')
125
- echo "CODEQL_ACTION_EXTRA_OPTIONS=${JSON}" >> ${GITHUB_ENV}
126
- env :
127
- PACK : ${{ runner.temp }}/pack
128
-
129
- - name : Create CodeQL config file
130
- run : |
131
- echo "paths-ignore:" >> ${CONF}
132
- echo " - ql/ql/test" >> ${CONF}
133
- echo " - \"*/ql/lib/upgrades/\"" >> ${CONF}
134
- echo "disable-default-queries: true" >> ${CONF}
135
- echo "queries:" >> ${CONF}
136
- echo " - uses: ./ql/ql/src/codeql-suites/ql-code-scanning.qls" >> ${CONF}
137
- echo "Config file: "
138
- cat ${CONF}
49
+ if : steps.cache-extractor.outputs.cache-hit != 'true'
50
+ run : cd ql; ./scripts/create-extractor-pack.sh
139
51
env :
140
- CONF : ./ql-for-ql-config.yml
141
- - name : Initialize CodeQL
142
- uses : github/codeql-action/init@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
143
- with :
144
- languages : ql
145
- db-location : ${{ runner.temp }}/db
146
- config-file : ./ql-for-ql-config.yml
147
- tools : ${{ steps.find-latest-bundle.outputs.url }}
148
- - name : Move pack queries
52
+ GH_TOKEN : ${{ github.token }}
53
+ - name : Cache compilation cache
54
+ id : query-cache
55
+ uses : ./.github/actions/cache-query-compilation
56
+ with :
57
+ key : run-ql-for-ql
58
+ - name : Make database and analyze
149
59
run : |
150
- cp -r ${PACK}/queries ql/ql/src
151
- env :
152
- PACK : ${{ runner.temp }}/pack
153
-
154
- - name : Perform CodeQL Analysis
155
- uses : github/codeql-action/analyze@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
60
+ ${CODEQL} database create -l=ql --search-path ql/extractor-pack ${DB}
61
+ ${CODEQL} database analyze -j0 --format=sarif-latest --output=ql-for-ql.sarif ${DB} ql/ql/src/codeql-suites/ql-code-scanning.qls --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
62
+ env :
63
+ CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
64
+ DB : ${{ runner.temp }}/DB
65
+ LGTM_INDEX_FILTERS : |
66
+ exclude:ql/ql/test
67
+ exclude:*/ql/lib/upgrades/
68
+ - name : Upload sarif to code-scanning
69
+ uses : github/codeql-action/upload-sarif@v2
156
70
with :
157
- category : " ql-for-ql"
158
- - name : Copy sarif file to CWD
159
- run : cp ../results/ql.sarif ./ql-for-ql.sarif
160
- - name : Fixup the $scema in sarif # Until https://github.com/microsoft/sarif-vscode-extension/pull/436/ is part in a stable release
161
- run : |
162
- sed -i 's/\$schema.*/\$schema": "https:\/\/raw.githubusercontent.com\/oasis-tcs\/sarif-spec\/master\/Schemata\/sarif-schema-2.1.0",/' ql-for-ql.sarif
71
+ sarif_file : ql-for-ql.sarif
72
+ category : ql-for-ql
163
73
- name : Sarif as artifact
164
74
uses : actions/upload-artifact@v3
165
75
with :
0 commit comments