Skip to content

Commit

Permalink
[ci] add lint CI
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Sep 3, 2024
1 parent 0d25d9e commit de7c2a3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 6 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Code linting
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
- labeled
env:
USER: runner

# Cancel the current workflow when new commit pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
checkfmt:
name: "Check formats"
strategy:
fail-fast: false
runs-on: [self-hosted, linux, nixos]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: "Run testcases"
run: |
RET=0
warnOnFileChanged() {
if ! git diff -q --exit-code; then
RET=1
local msg="$1"; shift
echo "$msg"
echo "$msg" >> $GITHUB_STEP_SUMMARY
git reset --hard
fi
}
nix develop '.#t1.elaborator' -c mill -i configgen.reformat
nix develop '.#t1.elaborator' -c mill -i rocketv.reformat
nix develop '.#t1.elaborator' -c mill -i t1.reformat
nix develop '.#t1.elaborator' -c mill -i t1rocket.reformat
warnOnFileChanged "* Scala format fail, please run 'nix develop '.#t1.elaborator' -c mill -i _.reformat'"
nix fmt
warnOnFileChanged "* Nix format fail, please run 'nix fmt'"
pushd difftest
nix shell '.#cargo' '.#rustfmt' -c cargo fmt
warnOnFileChanged "* Cargo format fail, please run 'cd difftest; nix run .#cargo -- format'"
popd
pushd t1rocketemu
nix shell '.#cargo' '.#rustfmt' -c cargo fmt
warnOnFileChanged "* Cargo format fail, please run 'cd t1rocketemu; nix run .#cargo -- format'"
popd
if nix run '.#ripgrep' -- '\p{Script=Han}' t1 > zh-hans.txt; then
RET=1
msg="* Found ZH_CN comments"
echo "$msg"
echo "$msg" >> $GITHUB_STEP_SUMMARY
echo '```text' >> $GITHUB_STEP_SUMMARY
cat zh-hans.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
git reset --hard
fi
exit $RET
6 changes: 3 additions & 3 deletions difftest/dpi_t1rocket/src/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use dpi_common::dump::DumpControl;
use dpi_common::plusarg::PlusArgMatcher;
use dpi_common::DpiTarget;
use svdpi::SvScope;
use std::ffi::{c_char, c_longlong};
use svdpi::SvScope;
use tracing::debug;

use crate::drive::Driver;
Expand Down Expand Up @@ -58,7 +58,8 @@ unsafe fn load_from_payload(
})
.collect();
assert_eq!(
masks.len(), data.len(),
masks.len(),
data.len(),
"strobe bit width is not aligned with data byte width"
);

Expand Down Expand Up @@ -316,4 +317,3 @@ unsafe extern "C" fn get_resetvector(resetvector: *mut c_longlong) {
//--------------------------------
// import functions and wrappers
//--------------------------------

6 changes: 3 additions & 3 deletions difftest/dpi_t1rocket/src/drive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::dpi::*;
use svdpi::SvScope;
use crate::OnlineArgs;
use crate::{get_t, EXIT_CODE, EXIT_POS};
use svdpi::SvScope;

use anyhow::Context;
use dpi_common::dump::{DumpControl, DumpEndError};
Expand Down Expand Up @@ -141,7 +141,7 @@ impl Driver {

shadow_mem,

quit: false
quit: false,
}
}

Expand Down Expand Up @@ -335,7 +335,7 @@ impl Driver {
WATCHDOG_TIMEOUT
} else {
match self.dump_control.trigger_watchdog(tick) {
Ok(()) => {},
Ok(()) => {}
Err(DumpEndError) => {
info!(
"[{tick}] run to dump end, exiting (last_commit_cycle={})",
Expand Down

0 comments on commit de7c2a3

Please sign in to comment.