Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22990a9

Browse files
committed
Add support for LGTM_INDEX_FILTERS environment variable
* re-implement autobuilder script in Rust * add additional --include/--exclude flags based on LGTM_INDEX_FILTERS environment variable
1 parent 7574d1c commit 22990a9

9 files changed

Lines changed: 59 additions & 16 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ jobs:
6262
with:
6363
name: extractor-${{ matrix.os }}
6464
path: |
65+
target/release/ruby-autobuilder
66+
target/release/ruby-autobuilder.exe
6567
target/release/ruby-extractor
6668
target/release/ruby-extractor.exe
6769
retention-days: 1
@@ -125,10 +127,13 @@ jobs:
125127
mkdir -p ruby
126128
cp -r codeql-extractor.yml tools ql/src/ruby.dbscheme.stats ruby/
127129
mkdir -p ruby/tools/{linux64,osx64,win64}
130+
cp linux64/ruby-autobuilder ruby/tools/linux64/autobuilder
131+
cp osx64/ruby-autobuilder ruby/tools/osx64/autobuilder
132+
cp win64/ruby-autobuilder.exe ruby/tools/win64/autobuilder.exe
128133
cp linux64/ruby-extractor ruby/tools/linux64/extractor
129134
cp osx64/ruby-extractor ruby/tools/osx64/extractor
130135
cp win64/ruby-extractor.exe ruby/tools/win64/extractor.exe
131-
chmod +x ruby/tools/{linux64,osx64}/extractor
136+
chmod +x ruby/tools/{linux64,osx64}/{autobuilder,extractor}
132137
zip -rq codeql-ruby.zip ruby
133138
- uses: actions/upload-artifact@v2
134139
with:

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = [
3+
"autobuilder",
34
"extractor",
45
"generator",
56
"node-types",

autobuilder/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "ruby-autobuilder"
3+
version = "0.1.0"
4+
authors = ["GitHub"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]

autobuilder/src/main.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use std::env;
2+
use std::process::Command;
3+
4+
fn main() -> std::io::Result<()> {
5+
let dist = env::var("CODEQL_DIST").expect("CODEQL_DIST not set");
6+
let db = env::var("CODEQL_EXTRACTOR_RUBY_WIP_DATABASE")
7+
.expect("CODEQL_EXTRACTOR_RUBY_WIP_DATABASE not set");
8+
let ext = if env::consts::OS == "windows" {
9+
".exe"
10+
} else {
11+
""
12+
};
13+
let mut cmd = Command::new(format!("{}/codeql{}", dist, ext));
14+
&cmd.arg("database")
15+
.arg("index-files")
16+
.arg("--include-extension=.rb")
17+
.arg("--include-extension=.erb")
18+
.arg("--size-limit=5m")
19+
.arg("--language=ruby")
20+
.arg("--working-dir=.")
21+
.arg(db);
22+
23+
for line in env::var("LGTM_INDEX_FILTERS")
24+
.unwrap_or_default()
25+
.split("\n")
26+
{
27+
if line.starts_with("include:") {
28+
&cmd.arg("--include").arg(&line[8..]);
29+
} else if line.starts_with("exclude:") {
30+
&cmd.arg("--exclude").arg(&line[8..]);
31+
}
32+
}
33+
let exit = &cmd.spawn()?.wait()?;
34+
std::process::exit(exit.code().unwrap_or(1))
35+
}

create-extractor-pack.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ cp codeql-extractor.yml, ql\src\ruby.dbscheme, ql\src\ruby.dbscheme.stats extrac
99
cp -Recurse tools extractor-pack
1010
mkdir extractor-pack\tools\win64 | Out-Null
1111
cp target\release\ruby-extractor.exe extractor-pack\tools\win64\extractor.exe
12+
cp target\release\ruby-autobuilder.exe extractor-pack\tools\win64\autobuilder.exe

create-extractor-pack.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ mkdir -p extractor-pack
2020
cp -r codeql-extractor.yml tools ql/src/ruby.dbscheme ql/src/ruby.dbscheme.stats extractor-pack/
2121
mkdir -p extractor-pack/tools/${platform}
2222
cp target/release/ruby-extractor extractor-pack/tools/${platform}/extractor
23+
cp target/release/ruby-autobuilder extractor-pack/tools/${platform}/autobuilder

tools/autobuild.cmd

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
@echo off
22

3-
type NUL && "%CODEQL_DIST%\codeql.exe" database index-files ^
4-
--include-extension=.rb ^
5-
--include-extension=.erb ^
6-
--size-limit=5m ^
7-
--language=ruby ^
8-
"%CODEQL_EXTRACTOR_RUBY_WIP_DATABASE%"
3+
type NUL && "%CODEQL_EXTRACTOR_RUBY_ROOT%\tools\%CODEQL_PLATFORM\autobuilder"
94

105
exit /b %ERRORLEVEL%

tools/autobuild.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
#!/bin/sh
22

3-
set -eu
4-
5-
exec "${CODEQL_DIST}/codeql" database index-files \
6-
--include-extension=.rb \
7-
--include-extension=.erb \
8-
--size-limit=5m \
9-
--language=ruby \
10-
--working-dir=.\
11-
"$CODEQL_EXTRACTOR_RUBY_WIP_DATABASE"
3+
exec "${CODEQL_EXTRACTOR_RUBY_ROOT}/tools/${CODEQL_PLATFORM}/autobuilder"

0 commit comments

Comments
 (0)