Skip to content

Commit 604d5f0

Browse files
authored
Merge pull request github#12510 from hmac/merge-ruby-extractor
Ruby: Merge extractor crates
2 parents aaeb8a0 + fd43ba0 commit 604d5f0

File tree

24 files changed

+78
-125
lines changed

24 files changed

+78
-125
lines changed

.github/workflows/ruby-build.yml

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,35 +55,35 @@ jobs:
5555
id: cache-extractor
5656
with:
5757
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') }}
58+
ruby/extractor/target/release/autobuilder
59+
ruby/extractor/target/release/autobuilder.exe
60+
ruby/extractor/target/release/extractor
61+
ruby/extractor/target/release/extractor.exe
62+
ruby/extractor/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
63+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/extractor/Cargo.lock') }}--${{ hashFiles('ruby/extractor/**/*.rs') }}
6464
- uses: actions/cache@v3
6565
if: steps.cache-extractor.outputs.cache-hit != 'true'
6666
with:
6767
path: |
6868
~/.cargo/registry
6969
~/.cargo/git
7070
ruby/target
71-
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
71+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/extractor/**/Cargo.lock') }}
7272
- name: Check formatting
7373
if: steps.cache-extractor.outputs.cache-hit != 'true'
74-
run: cargo fmt --all -- --check
74+
run: cd extractor && cargo fmt --all -- --check
7575
- name: Build
7676
if: steps.cache-extractor.outputs.cache-hit != 'true'
77-
run: cargo build --verbose
77+
run: cd extractor && cargo build --verbose
7878
- name: Run tests
7979
if: steps.cache-extractor.outputs.cache-hit != 'true'
80-
run: cargo test --verbose
80+
run: cd extractor && cargo test --verbose
8181
- name: Release build
8282
if: steps.cache-extractor.outputs.cache-hit != 'true'
83-
run: cargo build --release
83+
run: cd extractor && cargo build --release
8484
- name: Generate dbscheme
8585
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
86+
run: extractor/target/release/generator --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
8787
- uses: actions/upload-artifact@v3
8888
if: ${{ matrix.os == 'ubuntu-latest' }}
8989
with:
@@ -98,10 +98,10 @@ jobs:
9898
with:
9999
name: extractor-${{ matrix.os }}
100100
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
101+
ruby/extractor/target/release/autobuilder
102+
ruby/extractor/target/release/autobuilder.exe
103+
ruby/extractor/target/release/extractor
104+
ruby/extractor/target/release/extractor.exe
105105
retention-days: 1
106106
compile-queries:
107107
runs-on: ubuntu-latest-xl
@@ -116,21 +116,22 @@ jobs:
116116
key: ruby-build
117117
- name: Build Query Pack
118118
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/*)
119+
PACKS=${{ runner.temp }}/query-packs
120+
rm -rf $PACKS
121+
codeql pack create ../misc/suite-helpers --output "$PACKS"
122+
codeql pack create ../shared/regex --output "$PACKS"
123+
codeql pack create ../shared/ssa --output "$PACKS"
124+
codeql pack create ../shared/tutorial --output "$PACKS"
125+
codeql pack create ql/lib --output "$PACKS"
126+
codeql pack create -j0 ql/src --output "$PACKS" --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
127+
PACK_FOLDER=$(readlink -f "$PACKS"/codeql/ruby-queries/*)
127128
codeql generate query-help --format=sarifv2.1.0 --output="${PACK_FOLDER}/rules.sarif" ql/src
128129
(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}/{}" \;)
129130
- uses: actions/upload-artifact@v3
130131
with:
131132
name: codeql-ruby-queries
132133
path: |
133-
ruby/target/packs/*
134+
${{ runner.temp }}/query-packs/*
134135
retention-days: 1
135136

136137
package:
@@ -158,12 +159,12 @@ jobs:
158159
mkdir -p ruby
159160
cp -r codeql-extractor.yml tools ql/lib/ruby.dbscheme.stats ruby/
160161
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
162+
cp linux64/autobuilder ruby/tools/linux64/autobuilder
163+
cp osx64/autobuilder ruby/tools/osx64/autobuilder
164+
cp win64/autobuilder.exe ruby/tools/win64/autobuilder.exe
165+
cp linux64/extractor ruby/tools/linux64/extractor
166+
cp osx64/extractor ruby/tools/osx64/extractor
167+
cp win64/extractor.exe ruby/tools/win64/extractor.exe
167168
chmod +x ruby/tools/{linux64,osx64}/{autobuilder,extractor}
168169
zip -rq codeql-ruby.zip ruby
169170
- uses: actions/upload-artifact@v3

ruby/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/target
1+
extractor/target
22
extractor-pack
33
.vscode/launch.json
44
.cache

ruby/Cargo.toml

Lines changed: 0 additions & 7 deletions
This file was deleted.

ruby/actions/create-extractor-pack/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ runs:
1010
uses: actions/cache@v3
1111
with:
1212
path: ruby/extractor-pack
13-
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/scripts/create-extractor-pack.sh', 'ruby/**/Cargo.lock', 'ruby/actions/create-extractor-pack/action.yml') }}-${{ hashFiles('ruby/**/*.rs') }}-${{ hashFiles('ruby/codeql-extractor.yml', 'ruby/downgrades', 'ruby/tools', 'ruby/ql/lib/ruby.dbscheme', 'ruby/ql/lib/ruby.dbscheme.stats') }}
13+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/scripts/create-extractor-pack.sh', 'ruby/extractor/**/Cargo.lock', 'ruby/actions/create-extractor-pack/action.yml') }}-${{ hashFiles('ruby/extractor/**/*.rs') }}-${{ hashFiles('ruby/codeql-extractor.yml', 'ruby/downgrades', 'ruby/tools', 'ruby/ql/lib/ruby.dbscheme', 'ruby/ql/lib/ruby.dbscheme.stats') }}
1414
- name: Cache cargo
1515
uses: actions/cache@v3
1616
if: steps.cache-extractor.outputs.cache-hit != 'true'
@@ -19,7 +19,7 @@ runs:
1919
~/.cargo/registry
2020
~/.cargo/git
2121
ruby/target
22-
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-qltest-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/scripts/create-extractor-pack.sh', 'ruby/**/Cargo.lock') }}
22+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-qltest-cargo-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/scripts/create-extractor-pack.sh', 'ruby/extractor/**/Cargo.lock') }}
2323
- name: Build Extractor
2424
if: steps.cache-extractor.outputs.cache-hit != 'true'
2525
shell: bash

ruby/autobuilder/Cargo.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

ruby/Cargo.lock renamed to ruby/extractor/Cargo.lock

Lines changed: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ruby/extractor/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2018"
88

99
[dependencies]
1010
flate2 = "1.0"
11-
node-types = { path = "../node-types" }
1211
tree-sitter = "0.20"
1312
tree-sitter-embedded-template = { git = "https://github.com/tree-sitter/tree-sitter-embedded-template.git", rev = "203f7bd3c1bbfbd98fc19add4b8fcb213c059205" }
1413
tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "206c7077164372c596ffa8eaadb9435c28941364" }
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)