Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add go-arch-lint #2421

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ jobs:
submodules: true
- uses: cashapp/activate-hermit@v1
- run: cd docs && zola build
arch-lint:
name: Lint Architecture
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cashapp/activate-hermit@v1
- run: go-arch-lint check || true
integration-shard:
name: Shard Integration Tests
if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all')
Expand Down
1 change: 1 addition & 0 deletions .go-arch-lint-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"definitions":{"commonComponents":{"description":"All project packages can import this components, useful for utils packages like 'models'","items":{"title":"component name","type":"string"},"title":"List of components names","type":"array"},"commonVendors":{"description":"All project packages can import this vendor libs","items":{"title":"vendor name","type":"string"},"title":"List of vendor names","type":"array"},"component":{"additionalProperties":false,"properties":{"in":{"anyOf":[{"$ref":"#/definitions/componentIn"},{"items":{"$ref":"#/definitions/componentIn"},"type":"array"}]}},"required":["in"],"type":"object"},"componentIn":{"description":"relative directory name, support glob masking (src/\\*/engine/\\*\\*)","examples":["src/services","src/services/*/repo","src/*/services/**"],"title":"relative path to project package","type":"string"},"components":{"additionalProperties":{"$ref":"#/definitions/component"},"title":"List of components","type":"object"},"dependencies":{"additionalProperties":{"$ref":"#/definitions/dependencyRule"},"title":"Dependency rules between spec and package imports","type":"object"},"dependencyRule":{"additionalProperties":false,"properties":{"anyProjectDeps":{"description":"all component code can import any other project code, useful for DI/main component","title":"Allow import any project package?","type":"boolean"},"anyVendorDeps":{"description":"all component code can import any vendor code","title":"Allow import any vendor package?","type":"boolean"},"canUse":{"items":{"title":"vendor name","type":"string"},"title":"List of allowed vendors to import","type":"array"},"deepScan":{"description":"you can turn on/off deepScan only for this component","title":"Override deepscan global flag for this component","type":"boolean"},"mayDependOn":{"items":{"title":"component name","type":"string"},"title":"List of allowed components to import","type":"array"}},"type":"object"},"exclude":{"items":{"title":"list of directories (relative path) for exclude from analyse","type":"string"},"title":"Excluded folders from analyse","type":"array"},"excludeFiles":{"description":"package will by excluded in all package files is matched by provided regexp's","items":{"title":"regular expression rules for file names, will exclude this files and it's packages from analyse","type":"string","x-intellij-language-injection":"regexp"},"title":"Excluded files from analyse matched by regexp","type":"array"},"settings":{"additionalProperties":false,"properties":{"deepScan":{"title":"will use new advanced AST linter (this default=true from v3+)","type":"boolean"},"depOnAnyVendor":{"title":"allow import any vendor code to any project file","type":"boolean"}},"title":"Global Scheme options","type":"object"},"vendor":{"additionalProperties":false,"properties":{"in":{"anyOf":[{"$ref":"#/definitions/vendorIn"},{"items":{"$ref":"#/definitions/vendorIn"},"type":"array"}]}},"required":["in"],"type":"object"},"vendorIn":{"description":"one or more import path of vendor libs, support glob masking (src/\\*/engine/\\*\\*)","examples":["golang.org/x/mod/modfile","example.com/*/libs/**",["gopkg.in/yaml.v2","github.com/mailru/easyjson"]],"title":"full import path to vendor","type":"string"},"vendors":{"additionalProperties":{"$ref":"#/definitions/vendor"},"title":"List of vendor libs","type":"object"},"version":{"description":"Defines arch file syntax and file validation rules","maximum":3,"minimum":3,"title":"Scheme Version","type":"integer"},"workdir":{"description":"Linter will prepend all path's in project with this relative path prefix (relative directory for analyse)","title":"Working directory","type":"string"}},"description":"Arch file scheme version 3","id":"https://github.com/fe3dback/go-arch-lint/v3","properties":{"allow":{"$ref":"#/definitions/settings"},"commonComponents":{"$ref":"#/definitions/commonComponents"},"commonVendors":{"$ref":"#/definitions/commonVendors"},"components":{"$ref":"#/definitions/components"},"deps":{"$ref":"#/definitions/dependencies"},"exclude":{"$ref":"#/definitions/exclude"},"excludeFiles":{"$ref":"#/definitions/excludeFiles"},"vendors":{"$ref":"#/definitions/vendors"},"version":{"$ref":"#/definitions/version"},"workdir":{"$ref":"#/definitions/workdir"}},"required":["version","components","deps"],"title":"Go Arch Lint V3","type":"object"}
103 changes: 103 additions & 0 deletions .go-arch-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# yaml-language-server: $schema=./.go-arch-lint-schema.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So many cool go tools out there! This is great.

version: 3
workdir: .
components:
controller: { in: backend/controller/** }
ftl-controller-cmd: { in: cmd/ftl-controller/** }
common: { in: common/** }
internal: { in: internal/** }
dal: { in: backend/dal/** }
protos: { in: backend/protos/** }
schema: { in: backend/schema/** }
ftl: { in: . }
ftl-cmd: { in: cmd/ftl/** }
go-runtime: { in: go-runtime/** }
jvm-runtime: { in: jvm-runtime/** }
rust-runtime: { in: rust-runtime/** }
runner: { in: backend/runner/** }
ftl-runner-cmd: { in: cmd/ftl-runner/** }
frontend: { in: frontend/** }
ftl-gen-lsp-cmd: { in: cmd/ftl-gen-lsp/** }
ftl-initdb-cmd: { in: cmd/ftl-initdb/** }
ftl-schema-cmd: { in: cmd/ftl-schema/** }
lint-commit-or-rollback-cmd: { in: cmd/lint-commit-or-rollback/** }
databasetesting: { in: backend/controller/sql/databasetesting/** }
sql: { in: backend/controller/sql/** }
# TODO: Nothing outside of the go-runtime package should depend on reflection.
reflection: { in: go-runtime/ftl/reflection/** }
# TODO: Nothing outside of the go-runtime package should depend on reflection.
encoding: { in: go-runtime/encoding/** }
leases: { in: backend/controller/leases/** }

excludeFiles:
- ".*/testdata/.*"
- ".*/\\.ftl/.*"
- "/examples/.*"
- "/jvm-runtime/.*"

allow:
depOnAnyVendor: true

commonComponents:
- common
- internal
- dal
- protos
- schema
- ftl

deps:
controller:
mayDependOn:
- controller
- frontend
runner:
mayDependOn:
- common
- internal
- runner
go-runtime:
mayDependOn:
- common
- internal
- go-runtime
ftl-cmd:
mayDependOn:
- controller
- common
- internal
- dal
- protos
- schema
- ftl
- jvm-runtime # TODO: When we decouple runtimes, this should be removed.
- go-runtime # TODO: When we decouple runtimes, this should be removed.
ftl-controller-cmd:
mayDependOn:
- controller
- common
- internal
- dal
- protos
- schema
- ftl
ftl-runner-cmd:
mayDependOn:
- common
- internal
- runner
ftl-initdb-cmd:
mayDependOn:
- databasetesting
databasetesting:
mayDependOn:
- common
- internal
- dal
- sql
sql:
mayDependOn:
- common
- internal
- sql
- leases
1 change: 1 addition & 0 deletions bin/.go-arch-lint-1.11.4.pkg
1 change: 1 addition & 0 deletions bin/go-arch-lint