Skip to content

Commit

Permalink
Merge branch 'main' into DaveSkender-patch-1
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Skender <[email protected]>
  • Loading branch information
DaveSkender authored Jan 6, 2025
2 parents bc3345a + d3593f5 commit e5b0d09
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Normalize line endings.
* text=lf
* text=auto eol=lf
3 changes: 1 addition & 2 deletions .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ jobs:
if [[ "${{ steps.settings.outputs.environ }}" == "nuget.org" ]]; then
echo "url=https://www.nuget.org/packages/${PACKAGE_NAME}/${{ steps.version_info.outputs.version }}" >> $GITHUB_OUTPUT
else
echo "url=https://github.com/${{ github.repository }}/packages/nuget/${PACKAGE_NAME}/${{ steps.version_info.outputs.version }}" >> $GITHUB_OUTPUT
fi
echo "url=https://github.com/${{ github.repository }}/pkgs/nuget/${PACKAGE_NAME}" >> $GITHUB_OUTPUT
- name: Build library
run: >
Expand Down
63 changes: 37 additions & 26 deletions .github/workflows/lint-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Pull request

on:
pull_request_target:
pull_request:
types:
- opened
- edited
- synchronize
- unlabeled

permissions:
pull-requests: write
Expand All @@ -21,49 +21,60 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:

# Configure additional validation for the subject based on a regex.
# We enforce that the subject starts with an uppercase character.
subjectPattern: ^([A-Z]).+$

# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: >
The subject "**{subject}**" in pull request "*{title}*"
needs to start with an uppercase character.
# If the PR contains one of these newline-delimited labels, the
# validation is skipped. If you want to rerun the validation when
# labels change, you might want to use the `labeled` and `unlabeled`
# event triggers in your workflow.
The subject "**{subject}**" must start with an uppercase character.
Example: "Add feature" instead of "add feature"
ignoreLabels: |
bot
dependencies
- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
### ⚠️ Pull Request title needs adjustment
### ⚠️ Invalid Pull Request title
Your PR title doesn't match our naming convention: `type: Subject`
Your PR title must follow the format: `type: Subject` where:
- `type` is one of the conventional commit types (in lowercase)
- `Subject` starts with an uppercase letter
> [!CAUTION]
> ${{ steps.lint_pr_title.outputs.error_message }}
#### Valid examples
- `feat: Add new RSI indicator`
- `fix: Correct MACD calculation`
- `chore: Update documentation`
- `test: Add unit tests for EMA`
- `refactor: Optimize moving average logic`
- `feat: Add API endpoint for market data`
- `fix: Resolve WebSocket connection issues`
- `chore: Update NuGet dependencies`
<details>
<summary>see more valid examples</summary>
#### Features & fixes
- `feat: Add API endpoint for market data`
- `fix: Resolve WebSocket connection issues`
#### Code quality
- `style: Format trading strategy classes`
- `refactor: Restructure trading engine components`
- `perf: Optimize trade order execution flow`
#### Documentation & testing
- `docs: Update API documentation`
- `test: Add unit tests for sign-in flow`
#### Infrastructure
- `build: Update .NET SDK version to 8.0`
- `ci: Add workflow for performance testing`
- `chore: Update NuGet dependencies`
#### Other
- `revert: Remove faulty market data provider`
See the [Conventional Commits specification](https://www.conventionalcommits.org) for more information.
See [Conventional Commits](https://www.conventionalcommits.org) for more details.
</details>
# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
Expand Down
52 changes: 0 additions & 52 deletions .github/workflows/test-codeql.yml

This file was deleted.

32 changes: 12 additions & 20 deletions .github/workflows/test-indicators.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Indicators
name: Test Indicators

on:
push:
branches: ["main"]

pull_request:
branches: ["*"]
workflow_dispatch:

jobs:
test:
Expand All @@ -20,38 +20,29 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
dotnet-version: ["9.x"]
# TODO: restore when runners have 9.x on all
# ["2.1.x", "6.x", "9.x"]
dotnet-version: ["6.0.x", "9.0.x"]

env:

# identifying primary configuration so only one reports coverage
IS_PRIMARY: ${{ matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '9.x' }}
IS_PRIMARY: ${{ matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '9.0.x' }}

# .NET SDK versions in the matrix that support `ga` quality spec
# versions before 5.x do not support it
SUPPORT_GA: ${{ contains(fromJson('["6.x", "9.x"]'), matrix.dotnet-version) }}
# Identifies the current target framework
TARGET_FRAMEWORK: >
${{ matrix.dotnet-version == '6.0.x' && 'net6.0' ||
matrix.dotnet-version == '9.0.x' && 'net9.0' }}
steps:

- name: Checkout source
uses: actions/checkout@v4

- name: Setup .NET
id: dotnet-new
uses: actions/setup-dotnet@v4
if: env.SUPPORT_GA == 'true'
with:
dotnet-version: ${{ matrix.dotnet-version }}
dotnet-version: "9.x"
dotnet-quality: "ga"

- name: Setup .NET (older)
uses: actions/setup-dotnet@v4
if: env.SUPPORT_GA == 'false'
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Build library
run: >
dotnet build
Expand All @@ -66,6 +57,7 @@ jobs:
run: >
dotnet test tests/indicators/Tests.Indicators.csproj
--configuration Release
--property:TestFramework="${{ env.TARGET_FRAMEWORK }}"
--no-build
--verbosity normal
--logger trx
Expand All @@ -84,8 +76,8 @@ jobs:
--logger trx
--results-directory ./test-other
- name: Post test summary
uses: dorny/test-reporter@v1
- name: Post test results
uses: dorny/test-reporter@v1.9.1
if: env.IS_PRIMARY == 'true' && always()
with:
name: Test results
Expand Down
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ _TeamCity*
*.coverage
*.coveragexml

# Visual Studio live unit testing
*.lutconfig

# NCrunch
_NCrunch_*
.*crunch*.local.xml
Expand Down Expand Up @@ -218,7 +221,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

Expand Down Expand Up @@ -314,7 +317,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
Expand All @@ -323,11 +326,11 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Jekyll site
_site/

# zip artifacts
.DS_Store
.DS_Store
2 changes: 1 addition & 1 deletion docs/pages/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ See the [guide]({{site.baseurl}}/guide/#content) and the [full list of indicator
Our [NuGet library](https://www.nuget.org/packages/Skender.Stock.Indicators) directly targets all current frameworks for peak performance, including the .NET Standard for older framework compatibility.

- .NET 9.0, 8.0, 6.0
- .NET Standard 2.1
- .NET Standard 2.1, 2.0

The compiled library package is [Common Language Specification (CLS) compliant](https://docs.microsoft.com/en-us/dotnet/standard/common-type-system) and can be used in other programming languages, including Python and everything in the .NET universe.

Expand Down
3 changes: 2 additions & 1 deletion src/Indicators.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net9.0;net8.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>13.0</LangVersion>

<Authors>Dave Skender</Authors>
<Product>Stock Indicators for .NET</Product>
Expand Down
39 changes: 39 additions & 0 deletions tests/indicators/_Initialize.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;

// GLOBALS & INITIALIZATION OF TEST DATA

Expand All @@ -8,6 +10,9 @@
[assembly: InternalsVisibleTo("Tests.Performance")]
namespace Tests.Common;

/// <summary>
/// Base class for all test classes, providing common test data and utilities.
/// </summary>
[TestClass]
public abstract class TestBase
{
Expand All @@ -27,3 +32,37 @@ public abstract class TestBase
internal static readonly IEnumerable<Quote> zeroesQuotes = TestData.GetZeros();
internal static readonly IEnumerable<(DateTime, double)> tupleNanny = TestData.GetTupleNaN();
}

/// <summary>
/// Test class for the startup of the test project.
/// </summary>
[TestClass]
public class Startup
{
/// <summary>
/// Displays the assembly location, name, version, and target framework
/// as a sanity check for test runner targeting.
/// </summary>
[TestMethod]
[TestCategory("ShowMe")]
public void ShowFramework()
{
// Get the assembly of any type from your Indicators project
Assembly assembly = typeof(Indicator).Assembly;

Console.WriteLine($"Assembly Location: {assembly.Location}");
Console.WriteLine($"Assembly Name: {assembly.GetName().Name}");
Console.WriteLine($"Assembly Version: {assembly.GetName().Version}");

// Get the target framework the assembly was built for
TargetFrameworkAttribute targetFrameworkAttribute = assembly
.GetCustomAttribute<TargetFrameworkAttribute>();

string frameworkName
= targetFrameworkAttribute?.FrameworkName ?? "Unknown";

Console.WriteLine($"Target Framework: {frameworkName}");

frameworkName.Should().NotBe("Unknown");
}
}

0 comments on commit e5b0d09

Please sign in to comment.