diff --git a/.github/workflows/doctests.yml b/.github/workflows/doctests.yml deleted file mode 100644 index b170bedf..00000000 --- a/.github/workflows/doctests.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Documentation Tests - -on: - push: - pull_request: - - workflow_dispatch: - -permissions: - contents: read - -concurrency: - group: ${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - doctests: - runs-on: ubuntu-latest - services: - redis-stack: - image: redis/redis-stack-server:latest - options: >- - --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 - ports: - - 6379:6379 - steps: - - uses: actions/checkout@v3 - - name: .NET Core 6 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '6.0.x' - - name: .NET Core 7 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '7.0.x' - - name: run tests - working-directory: tests/Doc - run: | - dotnet test diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index ac6128a0..d0a4eaf2 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -12,7 +12,7 @@ on: - cron: "0 1 * * *" concurrency: - group: ${{ github.event.pull_request.number || github.ref }} + group: ${{ github.event.pull_request.number || github.ref }}-integration cancel-in-progress: true jobs: @@ -22,6 +22,7 @@ jobs: with: redis_stack_type: cluster clr_version: net6.0 + dotnet_sdk_version: 6.0.0 dotenv_file: .github/cluster.env secrets: inherit @@ -36,6 +37,7 @@ jobs: with: redis_stack_type: ${{matrix.redis-stack-type}} clr_version: net6.0 + dotnet_sdk_version: 6.0.0 dotenv_file: .github/standalone.env secrets: inherit @@ -45,6 +47,7 @@ jobs: with: redis_stack_type: cluster clr_version: net7.0 + dotnet_sdk_version: 7.0.0 dotenv_file: .github/cluster.env secrets: inherit @@ -59,6 +62,7 @@ jobs: with: redis_stack_type: ${{matrix.redis-stack-type}} clr_version: net7.0 + dotnet_sdk_version: 7.0.0 dotenv_file: .github/standalone.env secrets: inherit @@ -68,6 +72,7 @@ jobs: with: redis_stack_type: cluster clr_version: net8.0 + dotnet_sdk_version: 8.0.0 dotenv_file: .github/cluster.env secrets: inherit @@ -82,6 +87,7 @@ jobs: with: redis_stack_type: ${{matrix.redis-stack-type}} clr_version: net8.0 + dotnet_sdk_version: 8.0.0 dotenv_file: .github/standalone.env secrets: inherit diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 3ef14d77..7c776851 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -3,7 +3,7 @@ name: Format check on pull request on: pull_request concurrency: - group: ${{ github.event.pull_request.number || github.ref }} + group: ${{ github.event.pull_request.number || github.ref }}-linter cancel-in-progress: true jobs: @@ -14,9 +14,7 @@ jobs: run: dotnet tool install -g dotnet-format - name: Checkout repo - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} + uses: actions/checkout@v3 - name: lint run: | diff --git a/.github/workflows/nuget-release.yml b/.github/workflows/nuget-release.yml index ff128062..5a9b5d23 100644 --- a/.github/workflows/nuget-release.yml +++ b/.github/workflows/nuget-release.yml @@ -9,17 +9,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up .NET Core 6 - uses: actions/setup-dotnet@v2 + - name: Set up .NET Core 8 + uses: actions/setup-dotnet@v3 with: - dotnet-version: '6.0.x' - - name: Set up .NET Core 7 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '7.0.x' + dotnet-version: 8 + - name: Check .NET version + run: dotnet --version + - name: Check .NET SDKs + run: dotnet --list-sdks + - name: Check .NET runtimes + run: dotnet --list-runtimes - name: Build run: dotnet pack -c Release --output . - - name: Publish uses: alirezanet/publish-nuget@v3.0.3 with: diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index 8d0b19cf..cf994820 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -7,15 +7,22 @@ on: required: true type: string + # Target .NET framework, i.e. "net6.0". clr_version: required: true type: string + # SDK version, as obtained when running `dotnet --list-sdks`, + # i.e. "6.0.418", although it is safe to use '6.0.0' because + # in global.json we set the rollForward strategy to "latestMinor". + dotnet_sdk_version: + required: true + type: string + dotenv_file: required: true type: string jobs: - build_and_test: name: Test runs-on: ubuntu-latest @@ -25,24 +32,12 @@ jobs: PASSWORD: ${{ secrets.PASSWORD }} ENDPOINT: ${{ secrets.ENDPOINT }} steps: - - uses: actions/checkout@v3 - - name: .NET Core 6 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '6.0.x' - - - name: .NET Core 7 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '7.0.x' - - - name: .NET Core 8 preview + - name: .NET Core 8 uses: actions/setup-dotnet@v3 with: dotnet-version: 8 - dotnet-quality: 'preview' - name: run redis-stack-server docker working-directory: .github @@ -53,16 +48,27 @@ jobs: with: env-file: ${{inputs.dotenv_file}} + # Make sure only the desired dotnet version is set both as target and as active SDK. + - name: Tweak target frameworks + run: | + find . -name '*.csproj' | xargs -I {} sed -E -i 's|.*|${{inputs.clr_version}}|' {} + find . -name '*.csproj' | xargs cat + jq -n --arg version ${{inputs.dotnet_sdk_version}} '{"sdk":{"version":$version,"rollForward":"latestMinor"}}' > global.json + - name: Check .NET version + run: dotnet --version + - name: Check .NET SDKs + run: dotnet --list-sdks + - name: Check .NET runtimes + run: dotnet --list-runtimes - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true - name: Test run: | - echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_ca.pem - echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user.crt - echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user_private.key - ls -R + echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/${{inputs.clr_version}}/redis_ca.pem + echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/${{inputs.clr_version}}/redis_user.crt + echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/${{inputs.clr_version}}/redis_user_private.key dotnet test -f ${{inputs.clr_version}} --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - name: Codecov uses: codecov/codecov-action@v3 @@ -71,4 +77,3 @@ jobs: verbose: true - name: Build run: dotnet pack -c Release - diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index a1413e96..228297d5 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -4,7 +4,7 @@ on: pull_request: concurrency: - group: ${{ github.event.pull_request.number || github.ref }} + group: ${{ github.event.pull_request.number || github.ref }}-spellcheck cancel-in-progress: true jobs: diff --git a/.gitignore b/.gitignore index 3cf3c6c1..fd1be9e5 100644 --- a/.gitignore +++ b/.gitignore @@ -405,3 +405,6 @@ tests/NRedisStack.Tests/redis_ca.pem tests/NRedisStack.Tests/redis_credentials/redis_user_private.key tests/NRedisStack.Tests/redis_credentials/redis_user.crt .env + +# global.json +global.json diff --git a/src/NRedisStack/NRedisStack.csproj b/src/NRedisStack/NRedisStack.csproj index 58467115..df5fbeb8 100644 --- a/src/NRedisStack/NRedisStack.csproj +++ b/src/NRedisStack/NRedisStack.csproj @@ -2,7 +2,7 @@ enable - netstandard2.0;net6.0;net7.0 + netstandard2.0;net6.0;net7.0;net8.0 latest enable Redis Open Source diff --git a/src/NRedisStack/TimeSeries/TimeSeriesAux.cs b/src/NRedisStack/TimeSeries/TimeSeriesAux.cs index 65ad7c94..54c20f65 100644 --- a/src/NRedisStack/TimeSeries/TimeSeriesAux.cs +++ b/src/NRedisStack/TimeSeries/TimeSeriesAux.cs @@ -81,7 +81,7 @@ public static void AddOnDuplicate(this IList args, TsDuplicatePolicy? po public static void AddAlign(this IList args, TimeStamp? alignMaybe) { - if (alignMaybe is {} align) + if (alignMaybe is { } align) { args.Add(TimeSeriesArgs.ALIGN); args.Add(align.Value); @@ -251,7 +251,7 @@ public static List BuildTsIncrDecrByArgs(string key, double value, TimeS IReadOnlyCollection? labels, bool? uncompressed, long? chunkSizeBytes) { var args = new List { key, value }; - if (timestampMaybe is {} timestamp) args.AddTimeStamp(timestamp); + if (timestampMaybe is { } timestamp) args.AddTimeStamp(timestamp); args.AddRetentionTime(retentionTime); args.AddChunkSize(chunkSizeBytes); if (labels != null) args.AddLabels(labels); diff --git a/tests/Doc/Doc.csproj b/tests/Doc/Doc.csproj index c8fef667..99d64969 100644 --- a/tests/Doc/Doc.csproj +++ b/tests/Doc/Doc.csproj @@ -1,8 +1,8 @@ $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::get_Windows()))) - net6.0;net7.0;net481 - net6.0;net7.0 + net6.0;net7.0;net8.0;net481 + net6.0;net7.0;net8.0 enable enable latest diff --git a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj index e66bf0a1..1caa8cc8 100644 --- a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj +++ b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj @@ -1,8 +1,8 @@ $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::get_Windows()))) - net6.0;net7.0;net481 - net6.0;net7.0 + net6.0;net7.0;net8.0;net481 + net6.0;net7.0;net8.0 enable enable latest diff --git a/tests/NRedisStack.Tests/RedisFixture.cs b/tests/NRedisStack.Tests/RedisFixture.cs index aca9ba67..f90389c6 100644 --- a/tests/NRedisStack.Tests/RedisFixture.cs +++ b/tests/NRedisStack.Tests/RedisFixture.cs @@ -32,7 +32,9 @@ public RedisFixture() ConfigurationOptions clusterConfig = new ConfigurationOptions { - EndPoints = endpoints + EndPoints = endpoints, + AsyncTimeout = 10000, + SyncTimeout = 10000 }; isOSSCluster = true; diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs index 34b9ee38..391640d8 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs @@ -318,22 +318,22 @@ public void TestMRangeLatest() var compactedLabel = new TimeSeriesLabel("compact", "true"); string primaryTsKey = _keys[0], compactedTsKey = _keys[1]; var compactionRule = new TimeSeriesRule( - compactedTsKey, + compactedTsKey, (long)TimeSpan.FromHours(1).TotalMilliseconds, // 1h used to force partial bucket TsAggregation.Sum); - ts.Create(primaryTsKey, labels: [label]); - ts.Create(compactedTsKey, labels: [label, compactedLabel]); + ts.Create(primaryTsKey, labels: new[] { label }); + ts.Create(compactedTsKey, labels: new[] { label, compactedLabel }); ts.CreateRule(primaryTsKey, compactionRule); - var tuples = CreateData(ts, 50, [primaryTsKey]); + var tuples = CreateData(ts, 50, new[] { primaryTsKey }); - var results = ts.MRange("-", "+", ["key=MRangeLatest", "compact=true"], latest: true); + var results = ts.MRange("-", "+", new[] { "key=MRangeLatest", "compact=true" }, latest: true); Assert.Single(results); Assert.Equal(compactedTsKey, results[0].key); Assert.NotEmpty(results[0].values); Assert.Equal(tuples.Sum(x => x.Val), results[0].values.Sum(x => x.Val)); - results = ts.MRange("-", "+", ["key=MRangeLatest", "compact=true"], latest: false); + results = ts.MRange("-", "+", new[] { "key=MRangeLatest", "compact=true" }, latest: false); Assert.Single(results); Assert.Equal(compactedTsKey, results[0].key); Assert.Empty(results[0].values);