55 branches : [main]
66 pull_request :
77 branches : [main]
8+ paths :
9+ - " ql/**"
10+ - " **.qll"
11+ - " **.ql"
12+ - " **.dbscheme"
13+ - " **/qlpack.yml"
14+ - " .github/workflows/ql-for-ql-build.yml"
815
916env :
1017 CARGO_TERM_COLOR : always
1724 - uses : actions/checkout@v3
1825 - name : Find codeql
1926 id : find-codeql
20- uses : github/codeql-action/init@aa93aea877e5fb8841bcb1193f672abf6e9f2980
27+ uses : github/codeql-action/init@71a8b35ff4c80fcfcd05bc1cd932fe3c08f943ca
2128 with :
2229 languages : javascript # does not matter
2330 - name : Get CodeQL version
@@ -27,31 +34,37 @@ jobs:
2734 shell : bash
2835 env :
2936 CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
37+ - name : Cache entire pack
38+ id : cache-pack
39+ uses : actions/cache@v3
40+ with :
41+ path : ${{ runner.temp }}/pack
42+ key : ${{ runner.os }}-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') }}
3043 - name : Cache queries
44+ if : steps.cache-pack.outputs.cache-hit != 'true'
3145 id : cache-queries
3246 uses : actions/cache@v3
3347 with :
34- path : ${{ runner.temp }}/query-pack.zip
35- key : queries-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}
48+ path : ${{ runner.temp }}/queries
49+ 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') }}
3650 - name : Build query pack
37- if : steps.cache-queries.outputs.cache-hit != 'true'
51+ if : steps.cache-queries.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
3852 run : |
3953 cd ql/ql/src
40- "${CODEQL}" pack create
41- cd .codeql/pack/codeql/ql/0.0.0
42- zip "${PACKZIP}" -r .
43- rm -rf *
54+ "${CODEQL}" pack create -j 16
55+ mv .codeql/pack/codeql/ql/0.0.0 ${{ runner.temp }}/queries
56+ env :
57+ CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
58+ - name : Move cache queries to pack
59+ if : steps.cache-pack.outputs.cache-hit != 'true'
60+ run : |
61+ cp -r ${{ runner.temp }}/queries ${{ runner.temp }}/pack
4462 env :
4563 CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
46- PACKZIP : ${{ runner.temp }}/query-pack.zip
47- - name : Upload query pack
48- uses : actions/upload-artifact@v3
49- with :
50- name : query-pack-zip
51- path : ${{ runner.temp }}/query-pack.zip
5264
5365 # ## Build the extractor ###
5466 - name : Cache entire extractor
67+ if : steps.cache-pack.outputs.cache-hit != 'true'
5568 id : cache-extractor
5669 uses : actions/cache@v3
5770 with :
6275 ql/target/release/ql-extractor.exe
6376 key : ${{ runner.os }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
6477 - name : Cache cargo
65- if : steps.cache-extractor.outputs.cache-hit != 'true'
78+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
6679 uses : actions/cache@v3
6780 with :
6881 path : |
@@ -71,108 +84,75 @@ jobs:
7184 ql/target
7285 key : ${{ runner.os }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
7386 - name : Check formatting
74- if : steps.cache-extractor.outputs.cache-hit != 'true'
87+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
7588 run : cd ql; cargo fmt --all -- --check
7689 - name : Build
77- if : steps.cache-extractor.outputs.cache-hit != 'true'
90+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
7891 run : cd ql; cargo build --verbose
7992 - name : Run tests
80- if : steps.cache-extractor.outputs.cache-hit != 'true'
93+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8194 run : cd ql; cargo test --verbose
8295 - name : Release build
83- if : steps.cache-extractor.outputs.cache-hit != 'true'
96+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8497 run : cd ql; cargo build --release
8598 - name : Generate dbscheme
86- if : steps.cache-extractor.outputs.cache-hit != 'true'
99+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
87100 run : ql/target/release/ql-generator --dbscheme ql/ql/src/ql.dbscheme --library ql/ql/src/codeql_ql/ast/internal/TreeSitter.qll
88- - uses : actions/upload-artifact@v3
89- with :
90- name : extractor-ubuntu-latest
91- path : |
92- ql/target/release/ql-autobuilder
93- ql/target/release/ql-autobuilder.exe
94- ql/target/release/ql-extractor
95- ql/target/release/ql-extractor.exe
96- retention-days : 1
97101
98102 # ## Package the queries and extractor ###
99- - uses : actions/download-artifact@v3
100- with :
101- name : query-pack-zip
102- path : query-pack-zip
103- - uses : actions/download-artifact@v3
104- with :
105- name : extractor-ubuntu-latest
106- path : linux64
107- - run : |
108- unzip query-pack-zip/*.zip -d pack
109- cp -r ql/codeql-extractor.yml ql/tools ql/ql/src/ql.dbscheme.stats pack/
110- mkdir -p pack/tools/linux64
111- if [[ -f linux64/ql-autobuilder ]]; then
112- cp linux64/ql-autobuilder pack/tools/linux64/autobuilder
113- chmod +x pack/tools/linux64/autobuilder
114- fi
115- if [[ -f linux64/ql-extractor ]]; then
116- cp linux64/ql-extractor pack/tools/linux64/extractor
117- chmod +x pack/tools/linux64/extractor
118- fi
119- cd pack
120- zip -rq ../codeql-ql.zip .
121- rm -rf *
122- - uses : actions/upload-artifact@v3
123- with :
124- name : codeql-ql-pack
125- path : codeql-ql.zip
126- retention-days : 1
127-
128- # ## Run the analysis ###
129- - name : Download pack
130- uses : actions/download-artifact@v3
131- with :
132- name : codeql-ql-pack
133- path : ${{ runner.temp }}/codeql-ql-pack-artifact
134-
135- - name : Prepare pack
103+ - name : Package pack
104+ if : steps.cache-pack.outputs.cache-hit != 'true'
136105 run : |
137- unzip "${PACK_ARTIFACT}/*.zip" -d "${PACK}"
106+ cp -r ql/codeql-extractor.yml ql/tools ql/ql/src/ql.dbscheme.stats ${PACK}/
107+ mkdir -p ${PACK}/tools/linux64
108+ cp ql/target/release/ql-autobuilder ${PACK}/tools/linux64/autobuilder
109+ cp ql/target/release/ql-extractor ${PACK}/tools/linux64/extractor
110+ chmod +x ${PACK}/tools/linux64/autobuilder
111+ chmod +x ${PACK}/tools/linux64/extractor
138112 env :
139- PACK_ARTIFACT : ${{ runner.temp }}/codeql-ql-pack-artifact
140113 PACK : ${{ runner.temp }}/pack
114+
115+ # ## Run the analysis ###
141116 - name : Hack codeql-action options
142117 run : |
143- JSON=$(jq -nc --arg pack "${PACK}" '.database."run-queries"=["--search-path", $pack] | .resolve.queries=["--search-path", $pack] | .resolve.extractor=["--search-path", $pack] | .database.init=["--search-path", $pack]')
118+ 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]')
144119 echo "CODEQL_ACTION_EXTRA_OPTIONS=${JSON}" >> ${GITHUB_ENV}
145120 env :
146121 PACK : ${{ runner.temp }}/pack
147122
148123 - name : Create CodeQL config file
149124 run : |
150125 echo "paths-ignore:" >> ${CONF}
151- echo " - ql/ql/test" >> ${CONF}
152- echo " - \"*/ql/lib/upgrades/\"" >> ${CONF}
126+ echo " - ql/ql/test" >> ${CONF}
127+ echo " - \"*/ql/lib/upgrades/\"" >> ${CONF}
153128 echo "disable-default-queries: true" >> ${CONF}
154- echo "packs :" >> ${CONF}
155- echo " - codeql/ql" >> ${CONF}
129+ echo "queries :" >> ${CONF}
130+ echo " - uses: ./ql/ql/src/ codeql-suites /ql-code-scanning.qls " >> ${CONF}
156131 echo "Config file: "
157132 cat ${CONF}
158- env :
133+ env :
159134 CONF : ./ql-for-ql-config.yml
160135 - name : Initialize CodeQL
161- uses : github/codeql-action/init@aa93aea877e5fb8841bcb1193f672abf6e9f2980
136+ uses : github/codeql-action/init@71a8b35ff4c80fcfcd05bc1cd932fe3c08f943ca
162137 with :
163138 languages : ql
164139 db-location : ${{ runner.temp }}/db
165140 config-file : ./ql-for-ql-config.yml
141+ - name : Move pack cache
142+ run : |
143+ cp -r ${PACK}/.cache ql/ql/src/.cache
144+ env :
145+ PACK : ${{ runner.temp }}/pack
166146
167147 - name : Perform CodeQL Analysis
168- uses : github/codeql-action/analyze@aa93aea877e5fb8841bcb1193f672abf6e9f2980
169- with :
148+ uses : github/codeql-action/analyze@71a8b35ff4c80fcfcd05bc1cd932fe3c08f943ca
149+ with :
170150 category : " ql-for-ql"
171151 - name : Copy sarif file to CWD
172152 run : cp ../results/ql.sarif ./ql-for-ql.sarif
173153 - name : Fixup the $scema in sarif # Until https://github.com/microsoft/sarif-vscode-extension/pull/436/ is part in a stable release
174154 run : |
175- sed -i 's/\$schema.*/\$schema": "https:\/\/raw.githubusercontent.com\/oasis-tcs\/sarif-spec\/master\/Schemata\/sarif-schema-2.1.0",/' ql-for-ql.sarif
155+ sed -i 's/\$schema.*/\$schema": "https:\/\/raw.githubusercontent.com\/oasis-tcs\/sarif-spec\/master\/Schemata\/sarif-schema-2.1.0",/' ql-for-ql.sarif
176156 - name : Sarif as artifact
177157 uses : actions/upload-artifact@v3
178158 with :
0 commit comments