Skip to content

Commit

Permalink
[ci] add checkfmt for PRs
Browse files Browse the repository at this point in the history
Signed-off-by: unlsycn <[email protected]>
  • Loading branch information
unlsycn committed Sep 11, 2024
1 parent cb2af5c commit c117dee
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/checkfmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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"
run: |
nix develop -c bash -c 'mill gcd.checkFormat && mill elaborator.checkFormat'
- name: "Check Rust format"
run: |
cd gcdemu
nix develop -c cargo fmt --check
cd ..
- name: "Check nix format"
run: |
nix fmt -- --check nix flake.nix
9 changes: 9 additions & 0 deletions templates/chisel/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
.bloop
.bsp
.jvm-opts
.mill-jvm-opts
.metals/
.vscode/

out/
result*
gcd-sim-result/
/dependencies/
target/

*.vcd
*.fst
*.fsdb
*.log
2 changes: 1 addition & 1 deletion templates/chisel/.scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lineEndings = preserve
includeCurlyBraceInSelectChains = false
danglingParentheses.preset = true

align.tokens.add = [
align.tokens."+" = [
{
code = ":"
}
Expand Down
2 changes: 1 addition & 1 deletion templates/chisel/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c117dee

Please sign in to comment.