1- name : Build CodeQL for CodeQL
1+ name : Run CodeQL for CodeQL
22
33on :
44 push :
55 branches : [main]
66 pull_request :
77 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
148
159env :
1610 CARGO_TERM_COLOR : always
@@ -43,18 +37,11 @@ jobs:
4337 extractors :
4438 strategy :
4539 fail-fast : false
46- matrix :
47- os : ${{ fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]') }}
4840
49- runs-on : ${{ matrix.os }}
41+ runs-on : ubuntu-latest
5042
5143 steps :
5244 - 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
5845 - uses : actions/cache@v2
5946 with :
6047 path : |
@@ -71,11 +58,10 @@ jobs:
7158 - name : Release build
7259 run : cd ql; cargo build --release
7360 - name : Generate dbscheme
74- if : ${{ matrix.os == 'ubuntu-latest' }}
7561 run : ql/target/release/ql-generator --dbscheme ql/ql/src/ql.dbscheme --library ql/ql/src/codeql_ql/ast/internal/TreeSitter.qll
7662 - uses : actions/upload-artifact@v2
7763 with :
78- name : extractor-${{ matrix.os }}
64+ name : extractor-ubuntu-latest
7965 path : |
8066 ql/target/release/ql-extractor
8167 ql/target/release/ql-extractor.exe
@@ -94,39 +80,73 @@ jobs:
9480 name : query-pack-zip
9581 path : query-pack-zip
9682 - uses : actions/download-artifact@v2
97- if : ${{ contains(fromJson(inputs.os || '["ubuntu-latest", "macos-latest", "windows-latest"]'), 'ubuntu-latest') }}
9883 with :
9984 name : extractor-ubuntu-latest
10085 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
11186 - run : |
11287 unzip query-pack-zip/*.zip -d pack
11388 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
11590 if [[ -f linux64/ql-extractor ]]; then
11691 cp linux64/ql-extractor pack/tools/linux64/extractor
11792 chmod +x pack/tools/linux64/extractor
11893 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
12694 cd pack
12795 zip -rq ../codeql-ql.zip .
12896 - uses : actions/upload-artifact@v2
12997 with :
13098 name : codeql-ql-pack
13199 path : codeql-ql.zip
132100 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