1717 - uses : actions/checkout@v3
1818 - name : Find codeql
1919 id : find-codeql
20- uses : github/codeql-action/init@aa93aea877e5fb8841bcb1193f672abf6e9f2980
20+ uses : github/codeql-action/init@71a8b35ff4c80fcfcd05bc1cd932fe3c08f943ca
2121 with :
2222 languages : javascript # does not matter
2323 - name : Get CodeQL version
@@ -27,30 +27,37 @@ jobs:
2727 shell : bash
2828 env :
2929 CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
30+ - name : Cache entire pack
31+ id : cache-pack
32+ uses : actions/cache@v3
33+ with :
34+ path : ${{ runner.temp }}/pack
35+ 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') }}
3036 - name : Cache queries
37+ if : steps.cache-pack.outputs.cache-hit != 'true'
3138 id : cache-queries
3239 uses : actions/cache@v3
3340 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 }}
41+ path : ${{ runner.temp }}/queries
42+ 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') }}
3643 - name : Build query pack
37- if : steps.cache-queries.outputs.cache-hit != 'true'
44+ if : steps.cache-queries.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
3845 run : |
3946 cd ql/ql/src
40- "${CODEQL}" pack create
41- cd .codeql/pack/codeql/ql/0.0.0
42- zip "${PACKZIP}" -r .
47+ "${CODEQL}" pack create -j 16
48+ mv .codeql/pack/codeql/ql/0.0.0 ${{ runner.temp }}/queries
4349 env :
4450 CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
45- PACKZIP : ${{ runner.temp }}/query- pack.zip
46- - name : Upload query pack
47- uses : actions/upload-artifact@v3
48- with :
49- name : query-pack-zip
50- path : ${{ runner.temp }}/query-pack.zip
51-
51+ - name : Move cache queries to pack
52+ if : steps.cache-pack.outputs.cache-hit != 'true'
53+ run : |
54+ cp -r ${{ runner.temp }}/queries ${{ runner.temp }}/pack
55+ env :
56+ CODEQL : ${{ steps.find-codeql.outputs.codeql-path }}
57+
5258 # ## Build the extractor ###
5359 - name : Cache entire extractor
60+ if : steps.cache-pack.outputs.cache-hit != 'true'
5461 id : cache-extractor
5562 uses : actions/cache@v3
5663 with :
6168 ql/target/release/ql-extractor.exe
6269 key : ${{ runner.os }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
6370 - name : Cache cargo
64- if : steps.cache-extractor.outputs.cache-hit != 'true'
71+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
6572 uses : actions/cache@v3
6673 with :
6774 path : |
@@ -70,72 +77,35 @@ jobs:
7077 ql/target
7178 key : ${{ runner.os }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
7279 - name : Check formatting
73- if : steps.cache-extractor.outputs.cache-hit != 'true'
80+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
7481 run : cd ql; cargo fmt --all -- --check
7582 - name : Build
76- if : steps.cache-extractor.outputs.cache-hit != 'true'
83+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
7784 run : cd ql; cargo build --verbose
7885 - name : Run tests
79- if : steps.cache-extractor.outputs.cache-hit != 'true'
86+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8087 run : cd ql; cargo test --verbose
8188 - name : Release build
82- if : steps.cache-extractor.outputs.cache-hit != 'true'
89+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8390 run : cd ql; cargo build --release
8491 - name : Generate dbscheme
85- if : steps.cache-extractor.outputs.cache-hit != 'true'
92+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8693 run : ql/target/release/ql-generator --dbscheme ql/ql/src/ql.dbscheme --library ql/ql/src/codeql_ql/ast/internal/TreeSitter.qll
87- - uses : actions/upload-artifact@v3
88- with :
89- name : extractor-ubuntu-latest
90- path : |
91- ql/target/release/ql-autobuilder
92- ql/target/release/ql-autobuilder.exe
93- ql/target/release/ql-extractor
94- ql/target/release/ql-extractor.exe
95- retention-days : 1
9694
9795 # ## Package the queries and extractor ###
98- - uses : actions/download-artifact@v3
99- with :
100- name : query-pack-zip
101- path : query-pack-zip
102- - uses : actions/download-artifact@v3
103- with :
104- name : extractor-ubuntu-latest
105- path : linux64
106- - run : |
107- unzip query-pack-zip/*.zip -d pack
108- cp -r ql/codeql-extractor.yml ql/tools ql/ql/src/ql.dbscheme.stats pack/
109- mkdir -p pack/tools/linux64
110- if [[ -f linux64/ql-autobuilder ]]; then
111- cp linux64/ql-autobuilder pack/tools/linux64/autobuilder
112- chmod +x pack/tools/linux64/autobuilder
113- fi
114- if [[ -f linux64/ql-extractor ]]; then
115- cp linux64/ql-extractor pack/tools/linux64/extractor
116- chmod +x pack/tools/linux64/extractor
117- fi
118- cd pack
119- zip -rq ../codeql-ql.zip .
120- - uses : actions/upload-artifact@v3
121- with :
122- name : codeql-ql-pack
123- path : codeql-ql.zip
124- retention-days : 1
125-
126- # ## Run the analysis ###
127- - name : Download pack
128- uses : actions/download-artifact@v3
129- with :
130- name : codeql-ql-pack
131- path : ${{ runner.temp }}/codeql-ql-pack-artifact
132-
133- - name : Prepare pack
96+ - name : Package pack
97+ if : steps.cache-pack.outputs.cache-hit != 'true'
13498 run : |
135- unzip "${PACK_ARTIFACT}/*.zip" -d "${PACK}"
99+ cp -r ql/codeql-extractor.yml ql/tools ql/ql/src/ql.dbscheme.stats ${PACK}/
100+ mkdir -p ${PACK}/tools/linux64
101+ cp ql/target/release/ql-autobuilder ${PACK}/tools/linux64/autobuilder
102+ cp ql/target/release/ql-extractor ${PACK}/tools/linux64/extractor
103+ chmod +x ${PACK}/tools/linux64/autobuilder
104+ chmod +x ${PACK}/tools/linux64/extractor
136105 env :
137- PACK_ARTIFACT : ${{ runner.temp }}/codeql-ql-pack-artifact
138106 PACK : ${{ runner.temp }}/pack
107+
108+ # ## Run the analysis ###
139109 - name : Hack codeql-action options
140110 run : |
141111 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]')
@@ -149,21 +119,26 @@ jobs:
149119 echo " - ql/ql/test" >> ${CONF}
150120 echo " - \"*/ql/lib/upgrades/\"" >> ${CONF}
151121 echo "disable-default-queries: true" >> ${CONF}
152- echo "packs :" >> ${CONF}
153- echo " - codeql/ql" >> ${CONF}
122+ echo "queries :" >> ${CONF}
123+ echo " - uses: ./ql/ql/src/ codeql-suites /ql-code-scanning.qls " >> ${CONF}
154124 echo "Config file: "
155125 cat ${CONF}
156126 env :
157127 CONF : ./ql-for-ql-config.yml
158128 - name : Initialize CodeQL
159- uses : github/codeql-action/init@aa93aea877e5fb8841bcb1193f672abf6e9f2980
129+ uses : github/codeql-action/init@71a8b35ff4c80fcfcd05bc1cd932fe3c08f943ca
160130 with :
161131 languages : ql
162132 db-location : ${{ runner.temp }}/db
163133 config-file : ./ql-for-ql-config.yml
134+ - name : Move pack cache
135+ run : |
136+ cp -r ${PACK}/.cache ql/ql/src/.cache
137+ env :
138+ PACK : ${{ runner.temp }}/pack
164139
165140 - name : Perform CodeQL Analysis
166- uses : github/codeql-action/analyze@aa93aea877e5fb8841bcb1193f672abf6e9f2980
141+ uses : github/codeql-action/analyze@71a8b35ff4c80fcfcd05bc1cd932fe3c08f943ca
167142 with :
168143 category : " ql-for-ql"
169144 - name : Copy sarif file to CWD
0 commit comments