diff --git a/.github/workflows/checkfmt.yml b/.github/workflows/checkfmt.yml new file mode 100644 index 0000000..077ec5d --- /dev/null +++ b/.github/workflows/checkfmt.yml @@ -0,0 +1,46 @@ +name: Check the format of a PR +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: + + check-format: + name: "Check format" + runs-on: [self-hosted, linux, nixos] + strategy: + fail-fast: false + defaults: + run: + working-directory: ./templates/chisel + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: "Check Scala format" + continue-on-error: true + run: | + nix develop -c bash -c 'mill -i gcd.checkFormat && mill -i elaborator.checkFormat' + - name: "Check Rust format" + continue-on-error: true + run: | + cd gcdemu + nix develop -c cargo fmt --check + cd .. + - name: "Check nix format" + continue-on-error: true + run: | + nix fmt -- --check nix flake.nix + diff --git a/templates/chisel/.gitignore b/templates/chisel/.gitignore index 6f27e13..338f9fc 100644 --- a/templates/chisel/.gitignore +++ b/templates/chisel/.gitignore @@ -1,8 +1,17 @@ .bloop .bsp +.jvm-opts +.mill-jvm-opts .metals/ .vscode/ + out/ result* +gcd-sim-result/ /dependencies/ target/ + +*.vcd +*.fst +*.fsdb +*.log diff --git a/templates/chisel/.scalafmt.conf b/templates/chisel/.scalafmt.conf index c839f64..0310aaa 100644 --- a/templates/chisel/.scalafmt.conf +++ b/templates/chisel/.scalafmt.conf @@ -10,7 +10,7 @@ lineEndings = preserve includeCurlyBraceInSelectChains = false danglingParentheses.preset = true -align.tokens.add = [ +align.tokens."+" = [ { code = ":" } diff --git a/templates/chisel/build.sc b/templates/chisel/build.sc index 4da6ed7..3b79023 100644 --- a/templates/chisel/build.sc +++ b/templates/chisel/build.sc @@ -37,7 +37,7 @@ trait GCD extends millbuild.common.HasChisel with ScalafmtModule { } object elaborator extends Elaborator -trait Elaborator extends millbuild.common.ElaboratorModule { +trait Elaborator extends millbuild.common.ElaboratorModule with ScalafmtModule { def scalaVersion = T(deps.scalaVer) def panamaconverterModule = panamaconverter