Skip to content

Commit 37afad2

Browse files
authored
Merge pull request github#17410 from github/redsun82/rust-ci
Rust: set up `codeql` CI
2 parents 6f36ea9 + 45c9eb1 commit 37afad2

File tree

8 files changed

+72
-6
lines changed

8 files changed

+72
-6
lines changed

.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

.pre-commit-config.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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,10 @@ 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

misc/codegen/templates/rust_classes.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// generated by {{generator}}
22

3+
#![cfg_attr(any(), rustfmt::skip)]
4+
35
use crate::trap::{TrapId, TrapEntry};
46
use codeql_extractor::trap;
57
{{#classes}}

rust/extractor/src/generated/.generated.list

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/extractor/src/generated/top.rs

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

rust/extractor/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::trap::TrapId;
22
use anyhow::Context;
33
use ra_ap_hir::db::DefDatabase;
4-
use ra_ap_hir::{Crate};
4+
use ra_ap_hir::Crate;
55
use ra_ap_load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
66
use ra_ap_project_model::CargoConfig;
77
use ra_ap_project_model::RustLibSource;
8-
use std::path::{PathBuf};
8+
use std::path::PathBuf;
99

1010
mod archive;
1111
mod config;

rust/extractor/src/trap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use crate::config::Compression;
22
use crate::generated;
33
use crate::{config, path};
44
use codeql_extractor::trap;
5-
use log::{debug};
5+
use log::debug;
66
use ra_ap_ide_db::line_index::LineCol;
77
use std::ffi::OsString;
8-
use std::fmt::{Debug};
8+
use std::fmt::Debug;
99
use std::path::{Path, PathBuf};
1010

1111
//TODO: typed labels

rust/integration-tests/test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# dummy test to get CI going
2+
3+
def test(codeql, rust):
4+
pass

0 commit comments

Comments
 (0)