1
- name : Build CodeQL for CodeQL
1
+ name : Run CodeQL for CodeQL
2
2
3
3
on :
4
4
push :
5
5
branches : [main]
6
6
pull_request :
7
7
branches : [main]
8
- workflow_call :
9
- inputs :
10
- os :
11
- description : A JSON array string of (fixed) operating systems to build for, e.g. '["ubuntu-latest", "macos-latest", "windows-latest"]'
12
- required : false
13
- type : string
14
8
15
9
env :
16
10
CARGO_TERM_COLOR : always
@@ -43,18 +37,11 @@ jobs:
43
37
extractors :
44
38
strategy :
45
39
fail-fast : false
46
- matrix :
47
- os : ${{ fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]') }}
48
40
49
- runs-on : ${{ matrix.os }}
41
+ runs-on : ubuntu-latest
50
42
51
43
steps :
52
44
- uses : actions/checkout@v2
53
- - name : Install GNU tar
54
- if : runner.os == 'macOS'
55
- run : |
56
- brew install gnu-tar
57
- echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
58
45
- uses : actions/cache@v2
59
46
with :
60
47
path : |
@@ -71,11 +58,10 @@ jobs:
71
58
- name : Release build
72
59
run : cd ql; cargo build --release
73
60
- name : Generate dbscheme
74
- if : ${{ matrix.os == 'ubuntu-latest' }}
75
61
run : ql/target/release/ql-generator --dbscheme ql/ql/src/ql.dbscheme --library ql/ql/src/codeql_ql/ast/internal/TreeSitter.qll
76
62
- uses : actions/upload-artifact@v2
77
63
with :
78
- name : extractor-${{ matrix.os }}
64
+ name : extractor-ubuntu-latest
79
65
path : |
80
66
ql/target/release/ql-extractor
81
67
ql/target/release/ql-extractor.exe
@@ -94,39 +80,73 @@ jobs:
94
80
name : query-pack-zip
95
81
path : query-pack-zip
96
82
- uses : actions/download-artifact@v2
97
- if : ${{ contains(fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]'), 'ubuntu-latest') }}
98
83
with :
99
84
name : extractor-ubuntu-latest
100
85
path : linux64
101
- - uses : actions/download-artifact@v2
102
- if : ${{ contains(fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]'), 'windows-latest') }}
103
- with :
104
- name : extractor-windows-latest
105
- path : win64
106
- - uses : actions/download-artifact@v2
107
- if : ${{ contains(fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]'), 'macos-latest') }}
108
- with :
109
- name : extractor-macos-latest
110
- path : osx64
111
86
- run : |
112
87
unzip query-pack-zip/*.zip -d pack
113
88
cp -r ql/codeql-extractor.yml ql/tools ql/ql/src/ql.dbscheme.stats pack/
114
- mkdir -p pack/tools/{ linux64,osx64,win64}
89
+ mkdir -p pack/tools/linux64
115
90
if [[ -f linux64/ql-extractor ]]; then
116
91
cp linux64/ql-extractor pack/tools/linux64/extractor
117
92
chmod +x pack/tools/linux64/extractor
118
93
fi
119
- if [[ -f osx64/ql-extractor ]]; then
120
- cp osx64/ql-extractor pack/tools/osx64/extractor
121
- chmod +x pack/tools/osx64/extractor
122
- fi
123
- if [[ -f win64/ql-extractor.exe ]]; then
124
- cp win64/ql-extractor.exe pack/tools/win64/extractor
125
- fi
126
94
cd pack
127
95
zip -rq ../codeql-ql.zip .
128
96
- uses : actions/upload-artifact@v2
129
97
with :
130
98
name : codeql-ql-pack
131
99
path : codeql-ql.zip
132
100
retention-days : 1
101
+ analyze :
102
+ runs-on : ubuntu-latest
103
+
104
+ needs :
105
+ - package
106
+
107
+ steps :
108
+ - name : Download pack
109
+ uses : actions/download-artifact@v2
110
+ with :
111
+ name : codeql-ql-pack
112
+ path : ${{ runner.temp }}/codeql-ql-pack-artifact
113
+
114
+ - name : Prepare pack
115
+ run : |
116
+ unzip "${PACK_ARTIFACT}/*.zip" -d "${PACK}"
117
+ env :
118
+ PACK_ARTIFACT : ${{ runner.temp }}/codeql-ql-pack-artifact
119
+ PACK : ${{ runner.temp }}/pack
120
+ - name : Hack codeql-action options
121
+ run : |
122
+ JSON=$(jq -nc --arg pack "${PACK}" '.resolve.queries=["--search-path", $pack] | .resolve.extractor=["--search-path", $pack] | .database.init=["--search-path", $pack]')
123
+ echo "CODEQL_ACTION_EXTRA_OPTIONS=${JSON}" >> ${GITHUB_ENV}
124
+ env :
125
+ PACK : ${{ runner.temp }}/pack
126
+
127
+ - name : Checkout repository
128
+ uses : actions/checkout@v2
129
+
130
+ - name : Initialize CodeQL
131
+ uses : github/codeql-action/init@esbena/ql
132
+ with :
133
+ languages : ql
134
+ db-location : ${{ runner.temp }}/db
135
+ - name : Print debug info
136
+ run : |
137
+ echo "Pack"
138
+ ls ${{ runner.temp }}/pack
139
+ echo "Tools"
140
+ ls ${{ runner.temp }}/pack/tools
141
+ echo "index-files"
142
+ cat ${{ runner.temp }}/pack/tools/index-files.sh
143
+
144
+ - name : Perform CodeQL Analysis
145
+ uses : github/codeql-action/analyze@esbena/ql
146
+
147
+ - name : Upload db
148
+ uses : actions/upload-artifact@v2
149
+ with :
150
+ name : db
151
+ path : ${{ runner.temp }}/db
152
+ retention-days : 1
0 commit comments