@@ -48,42 +48,50 @@ jobs:
4848 run : |
4949 brew install gnu-tar
5050 echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
51+ - name : Install cargo-cross
52+ if : runner.os == 'Linux'
53+ run : cargo install cross --version 0.2.1
5154 - uses : ./.github/actions/os-version
5255 id : os_version
5356 - name : Cache entire extractor
5457 uses : actions/cache@v3
5558 id : cache-extractor
5659 with :
5760 path : |
58- ruby/target/release/ruby- autobuilder
59- ruby/target/release/ruby- autobuilder.exe
60- ruby/target/release/ruby- extractor
61- ruby/target/release/ruby- extractor.exe
62- ruby/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
63- key : ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/** /Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }}
61+ ruby/extractor/ target/release/autobuilder
62+ ruby/extractor/ target/release/autobuilder.exe
63+ ruby/extractor/ target/release/extractor
64+ ruby/extractor/ target/release/extractor.exe
65+ ruby/extractor/ ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
66+ key : ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/extractor/ rust-toolchain.toml', 'ruby/extractor /Cargo.lock') }}--${{ hashFiles('ruby/extractor /**/*.rs') }}
6467 - uses : actions/cache@v3
6568 if : steps.cache-extractor.outputs.cache-hit != 'true'
6669 with :
6770 path : |
6871 ~/.cargo/registry
6972 ~/.cargo/git
7073 ruby/target
71- key : ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
74+ key : ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/extractor/ rust-toolchain.toml', 'ruby/extractor /**/Cargo.lock') }}
7275 - name : Check formatting
7376 if : steps.cache-extractor.outputs.cache-hit != 'true'
74- run : cargo fmt --all -- --check
77+ run : cd extractor && cargo fmt --all -- --check
7578 - name : Build
7679 if : steps.cache-extractor.outputs.cache-hit != 'true'
77- run : cargo build --verbose
80+ run : cd extractor && cargo build --verbose
7881 - name : Run tests
7982 if : steps.cache-extractor.outputs.cache-hit != 'true'
80- run : cargo test --verbose
81- - name : Release build
82- if : steps.cache-extractor.outputs.cache-hit != 'true'
83- run : cargo build --release
83+ run : cd extractor && cargo test --verbose
84+ # On linux, build the extractor via cross in a centos7 container.
85+ # This ensures we don't depend on glibc > 2.17.
86+ - name : Release build (linux)
87+ if : steps.cache-extractor.outputs.cache-hit != 'true' && runner.os == 'Linux'
88+ run : cd extractor && cross build --release
89+ - name : Release build (windows and macos)
90+ if : steps.cache-extractor.outputs.cache-hit != 'true' && runner.os != 'Linux'
91+ run : cd extractor && cargo build --release
8492 - name : Generate dbscheme
8593 if : ${{ matrix.os == 'ubuntu-latest' && steps.cache-extractor.outputs.cache-hit != 'true'}}
86- run : target/release/ruby- generator --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
94+ run : extractor/ target/release/generator --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
8795 - uses : actions/upload-artifact@v3
8896 if : ${{ matrix.os == 'ubuntu-latest' }}
8997 with :
@@ -98,10 +106,10 @@ jobs:
98106 with :
99107 name : extractor-${{ matrix.os }}
100108 path : |
101- ruby/target/release/ruby- autobuilder
102- ruby/target/release/ruby- autobuilder.exe
103- ruby/target/release/ruby- extractor
104- ruby/target/release/ruby- extractor.exe
109+ ruby/extractor/ target/release/autobuilder
110+ ruby/extractor/ target/release/autobuilder.exe
111+ ruby/extractor/ target/release/extractor
112+ ruby/extractor/ target/release/extractor.exe
105113 retention-days : 1
106114 compile-queries :
107115 runs-on : ubuntu-latest-xl
@@ -116,21 +124,22 @@ jobs:
116124 key : ruby-build
117125 - name : Build Query Pack
118126 run : |
119- rm -rf target/packs
120- codeql pack create ../misc/suite-helpers --output target/packs
121- codeql pack create ../shared/regex --output target/packs
122- codeql pack create ../shared/ssa --output target/packs
123- codeql pack create ../shared/tutorial --output target/packs
124- codeql pack create ql/lib --output target/packs
125- codeql pack create -j0 ql/src --output target/packs --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
126- PACK_FOLDER=$(readlink -f target/packs/codeql/ruby-queries/*)
127+ PACKS=${{ runner.temp }}/query-packs
128+ rm -rf $PACKS
129+ codeql pack create ../misc/suite-helpers --output "$PACKS"
130+ codeql pack create ../shared/regex --output "$PACKS"
131+ codeql pack create ../shared/ssa --output "$PACKS"
132+ codeql pack create ../shared/tutorial --output "$PACKS"
133+ codeql pack create ql/lib --output "$PACKS"
134+ codeql pack create -j0 ql/src --output "$PACKS" --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
135+ PACK_FOLDER=$(readlink -f "$PACKS"/codeql/ruby-queries/*)
127136 codeql generate query-help --format=sarifv2.1.0 --output="${PACK_FOLDER}/rules.sarif" ql/src
128137 (cd ql/src; find queries \( -name '*.qhelp' -o -name '*.rb' -o -name '*.erb' \) -exec bash -c 'mkdir -p "'"${PACK_FOLDER}"'/$(dirname "{}")"' \; -exec cp "{}" "${PACK_FOLDER}/{}" \;)
129138 - uses : actions/upload-artifact@v3
130139 with :
131140 name : codeql-ruby-queries
132141 path : |
133- ruby/target/ packs/*
142+ ${{ runner.temp }}/query- packs/*
134143 retention-days : 1
135144
136145 package :
@@ -158,12 +167,12 @@ jobs:
158167 mkdir -p ruby
159168 cp -r codeql-extractor.yml tools ql/lib/ruby.dbscheme.stats ruby/
160169 mkdir -p ruby/tools/{linux64,osx64,win64}
161- cp linux64/ruby- autobuilder ruby/tools/linux64/autobuilder
162- cp osx64/ruby- autobuilder ruby/tools/osx64/autobuilder
163- cp win64/ruby- autobuilder.exe ruby/tools/win64/autobuilder.exe
164- cp linux64/ruby- extractor ruby/tools/linux64/extractor
165- cp osx64/ruby- extractor ruby/tools/osx64/extractor
166- cp win64/ruby- extractor.exe ruby/tools/win64/extractor.exe
170+ cp linux64/autobuilder ruby/tools/linux64/autobuilder
171+ cp osx64/autobuilder ruby/tools/osx64/autobuilder
172+ cp win64/autobuilder.exe ruby/tools/win64/autobuilder.exe
173+ cp linux64/extractor ruby/tools/linux64/extractor
174+ cp osx64/extractor ruby/tools/osx64/extractor
175+ cp win64/extractor.exe ruby/tools/win64/extractor.exe
167176 chmod +x ruby/tools/{linux64,osx64}/{autobuilder,extractor}
168177 zip -rq codeql-ruby.zip ruby
169178 - uses : actions/upload-artifact@v3
@@ -226,3 +235,54 @@ jobs:
226235 shell : bash
227236 run : |
228237 codeql database analyze --search-path "${{ runner.temp }}/ruby-bundle" --format=sarifv2.1.0 --output=out.sarif ../database ruby-code-scanning.qls
238+
239+ # This is a copy of the 'test' job that runs in a centos7 container.
240+ # This tests that the extractor works correctly on systems with an old glibc.
241+ test-centos7 :
242+ defaults :
243+ run :
244+ working-directory : ${{ github.workspace }}
245+ strategy :
246+ fail-fast : false
247+ runs-on : ubuntu-latest
248+ container :
249+ image : centos:centos7
250+ env :
251+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
252+ needs : [package]
253+ steps :
254+ - name : Install gh cli
255+ run : |
256+ yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
257+ # fetch-codeql requires unzip and jq
258+ # jq is available in epel-release (https://docs.fedoraproject.org/en-US/epel/)
259+ yum install -y gh unzip epel-release
260+ yum install -y jq
261+ - uses : actions/checkout@v3
262+ - name : Fetch CodeQL
263+ uses : ./.github/actions/fetch-codeql
264+
265+ # Due to a bug in Actions, we can't use runner.temp in the run blocks here.
266+ # https://github.com/actions/runner/issues/2185
267+
268+ - name : Download Ruby bundle
269+ uses : actions/download-artifact@v3
270+ with :
271+ name : codeql-ruby-bundle
272+ path : ${{ runner.temp }}
273+ - name : Unzip Ruby bundle
274+ shell : bash
275+ run : unzip -q -d "$RUNNER_TEMP"/ruby-bundle "$RUNNER_TEMP"/codeql-ruby-bundle.zip
276+
277+ - name : Run QL test
278+ shell : bash
279+ run : |
280+ codeql test run --search-path "$RUNNER_TEMP"/ruby-bundle --additional-packs "$RUNNER_TEMP"/ruby-bundle ruby/ql/test/library-tests/ast/constants/
281+ - name : Create database
282+ shell : bash
283+ run : |
284+ codeql database create --search-path "$RUNNER_TEMP"/ruby-bundle --language ruby --source-root ruby/ql/test/library-tests/ast/constants/ ../database
285+ - name : Analyze database
286+ shell : bash
287+ run : |
288+ codeql database analyze --search-path "$RUNNER_TEMP"/ruby-bundle --format=sarifv2.1.0 --output=out.sarif ../database ruby-code-scanning.qls
0 commit comments