diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml new file mode 100644 index 00000000..3ef14d77 --- /dev/null +++ b/.github/workflows/linter.yaml @@ -0,0 +1,32 @@ +name: Format check on pull request + +on: pull_request + +concurrency: + group: ${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + dotnet-format: + runs-on: windows-latest + steps: + - name: Install dotnet-format + run: dotnet tool install -g dotnet-format + + - name: Checkout repo + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: lint + run: | + dotnet format + + - name: Check for modified files + run: | + if (git status | Select-String -Pattern 'modified') { + Write-Host "Modified files found. Please run dotnet format and commit the changes." + exit 1 + } else { + Write-Host "No modified files found." + } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9eaade76..7c5e007b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,8 +35,8 @@ Here's how to get started with your code contribution: 3. Write your tests 4. Use the `docker run -p 6379:6379 -it redis/redis-stack-server:edge` as your local environment for running the functional tests. You can also use Development Container as described below. -5. Make sure your tests pass using `dotnet test` -6. Push your changes to GitHub +5. Run dotnet format to make sure your code is formatted +6. Make sure your tests pass using `dotnet test` 7. Open a pull request ## Development Container diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 2a4ecbe3..74703d1d 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -2438,13 +2438,13 @@ public async Task TestAddAndGetSuggestionAsync() Assert.True(await ft.SugAddAsync(key, noMatch, 1d) > 0); // test that with a partial part of that string will have the entire word returned - Assert.Single((await ft.SugGetAsync(key, suggestion.Substring(0, 3), true, max: 5))); + Assert.Single(await ft.SugGetAsync(key, suggestion.Substring(0, 3), true, max: 5)); // turn off fuzzy start at second word no hit Assert.Empty((await ft.SugGetAsync(key, noMatch.Substring(1, 6), false, max: 5))); // my attempt to trigger the fuzzy by 1 character - Assert.Single((await ft.SugGetAsync(key, noMatch.Substring(1, 6), true, max: 5))); + Assert.Single(await ft.SugGetAsync(key, noMatch.Substring(1, 6), true, max: 5)); } [Fact] diff --git a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs index 2b7e0741..856c9bca 100644 --- a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs +++ b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs @@ -66,6 +66,7 @@ public override string? Skip break; case Is.Standalone: + if (!redisFixture.isOSSCluster) { skipReason = skipReason + " Redis server is not OSS cluster."; @@ -74,7 +75,7 @@ public override string? Skip break; } } - // Version check (if Is.Standalone/Is.Cluster is set then ) + // Version check (if Is.Standalone/Is.OSSCluster is set then ) var serverVersion = redisFixture.Redis.GetServer(redisFixture.Redis.GetEndPoints()[0]).Version; var targetVersion = new Version(_targetVersion); diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index 6c91c9c2..295a279e 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -22,7 +22,6 @@ public void CreateTopKFilter() var res = topk.Add(key, "bb", "cc"); Assert.True(res![0].IsNull && res[1].IsNull); - Assert.Equal(topk.Query(key, "bb", "gg", "cc"), new bool[] { true, false, true }); Assert.False(topk.Query(key, "notExists")); diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index c96240c4..a3e8aa05 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -30,7 +30,7 @@ public void TestJsonTransaction() [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] [Obsolete] - public async Task TestModulsTransaction() + public void TestModulsTransaction() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); @@ -82,7 +82,7 @@ public async Task TestModulsTransaction() [SkipIfRedis(Is.OSSCluster)] [Obsolete] - public async Task TestModulsTransactionWithoutGraph() + public void TestModulsTransactionWithoutGraph() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL");