Skip to content

Commit

Permalink
SDK improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Feb 17, 2022
1 parent 6cbda88 commit 423547f
Show file tree
Hide file tree
Showing 79 changed files with 3,036 additions and 1,004 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
paths-ignore:
- '**.md'
- 'appveyor*'
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '0 1 * * 2'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
36 changes: 36 additions & 0 deletions .github/workflows/linux-macOS-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build on Linux and macOS
on:
push:
branches: [ master ]
paths-ignore:
- '**.md'
- 'appveyor*'
pull_request:
types: [opened, synchronize, reopened]

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
build-test:
name: Build & test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
- name: Restore
run: dotnet restore
- name: Test
run: |
dotnet test src/ConfigCat.Client.Tests/ConfigCat.Client.Tests.csproj -c Release -f netcoreapp3.1 --no-restore
dotnet test src/ConfigCat.Client.Tests/ConfigCat.Client.Tests.csproj -c Release -f net5.0 --no-restore
dotnet test src/ConfigCat.Client.Tests/ConfigCat.Client.Tests.csproj -c Release -f net6.0 --no-restore
54 changes: 54 additions & 0 deletions .github/workflows/sonar-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: SonarCloud Analysis
on:
push:
branches: [ master ]
paths-ignore:
- '**.md'
- 'appveyor*'
pull_request:
types: [opened, synchronize, reopened]

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

jobs:
analysis:
name: Run analysis & code coverage
runs-on: windows-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v1
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"net-sdk" /d:sonar.host.url="https://sonarcloud.io" /o:"configcat" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml" -d:sonar.cs.vstest.reportsPaths="**/TestResults/*.trx" /v:"${{ github.run_number }}" /d:sonar.exclusions="ConfigCatClient/Versioning/*" /d:sonar.coverage.exclusions="ConfigCatClient/Versioning/*"
dotnet test src\ConfigCat.Client.Tests\ConfigCat.Client.Tests.csproj -c Release --logger trx --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
27 changes: 6 additions & 21 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
version: 6.2.{build}
image: Visual Studio 2019
version: 6.3.{build}
image: Visual Studio 2022
configuration: Release
platform: Any CPU
environment:
SONARQUBE_TOKEN:
secure: Gcyk5/iAGeDpK2ckvhfw0zWpiiEt/jSg6GcxaGIriN4BkfV7h7kEnt1dkT6YMuOE
dotnet_csproj:
patch: true
file: '**\*.csproj'
Expand All @@ -13,30 +10,18 @@ dotnet_csproj:
assembly_version: '{version}'
file_version: '{version}'
informational_version: '{version}'
install:
- set JAVA_HOME=C:\Program Files\Java\jdk11
- set PATH=%JAVA_HOME%\bin;%PATH%
build_script:
- cmd: echo __BUILD__
- msbuild /verbosity:normal /t:Restore src/ConfigCatClient.sln
- msbuild /verbosity:normal /t:Build src/ConfigCatClient.sln
after_build:
- cmd: echo __PACK__
- msbuild /t:Pack /p:IncludeSymbols=true /p:Configuration=%configuration% /p:PackageOutputPath=..\..\artifacts /p:SymbolPackageFormat=snupkg src\ConfigCatClient\ConfigCatClient.csproj
before_test:
- ps: choco install opencover.portable --no-progress
- ps: choco install codecov --no-progress
test_script:
- cmd: echo __TEST_AND_COVERAGE__
- ps: . .\set-debug-type.ps1 src\ConfigCatClient\ConfigCatClient.csproj
- cmd: runtests.ci.cmd
- codecov -f "coverage.xml"
after_test:
- cmd: echo __ANALYSIS__
- ps: 'if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { choco install "sonarscanner-msbuild-net46" -y --no-progress }'
- ps: 'if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { SonarScanner.MSBuild.exe begin /k:"net-sdk" /d:sonar.host.url="https://sonarcloud.io" /o:"configcat" /d:sonar.login="$env:SONARQUBE_TOKEN" /d:sonar.cs.opencover.reportsPaths="coverage.xml" /d:sonar.cs.vstest.reportsPaths="testresult.xml" /v:$env:APPVEYOR_BUILD_VERSION /d:sonar.branch.name="$env:APPVEYOR_REPO_BRANCH" /d:sonar.exclusions="ConfigCatClient/Versioning/*" /d:sonar.coverage.exclusions="ConfigCatClient/Versioning/*" }'
- msbuild /p:Configuration=%configuration% /t:Build src/ConfigCatClient.sln
- ps: 'if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { SonarScanner.MSBuild.exe end /d:sonar.login="$env:SONARQUBE_TOKEN" }'
- dotnet test test\stashbox.tests.csproj -f net45 -c %configuration% --no-build
- dotnet test test\stashbox.tests.csproj -f netcoreapp3.1 -c %configuration% --no-build
- dotnet test test\stashbox.tests.csproj -f net5.0 -c %configuration% --no-build
- dotnet test test\stashbox.tests.csproj -f net6.0 -c %configuration% --no-build
artifacts:
- path: artifacts\ConfigCat.Client.*.*nupkg
name: NuGet
Expand Down
73 changes: 61 additions & 12 deletions src/ConfigCat.Client.Tests/BaseUrlTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#pragma warning disable CS0618 // Type or member is obsolete
namespace ConfigCat.Client.Tests
{
[TestCategory(TestCategories.Integration)]
Expand All @@ -12,18 +13,34 @@ public class BaseUrlTests
private readonly Uri workingBaseUrl = new Uri("https://cdn.configcat.com");
private readonly Uri notWorkingBaseUrl = new Uri("https://thiswillnotwork.configcat.com");

[TestMethod]
public void BaseUrl_Override_AutoPoll_Works()
[DataRow(true)]
[DataRow(false)]
[DataTestMethod]
public void BaseUrl_Override_AutoPoll_Works(bool useNewCreateApi)
{
var client = ConfigCatClientBuilder.Initialize(SDKKEY)
var client = useNewCreateApi
? new ConfigCatClient(options =>
{
options.SdkKey = SDKKEY;
options.PollingMode = PollingModes.AutoPoll();
options.BaseUrl = workingBaseUrl;
})
: ConfigCatClientBuilder.Initialize(SDKKEY)
.WithAutoPoll()
.WithBaseUrl(workingBaseUrl)
.Create();

var actual = client.GetValue("stringDefaultCat", "N/A");
Assert.AreEqual("Cat", actual);

client = ConfigCatClientBuilder.Initialize(SDKKEY)
client = useNewCreateApi
? new ConfigCatClient(options =>
{
options.SdkKey = SDKKEY;
options.PollingMode = PollingModes.AutoPoll();
options.BaseUrl = notWorkingBaseUrl;
})
: ConfigCatClientBuilder.Initialize(SDKKEY)
.WithAutoPoll()
.WithBaseUrl(notWorkingBaseUrl)
.Create();
Expand All @@ -32,18 +49,34 @@ public void BaseUrl_Override_AutoPoll_Works()
Assert.AreEqual("N/A", actual);
}

[TestMethod]
public void BaseUrl_Override_ManualPoll_Works()
[DataRow(true)]
[DataRow(false)]
[DataTestMethod]
public void BaseUrl_Override_ManualPoll_Works(bool useNewCreateApi)
{
var client = ConfigCatClientBuilder.Initialize(SDKKEY)
var client = useNewCreateApi
? new ConfigCatClient(options =>
{
options.SdkKey = SDKKEY;
options.PollingMode = PollingModes.ManualPoll;
options.BaseUrl = workingBaseUrl;
})
: ConfigCatClientBuilder.Initialize(SDKKEY)
.WithManualPoll()
.WithBaseUrl(workingBaseUrl)
.Create();
client.ForceRefresh();
var actual = client.GetValue("stringDefaultCat", "N/A");
Assert.AreEqual("Cat", actual);

client = ConfigCatClientBuilder.Initialize(SDKKEY)
client = useNewCreateApi
? new ConfigCatClient(options =>
{
options.SdkKey = SDKKEY;
options.PollingMode = PollingModes.ManualPoll;
options.BaseUrl = notWorkingBaseUrl;
})
: ConfigCatClientBuilder.Initialize(SDKKEY)
.WithManualPoll()
.WithBaseUrl(notWorkingBaseUrl)
.Create();
Expand All @@ -52,18 +85,34 @@ public void BaseUrl_Override_ManualPoll_Works()
Assert.AreEqual("N/A", actual);
}

[TestMethod]
public void BaseUrl_Override_LazyLoad_Works()
[DataRow(true)]
[DataRow(false)]
[DataTestMethod]
public void BaseUrl_Override_LazyLoad_Works(bool useNewCreateApi)
{
var client = ConfigCatClientBuilder.Initialize(SDKKEY)
var client = useNewCreateApi
? new ConfigCatClient(options =>
{
options.SdkKey = SDKKEY;
options.PollingMode = PollingModes.LazyLoad();
options.BaseUrl = workingBaseUrl;
})
: ConfigCatClientBuilder.Initialize(SDKKEY)
.WithLazyLoad()
.WithBaseUrl(workingBaseUrl)
.Create();

var actual = client.GetValue("stringDefaultCat", "N/A");
Assert.AreEqual("Cat", actual);

client = ConfigCatClientBuilder.Initialize(SDKKEY)
client = useNewCreateApi
? new ConfigCatClient(options =>
{
options.SdkKey = SDKKEY;
options.PollingMode = PollingModes.LazyLoad();
options.BaseUrl = notWorkingBaseUrl;
})
: ConfigCatClientBuilder.Initialize(SDKKEY)
.WithLazyLoad()
.WithBaseUrl(notWorkingBaseUrl)
.Create();
Expand Down
Loading

0 comments on commit 423547f

Please sign in to comment.