@@ -27,31 +27,37 @@ jobs:
27
27
shell : bash
28
28
env :
29
29
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') }}
30
36
- name : Cache queries
37
+ if : steps.cache-pack.outputs.cache-hit != 'true'
31
38
id : cache-queries
32
39
uses : actions/cache@v3
33
40
with :
34
- path : ${{ runner.temp }}/query-pack.zip
41
+ path : ${{ runner.temp }}/queries
35
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') }}
36
43
- 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'
38
45
run : |
39
46
cd ql/ql/src
40
47
"${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
44
49
env :
45
50
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
+
53
58
# ## Build the extractor ###
54
59
- name : Cache entire extractor
60
+ if : steps.cache-pack.outputs.cache-hit != 'true'
55
61
id : cache-extractor
56
62
uses : actions/cache@v3
57
63
with :
62
68
ql/target/release/ql-extractor.exe
63
69
key : ${{ runner.os }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
64
70
- 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'
66
72
uses : actions/cache@v3
67
73
with :
68
74
path : |
@@ -71,73 +77,35 @@ jobs:
71
77
ql/target
72
78
key : ${{ runner.os }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
73
79
- 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'
75
81
run : cd ql; cargo fmt --all -- --check
76
82
- 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'
78
84
run : cd ql; cargo build --verbose
79
85
- 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'
81
87
run : cd ql; cargo test --verbose
82
88
- 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'
84
90
run : cd ql; cargo build --release
85
91
- 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'
87
93
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
97
94
98
95
# ## 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'
136
98
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
138
105
env :
139
- PACK_ARTIFACT : ${{ runner.temp }}/codeql-ql-pack-artifact
140
106
PACK : ${{ runner.temp }}/pack
107
+
108
+ # ## Run the analysis ###
141
109
- name : Hack codeql-action options
142
110
run : |
143
111
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