Skip to content

Commit f9e4c0a

Browse files
authored
Merge pull request #17435 from github/rust-experiment
Rust: merge current status of experimental extractor into main
2 parents 07bd854 + fea6017 commit f9e4c0a

File tree

327 files changed

+18441
-1089
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

327 files changed

+18441
-1089
lines changed

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Ruby:
3030
- ruby/**/*
3131
- change-notes/**/*ruby*
3232

33+
Rust:
34+
- rust/**/*
35+
- change-notes/**/*rust*
36+
3337
Swift:
3438
- swift/**/*
3539
- change-notes/**/*swift*

.github/workflows/check-change-note.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ on:
1616
- "shared/**/*.qll"
1717
- "!**/experimental/**"
1818
- "!ql/**"
19+
- "!rust/**"
1920
- ".github/workflows/check-change-note.yml"
2021

2122
jobs:
2223
check-change-note:
23-
env:
24+
env:
2425
REPO: ${{ github.repository }}
2526
PULL_REQUEST_NUMBER: ${{ github.event.number }}
2627
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -33,7 +34,7 @@ jobs:
3334
!contains(github.event.pull_request.labels.*.name, 'no-change-note-required')
3435
run: |
3536
change_note_files=$(gh api "repos/$REPO/pulls/$PULL_REQUEST_NUMBER/files" --paginate --jq '.[].filename | select(test("/change-notes/.*[.]md$"))')
36-
37+
3738
if [ -z "$change_note_files" ]; then
3839
echo "No change note found. Either add one, or add the 'no-change-note-required' label."
3940
exit 1

.github/workflows/ruby-build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ jobs:
6565
id: cache-extractor
6666
with:
6767
path: |
68-
ruby/extractor/target/release/codeql-extractor-ruby
69-
ruby/extractor/target/release/codeql-extractor-ruby.exe
68+
target/release/codeql-extractor-ruby
69+
target/release/codeql-extractor-ruby.exe
7070
ruby/extractor/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
7171
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/extractor/Cargo.lock') }}-${{ hashFiles('shared/tree-sitter-extractor') }}-${{ hashFiles('ruby/extractor/**/*.rs') }}
7272
- uses: actions/cache@v3
@@ -75,7 +75,7 @@ jobs:
7575
path: |
7676
~/.cargo/registry
7777
~/.cargo/git
78-
ruby/target
78+
target
7979
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/extractor/**/Cargo.lock') }}
8080
- name: Check formatting
8181
if: steps.cache-extractor.outputs.cache-hit != 'true'
@@ -91,7 +91,7 @@ jobs:
9191
run: cd extractor && cargo build --release
9292
- name: Generate dbscheme
9393
if: ${{ matrix.os == 'ubuntu-latest' && steps.cache-extractor.outputs.cache-hit != 'true'}}
94-
run: extractor/target/release/codeql-extractor-ruby generate --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
94+
run: ../target/release/codeql-extractor-ruby generate --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
9595
- uses: actions/upload-artifact@v3
9696
if: ${{ matrix.os == 'ubuntu-latest' }}
9797
with:
@@ -106,8 +106,8 @@ jobs:
106106
with:
107107
name: extractor-${{ matrix.os }}
108108
path: |
109-
ruby/extractor/target/release/codeql-extractor-ruby
110-
ruby/extractor/target/release/codeql-extractor-ruby.exe
109+
target/release/codeql-extractor-ruby
110+
target/release/codeql-extractor-ruby.exe
111111
retention-days: 1
112112
compile-queries:
113113
if: github.repository_owner == 'github'

.github/workflows/rust.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: "Rust"
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "rust/**"
7+
- "misc/bazel/**"
8+
- "misc/codegen/**"
9+
- "shared/**"
10+
- "MODULE.bazel"
11+
- .github/workflows/rust.yml
12+
- .github/actions/**
13+
- codeql-workspace.yml
14+
- "!**/*.md"
15+
- "!**/*.qhelp"
16+
branches:
17+
- rust-experiment
18+
- main
19+
- rc/*
20+
- codeql-cli-*
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
rust-check:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
- name: Format
32+
working-directory: rust/extractor
33+
shell: bash
34+
run: |
35+
cargo fmt --check
36+
- name: Compilation
37+
working-directory: rust/extractor
38+
shell: bash
39+
run: cargo check
40+
- name: Clippy
41+
working-directory: rust/extractor
42+
shell: bash
43+
run: |
44+
cargo clippy --fix
45+
git diff --exit-code
46+
- name: Code generation
47+
shell: bash
48+
run: |
49+
bazel run //rust/codegen
50+
git add .
51+
git diff --exit-code HEAD

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,9 @@ node_modules/
6565

6666
# bazel-built in-tree extractor packs
6767
/*/extractor-pack
68+
69+
# Jetbrains IDE files
70+
.idea
71+
72+
# cargo build directory
73+
/target

.pre-commit-config.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ repos:
55
rev: v3.2.0
66
hooks:
77
- id: trailing-whitespace
8-
exclude: /test/.*$(?<!\.ql)(?<!\.qll)(?<!\.qlref)|.*\.patch
8+
exclude: /test/.*$(?<!\.qlref)|.*\.patch$|.*\.qll?$
99
- id: end-of-file-fixer
10-
exclude: /test/.*$(?<!\.ql)(?<!\.qll)(?<!\.qlref)|.*\.patch
10+
exclude: /test/.*$(?<!\.qlref)|.*\.patch$|.*\.qll?$
1111

1212
- repo: https://github.com/pre-commit/mirrors-clang-format
1313
rev: v17.0.6
@@ -45,7 +45,7 @@ repos:
4545

4646
- id: sync-files
4747
name: Fix files required to be identical
48-
files: \.(qll?|qhelp|swift)$|^config/identical-files\.json$
48+
files: \.(qll?|qhelp|swift|toml)$|^config/identical-files\.json$
4949
language: system
5050
entry: python3 config/sync-files.py --latest
5151
pass_filenames: false
@@ -58,7 +58,7 @@ repos:
5858

5959
- id: swift-codegen
6060
name: Run Swift checked in code generation
61-
files: ^swift/(schema.py$|codegen/|.*/generated/|ql/lib/(swift\.dbscheme$|codeql/swift/elements)|ql/\.generated.list)
61+
files: ^misc/codegen/|^swift/(schema.py$|codegen/|.*/generated/|ql/lib/(swift\.dbscheme$|codeql/swift/elements)|ql/\.generated.list)
6262
language: system
6363
entry: bazel run //swift/codegen -- --quiet
6464
pass_filenames: false
@@ -69,3 +69,17 @@ repos:
6969
language: system
7070
entry: bazel test //misc/codegen/test
7171
pass_filenames: false
72+
73+
- id: rust-codegen
74+
name: Run Rust checked in code generation
75+
files: ^misc/codegen/|^rust/(schema.py$|codegen/|.*/generated/|ql/lib/(rust\.dbscheme$|codeql/rust/elements)|\.generated.list)
76+
language: system
77+
entry: bazel run //rust/codegen -- --quiet
78+
pass_filenames: false
79+
80+
- id: rust-lint
81+
name: Run fmt and clippy on Rust code
82+
files: ^rust/extractor/(.*rs|Cargo.toml)$
83+
language: system
84+
entry: python3 rust/lint.py
85+
pass_filenames: false

0 commit comments

Comments
 (0)