Skip to content

Commit 65d129d

Browse files
authored
Merge pull request github#12529 from hmac/ruby-extractor-bump-rust-version
Ruby: Bump rust toolchain to 1.68
2 parents 536bc9a + bed5eeb commit 65d129d

File tree

4 files changed

+66
-5
lines changed

4 files changed

+66
-5
lines changed

.github/workflows/ruby-build.yml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ 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
@@ -78,8 +81,13 @@ jobs:
7881
- name: Run tests
7982
if: steps.cache-extractor.outputs.cache-hit != 'true'
8083
run: cd extractor && cargo test --verbose
81-
- name: Release build
82-
if: steps.cache-extractor.outputs.cache-hit != 'true'
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'
8391
run: cd extractor && cargo build --release
8492
- name: Generate dbscheme
8593
if: ${{ matrix.os == 'ubuntu-latest' && steps.cache-extractor.outputs.cache-hit != 'true'}}
@@ -227,3 +235,54 @@ jobs:
227235
shell: bash
228236
run: |
229237
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

ruby/doc/HOWTO.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This document contains information about common development tasks.
77
[Install Rust](https://www.rust-lang.org/tools/install), then run:
88

99
```bash
10-
cargo build --release
10+
(cd extractor && cargo build --release)
1111
```
1212

1313
## Generating the database schema and QL library
@@ -16,7 +16,7 @@ The generated `ql/lib/ruby.dbscheme` and `ql/lib/codeql/ruby/ast/internal/TreeSi
1616

1717
```bash
1818
# Run the generator
19-
cargo run --release -p ruby-generator -- --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
19+
(cd extractor && cargo run --release --bin generator -- --dbscheme ../ql/lib/ruby.dbscheme --library ../ql/lib/codeql/ruby/ast/internal/TreeSitter.qll)
2020
# Then auto-format the QL library
2121
codeql query format -i ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
2222
```

ruby/extractor/rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# extractor. It is set to the lowest version of Rust we want to support.
33

44
[toolchain]
5-
channel = "1.54"
5+
channel = "1.68"
66
profile = "minimal"
77
components = [ "rustfmt" ]

ruby/extractor/src/bin/extractor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ fn scan_erb(
320320
(result, line_breaks)
321321
}
322322

323+
/// Advance `index` to the next non-whitespace character.
324+
/// Newlines are **not** considered whitespace.
323325
fn skip_space(content: &[u8], index: usize) -> usize {
324326
let mut index = index;
325327
while index < content.len() {

0 commit comments

Comments
 (0)