@@ -22,144 +22,54 @@ jobs:
2222 steps :
2323 # ## Build the queries ###
2424 - uses : actions/checkout@v3
25- - name : Find latest bundle
26- id : find-latest-bundle
27- uses : ./.github/actions/find-latest-bundle
2825 - name : Find codeql
2926 id : find-codeql
30- uses : github/codeql-action/init@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
27+ uses : github/codeql-action/init@v2
3128 with :
3229 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 }}
4130 - uses : ./.github/actions/os-version
4231 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-
7132 # ## Build the extractor ###
7233 - name : Cache entire extractor
73- if : steps.cache-pack.outputs.cache-hit != 'true'
7434 id : cache-extractor
7535 uses : actions/cache@v3
7636 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/
8238 key : ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
8339 - 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'
8541 uses : actions/cache@v3
8642 with :
8743 path : |
8844 ~/.cargo/registry
8945 ~/.cargo/git
9046 ql/target
9147 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
10148 - 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
13951 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
14959 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
15670 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
16373 - name : Sarif as artifact
16474 uses : actions/upload-artifact@v3
16575 with :
0 commit comments