ci: Add matrix unit tests #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: indicators | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
test: | |
name: unit tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
dotnet-version: ["2.0.x", "3.x", "6.x", "8.x"] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v4 | |
if: ${{ contains(fromJson('["6.x", "8.x"]'), matrix.dotnet-version) }} | |
with: | |
dotnet-version: ${{ matrix.dotnet-version }} | |
dotnet-quality: "ga" | |
- name: Setup .NET SDK (older) | |
uses: actions/setup-dotnet@v4 | |
if: ${{ contains(fromJson('["2.0.x", "3.x"]'), matrix.dotnet-version) }} | |
with: | |
dotnet-version: ${{ matrix.dotnet-version }} | |
# older SDK do not support 'ga' | |
- name: Build solution | |
run: > | |
dotnet build | |
--configuration Release | |
--property:ContinuousIntegrationBuild=true | |
-warnAsError | |
- name: Test indicators | |
id: test-library | |
env: | |
ALPACA_KEY: ${{ secrets.ALPACA_KEY }} | |
ALPACA_SECRET: ${{ secrets.ALPACA_SECRET }} | |
run: > | |
dotnet test tests/indicators/Tests.Indicators.csproj | |
--configuration Release | |
--no-build | |
--verbosity normal | |
--logger trx | |
--collect:"XPlat Code Coverage" | |
--results-directory ./test-indicators | |
- name: Test other items | |
id: test-other | |
run: > | |
dotnet test tests/other/Tests.Other.csproj | |
--configuration Release | |
--no-build | |
--verbosity normal | |
--logger trx | |
--results-directory ./test-other | |
- name: Post tests summary | |
uses: bibipkins/[email protected] | |
if: ${{ matrix.dotnet-version == '8.x' && matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request' && (success() || (failure() && (steps.test-library.conclusion == 'failure' || steps.test-other.conclusion == 'failure'))) }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
comment-title: "" | |
results-path: ./test-indicators/**/*.trx | |
coverage-path: ./test-indicators/**/coverage.cobertura.xml | |
coverage-type: cobertura | |
- name: Post coverage to Codacy | |
uses: codacy/codacy-coverage-reporter-action@v1 | |
if: ${{ matrix.dotnet-version == '8.x' && matrix.os == 'ubuntu-latest' }} | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
coverage-reports: ./test-indicators/**/coverage.cobertura.xml |