Skip to content

Commit

Permalink
Lint checks in CI runs (#183)
Browse files Browse the repository at this point in the history
* delete mock

* coverage

* fix test

* indent

* change to var - check

* cluster test

* add opthin to connect cluster with dotnet test

* use key in topk tests

* get env vars inside RedisFixture

* skip if redis

* add skip where needed

* Execute broadcast

* delete cluster tests

* RedisFixture fix

* add to contributing

* run cluster on CI

* wip

* fix /

* -d

* delete restore

* return restore

* add -RC3

* add RC3 to docker-compose

* try define both .net 6 and 7

* Skip if cluster where needed

* add names

* skip configOnTimeout if cluster

* try to fix win tests

* tests names +fix win version

* fix versions

* versions

* win verer

* wording

* dotnet format

* format

* format

* add linter.yaml

* update linter

* lint on push

* change linter

* create lint problems to see what happen

* linter force and run

* try to fix yml

* dotnet format

* tell the contributer to run dotnet format in the CONTRIBUTING.md

* disable multi runs

* fix warnings

* chayom changes

---------

Co-authored-by: Chayim <[email protected]>
Co-authored-by: Chayim I. Kirshen <[email protected]>
  • Loading branch information
3 people authored Sep 27, 2023
1 parent 30dee6e commit 3d639ce
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -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."
}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/Search/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion tests/NRedisStack.Tests/SkipIfRedisAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public override string? Skip
break;

case Is.Standalone:

if (!redisFixture.isOSSCluster)
{
skipReason = skipReason + " Redis server is not OSS cluster.";
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion tests/NRedisStack.Tests/TopK/TopKTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/TransactionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 3d639ce

Please sign in to comment.