Skip to content
Draft
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
67 changes: 67 additions & 0 deletions .github/_typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Configuration for typos spell checker
# See: https://github.com/crate-ci/typos
#
# Inline typos ignore comments:
# To ignore a specific line, add a comment on the same line:
# var myVar = "mispeling" // typos:disable-line
#
# To ignore the next line, add a comment on the line before:
# // typos:ignore-next-line
# var myVar = "mispeling"
#
# To ignore a block of code:
# // typos:off
# var myVar = "mispeling"
# var other = "anothermispeling"
# // typos:on
#
# To check only changed files (useful for local development):
# git diff --name-only --diff-filter=ACMR main...HEAD | typos --file-list -
# Or check only staged files:
# git diff --cached --name-only | typos --file-list -

[default]
# Custom ignore patterns for inline typos comments
extend-ignore-re = [
# Line ignore with trailing comment: // typos:disable-line or # typos:disable-line
"(?Rm)^.*(#|//)\\s*typos:disable-line$",
# Block ignore with typos:off/on: // typos:off ... // typos:on
"(?s)(#|//)\\s*typos:off.*?\\n\\s*(#|//)\\s*typos:on",
# Next-line ignore: // typos:ignore-next-line (ignores the following line)
"(#|//)\\s*typos:ignore-next-line\\n.*",
]

[default.extend-words]
# Add custom dictionary entries here for intentional "misspellings" used in the codebase
# Preemptable is used consistently instead of "Preemptible" for caller types
Preemptable = "Preemptable"
preemptable = "preemptable"
# "ba" is a legitimate variable name in merge tests (shorthand for "b merged with a")
ba = "ba"
# Hash strings may contain letter combinations that look like typos
Ue = "Ue"
# Test data and base64 strings that contain letter combinations that look like typos
nd = "nd"
abd = "abd"
# Environment variable name that must remain for backwards compatibility
AVAILABILTY = "AVAILABILTY"
# Proto-generated field names that have typos in the proto definition
# These should be fixed in the proto file first, then regenerated
Heartbeart = "Heartbeart"
heartbeart = "heartbeart"

Invoke = "Invoke"
invoke = "invoke"
Invokable = "Invokable"

[files]
# Exclude generated protobuf files
extend-exclude = [
"*.pb.go",
"*.gen.go",
"**/testdata/**",
"*.svg",
]

[type.go]
extend-glob = ["*.go"]
23 changes: 23 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,28 @@ jobs:
exit 1
fi

typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changed files
id: changed-files
env:
BASE_REF: ${{ github.base_ref }}
run: |
git diff --name-only --diff-filter=ACMR "origin/${BASE_REF}"...HEAD | tr '\n' ' ' > changed_files.txt
echo "files=$(cat changed_files.txt)" >> "$GITHUB_OUTPUT"

- name: check spelling with typos on changed files
if: steps.changed-files.outputs.files != ''
uses: crate-ci/[email protected]
with:
config: .github/_typos.toml
files: ${{ steps.changed-files.outputs.files }}

linters-succeed:
name: All Linters Succeed
needs:
Expand All @@ -141,6 +163,7 @@ jobs:
- lint-actions
- fmt-imports
- golangci
- typos
runs-on: ubuntu-latest
if: always()
env:
Expand Down
28 changes: 26 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ ACTIONLINT := $(LOCALBIN)/actionlint-$(ACTIONLINT_VER)
$(ACTIONLINT): | $(LOCALBIN)
$(call go-install-tool,$(ACTIONLINT),github.com/rhysd/actionlint/cmd/actionlint,$(ACTIONLINT_VER))

TYPOS_VER := v1.28.4
TYPOS := typos

WORKFLOWCHECK_VER := master # TODO: pin this specific version once 0.3.0 follow-up is released
WORKFLOWCHECK := $(LOCALBIN)/workflowcheck-$(WORKFLOWCHECK_VER)
$(WORKFLOWCHECK): | $(LOCALBIN)
Expand Down Expand Up @@ -369,7 +372,7 @@ temporal-server-debug: $(ALL_SRC)
##### Checks #####
goimports: fmt-imports $(GOIMPORTS)
@printf $(COLOR) "Run goimports for all files..."
@UNGENERATED_FILES=$$(find . -type f -name '*.go' -print0 | xargs -0 grep -L -e "Code generated by .* DO NOT EDIT." || true) && \
@UNGENERATED_FILES=$$(find . -type f -name '*.go' -not -path './.git/*' -print0 | xargs -0 grep -L -e "Code generated by .* DO NOT EDIT." || true) && \
$(GOIMPORTS) -w $$UNGENERATED_FILES

lint-actions: $(ACTIONLINT)
Expand All @@ -385,7 +388,28 @@ fmt-imports: $(GCI) # Don't get confused, there is a single linter called gci, w
@printf $(COLOR) "Formatting imports..."
@$(GCI) write --skip-generated -s standard -s default ./*

lint: lint-code lint-actions lint-api lint-protos
lint-typos:
@printf $(COLOR) "Checking spelling with typos..."
@if command -v $(TYPOS) >/dev/null 2>&1; then \
$(TYPOS) --config .github/_typos.toml; \
else \
printf $(RED) "WARNING: typos is not installed. Install it from https://github.com/crate-ci/typos or run: cargo install typos-cli"; \
echo ""; \
echo "Skipping spell check..."; \
fi

# Check spelling only on files changed from main branch
lint-typos-changed:
@printf $(COLOR) "Checking spelling on changed files with typos..."
@if command -v $(TYPOS) >/dev/null 2>&1; then \
git diff --name-only --diff-filter=ACMR $(MAIN_BRANCH)...HEAD | $(TYPOS) --config .github/_typos.toml --file-list -; \
else \
printf $(RED) "WARNING: typos is not installed. Install it from https://github.com/crate-ci/typos or run: cargo install typos-cli"; \
echo ""; \
echo "Skipping spell check..."; \
fi

lint: lint-code lint-actions lint-api lint-protos lint-typos-changed
@printf $(COLOR) "Run linters..."

lint-api: $(API_LINTER) $(API_BINPB)
Expand Down
2 changes: 1 addition & 1 deletion chasm/lib/scheduler/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Generator struct {
Scheduler chasm.Field[*Scheduler]
}

// NewGenerator returns an intialized Generator component, which should
// NewGenerator returns an initialized Generator component, which should
// be parented under a Scheduler root node.
func NewGenerator(ctx chasm.MutableContext, scheduler *Scheduler, invoker *Invoker) *Generator {
generator := &Generator{
Expand Down
2 changes: 1 addition & 1 deletion chasm/lib/scheduler/invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (i *Invoker) LifecycleState(ctx chasm.Context) chasm.LifecycleState {
return chasm.LifecycleStateRunning
}

// NewInvoker returns an intialized Invoker component, which should
// NewInvoker returns an initialized Invoker component, which should
// be parented under a Scheduler root component.
func NewInvoker(ctx chasm.MutableContext, scheduler *Scheduler) *Invoker {
return &Invoker{
Expand Down
6 changes: 3 additions & 3 deletions chasm/lib/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (s *Scheduler) LifecycleState(ctx chasm.Context) chasm.LifecycleState {
return chasm.LifecycleStateRunning
}

// NewRangeBackfiller returns an intialized Backfiller component, which should
// NewRangeBackfiller returns an initialized Backfiller component, which should
// be parented under a Scheduler root node.
func (s *Scheduler) NewRangeBackfiller(
ctx chasm.MutableContext,
Expand All @@ -172,7 +172,7 @@ func (s *Scheduler) NewRangeBackfiller(
return backfiller
}

// NewImmediateBackfiller returns an intialized Backfiller component, which should
// NewImmediateBackfiller returns an initialized Backfiller component, which should
// be parented under a Scheduler root node.
func (s *Scheduler) NewImmediateBackfiller(
ctx chasm.MutableContext,
Expand Down Expand Up @@ -401,7 +401,7 @@ func executionStatusFromFailure(failure *failurepb.Failure) enumspb.WorkflowExec
}

// HandleNexusCompletion allows Scheduler to record workflow completions from
// worfklows started by the same scheduler tree's Invoker.
// workflows started by the same scheduler tree's Invoker.
func (s *Scheduler) HandleNexusCompletion(
ctx chasm.MutableContext,
info *persistencespb.ChasmNexusCompletion,
Expand Down
4 changes: 2 additions & 2 deletions chasm/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type ComponentRef struct {
// It is used to find and validate the loaded execution has the right archetype, especially when runID
// is not specified in the ExecutionKey.
archetypeID ArchetypeID
// executionGoType is used for determining the ComponetRef's archetype.
// When CHASM deverloper needs to create a ComponentRef, they will only provide the component type,
// executionGoType is used for determining the ComponentRef's archetype.
// When CHASM developer needs to create a ComponentRef, they will only provide the component type,
// and leave the work of determining archetypeID to the CHASM framework.
executionGoType reflect.Type

Expand Down
10 changes: 5 additions & 5 deletions chasm/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (
// - NeedSyncStructure: Value is deserialized, neither data nor tree structure is synced.
//
// For simplicity, for a dirty component node, the logic always sync structure (potentially multiple times within a transaction) first,
// and the serialize the data at the very end of a transaction. So there will never base a case where value is synced with seralizedNode,
// and the serialize the data at the very end of a transaction. So there will never base a case where value is synced with serializedNode,
// but not with children.
//
// To update this field, ALWAYS use setValueState() method.
Expand Down Expand Up @@ -308,7 +308,7 @@ func newTreeInitSearchAttributesAndMemo(
return err
}

// Theoritically we should check if the root node has a Visibility component or not.
// Theoretically we should check if the root node has a Visibility component or not.
// But that doesn't really matter. Even if it doesn't have one, currentSearchAttributes
// and currentMemo will just never be used.

Expand Down Expand Up @@ -1549,7 +1549,7 @@ func (n *Node) closeTransactionForceUpdateVisibility(
visibility.generateTask(mutableContext)
visibilityNode.setValueState(valueStateNeedSerialize)

// We don't need to sync tree structure here for the visiblity node because we only generated a task without
// We don't need to sync tree structure here for the visibility node because we only generated a task without
// changing any component fields.
return nil
}
Expand Down Expand Up @@ -2684,7 +2684,7 @@ func deserializeTask(
return taskValue, nil
}

// TODO: consider pre-calculating the proto field num when registring the task type.
// TODO: consider pre-calculating the proto field num when registering the task type.

protoMessageFound := false
for i := 0; i < taskGoType.NumField(); i++ {
Expand Down Expand Up @@ -2735,7 +2735,7 @@ func serializeTask(
}, nil
}

// TODO: consider pre-calculating the proto field num when registring the task type.
// TODO: consider pre-calculating the proto field num when registering the task type.

var blob *commonpb.DataBlob
protoMessageFound := false
Expand Down
36 changes: 18 additions & 18 deletions chasm/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1694,18 +1694,18 @@ func (s *nodeSuite) TestRef() {
subComponent11 := subComponent1.SubComponent11.Get(chasmContext)

testCases := []struct {
name string
component Component
expectErr bool
expectedPath []string
expectedInitalVT *persistencespb.VersionedTransition
name string
component Component
expectErr bool
expectedPath []string
expectedInitialVT *persistencespb.VersionedTransition
}{
{
name: "root",
component: testComponent,
expectErr: false,
expectedPath: nil, // same as []string{}
expectedInitalVT: &persistencespb.VersionedTransition{
expectedInitialVT: &persistencespb.VersionedTransition{
NamespaceFailoverVersion: 1,
TransitionCount: 1,
},
Expand All @@ -1715,7 +1715,7 @@ func (s *nodeSuite) TestRef() {
component: subComponent1,
expectErr: false,
expectedPath: []string{"SubComponent1"},
expectedInitalVT: &persistencespb.VersionedTransition{
expectedInitialVT: &persistencespb.VersionedTransition{
NamespaceFailoverVersion: 1,
TransitionCount: 1,
},
Expand All @@ -1725,7 +1725,7 @@ func (s *nodeSuite) TestRef() {
component: subComponent11,
expectErr: false,
expectedPath: []string{"SubComponent1", "SubComponent11"},
expectedInitalVT: &persistencespb.VersionedTransition{
expectedInitialVT: &persistencespb.VersionedTransition{
NamespaceFailoverVersion: 1,
TransitionCount: 1,
},
Expand Down Expand Up @@ -1754,13 +1754,13 @@ func (s *nodeSuite) TestRef() {

// Proto fields are validated separately with ProtoEqual.
// executionLastUpdateVT: currentVT,
// componentInitialVT: tc.expectedInitalVT,
// componentInitialVT: tc.expectedInitialVT,
}

actualRef, err := DeserializeComponentRef(encodedRef)
s.NoError(err)
s.ProtoEqual(currentVT, actualRef.executionLastUpdateVT)
s.ProtoEqual(tc.expectedInitalVT, actualRef.componentInitialVT)
s.ProtoEqual(tc.expectedInitialVT, actualRef.componentInitialVT)

actualRef.executionLastUpdateVT = nil
actualRef.componentInitialVT = nil
Expand Down Expand Up @@ -1926,7 +1926,7 @@ func (s *nodeSuite) TestCloseTransaction_ForceUpdateVisibility_RootLifecycleChan
return true, nil
}

// Init visiblity component
// Init visibility component
testComponent.(*TestComponent).Visibility = NewComponentField(chasmCtx, NewVisibility(chasmCtx))
mutation, err := node.CloseTransaction()
s.NoError(err)
Expand Down Expand Up @@ -1979,7 +1979,7 @@ func (s *nodeSuite) TestCloseTransaction_ForceUpdateVisibility_RootSAMemoChanged
return nextTransitionCount
}

// Init visiblity component
// Init visibility component
testComponent.(*TestComponent).Visibility = NewComponentField(chasmCtx, NewVisibility(chasmCtx))
s.nodeBackend.HandleUpdateWorkflowStateStatus = func(state enumsspb.WorkflowExecutionState, status enumspb.WorkflowExecutionStatus) (bool, error) {
return true, nil
Expand Down Expand Up @@ -2604,7 +2604,7 @@ func (s *nodeSuite) TestExecuteImmediatePureTask() {
s.Len(mutations.UpdatedNodes, 2, "root and subcomponent1 should be updated")
s.Empty(mutations.DeletedNodes)

// immedidate pure tasks will be executed inline and no physical chasm pure task will be generated.
// immediate pure tasks will be executed inline and no physical chasm pure task will be generated.
s.Equal(tasks.MaximumKey.FireTime, s.nodeBackend.LastDeletePureTaskCall())
}

Expand Down Expand Up @@ -2889,14 +2889,14 @@ func (s *nodeSuite) TestExecuteSideEffectTask() {
ctx := NewEngineContext(context.Background(), mockEngine)

chasmContext := NewMutableContext(ctx, root)
var backendValidtionFnCalled bool
var backendValidationFnCalled bool
// This won't be called until access time.
dummyValidationFn := func(_ NodeBackend, _ Context, _ Component) error {
backendValidtionFnCalled = true
backendValidationFnCalled = true
return nil
}
expectValidate := func(valid bool, validationErr error) {
backendValidtionFnCalled = false
backendValidationFnCalled = false
s.testLibrary.mockSideEffectTaskValidator.EXPECT().Validate(
gomock.Any(),
gomock.Any(),
Expand Down Expand Up @@ -2932,7 +2932,7 @@ func (s *nodeSuite) TestExecuteSideEffectTask() {
expectExecute(nil)
err = root.ExecuteSideEffectTask(ctx, s.registry, executionKey, chasmTask, dummyValidationFn)
s.NoError(err)
s.True(backendValidtionFnCalled)
s.True(backendValidationFnCalled)
s.True(chasmTask.DeserializedTask.IsValid())

// Invalid task.
Expand All @@ -2957,7 +2957,7 @@ func (s *nodeSuite) TestExecuteSideEffectTask() {
expectExecute(executionErr)
err = root.ExecuteSideEffectTask(ctx, s.registry, executionKey, chasmTask, dummyValidationFn)
s.ErrorIs(executionErr, err)
s.True(backendValidtionFnCalled)
s.True(backendValidationFnCalled)
s.False(chasmTask.DeserializedTask.IsValid())
}

Expand Down
4 changes: 2 additions & 2 deletions client/client_bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (h *clientBeanImpl) GetRemoteAdminClient(cluster string) (adminservice.Admi
clusterInfo, clusterFound := h.clusterMetadata.GetAllClusterInfo()[cluster]
if !clusterFound {
// We intentionally return internal error here.
// This error could only happen with internal mis-configuration.
// This error could only happen with internal misconfiguration.
// This can happen when a namespace is config for multiple clusters. But those clusters are not connected.
// We also have logic in task processing to drop tasks when namespace cluster exclude a local cluster.
return nil, &serviceerror.Internal{
Expand Down Expand Up @@ -177,7 +177,7 @@ func (h *clientBeanImpl) GetRemoteFrontendClient(clusterName string) (grpc.Clien
clusterInfo, clusterFound := h.clusterMetadata.GetAllClusterInfo()[clusterName]
if !clusterFound {
// We intentionally return internal error here.
// This error could only happen with internal mis-configuration.
// This error could only happen with internal misconfiguration.
// This can happen when a namespace is config for multiple clusters. But those clusters are not connected.
// We also have logic in task processing to drop tasks when namespace cluster exclude a local cluster.
return nil, nil, &serviceerror.Internal{
Expand Down
Loading
Loading