@@ -27,31 +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
41+ path : ${{ runner.temp }}/queries
3542 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
4047 "${CODEQL}" pack create -j 16
41- cd .codeql/pack/codeql/ql/0.0.0
42- zip "${PACKZIP}" -r .
43- rm -rf *
48+ mv .codeql/pack/codeql/ql/0.0.0 ${{ runner.temp }}/queries
4449 env :
4550 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
52-
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+
5358 # ## Build the extractor ###
5459 - name : Cache entire extractor
60+ if : steps.cache-pack.outputs.cache-hit != 'true'
5561 id : cache-extractor
5662 uses : actions/cache@v3
5763 with :
6268 ql/target/release/ql-extractor.exe
6369 key : ${{ runner.os }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
6470 - name : Cache cargo
65- if : steps.cache-extractor.outputs.cache-hit != 'true'
71+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
6672 uses : actions/cache@v3
6773 with :
6874 path : |
@@ -71,73 +77,35 @@ jobs:
7177 ql/target
7278 key : ${{ runner.os }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
7379 - name : Check formatting
74- if : steps.cache-extractor.outputs.cache-hit != 'true'
80+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
7581 run : cd ql; cargo fmt --all -- --check
7682 - name : Build
77- if : steps.cache-extractor.outputs.cache-hit != 'true'
83+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
7884 run : cd ql; cargo build --verbose
7985 - name : Run tests
80- if : steps.cache-extractor.outputs.cache-hit != 'true'
86+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8187 run : cd ql; cargo test --verbose
8288 - name : Release build
83- if : steps.cache-extractor.outputs.cache-hit != 'true'
89+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8490 run : cd ql; cargo build --release
8591 - name : Generate dbscheme
86- if : steps.cache-extractor.outputs.cache-hit != 'true'
92+ if : steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8793 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
9794
9895 # ## 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
96+ - name : Package pack
97+ if : steps.cache-pack.outputs.cache-hit != 'true'
13698 run : |
137- 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
138105 env :
139- PACK_ARTIFACT : ${{ runner.temp }}/codeql-ql-pack-artifact
140106 PACK : ${{ runner.temp }}/pack
107+
108+ # ## Run the analysis ###
141109 - name : Hack codeql-action options
142110 run : |
143111 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]')
0 commit comments