From db11534164c33ea63ad397db78c920af2653a94f Mon Sep 17 00:00:00 2001
From: Dave Skender <8432125+DaveSkender@users.noreply.github.com>
Date: Mon, 1 Apr 2024 05:06:05 -0400
Subject: [PATCH] ci: Add matrix unit tests (#1182)
---
.github/workflows/deploy-package.yml | 16 ++---
.../{docs-deploy.yml => deploy-website.yml} | 4 +-
...ic-pr-linter.yml => lint-pull-request.yml} | 18 ++++--
.../{lock.yml => lock-issues-pr.yml} | 0
...{docs-test-a11y.yml => test-docs-a11y.yml} | 6 +-
...ocs-test-links.yml => test-docs-links.yml} | 10 ++-
.../{build-examples.yml => test-examples.yml} | 6 +-
...est-indicators.yml => test-indicators.yml} | 62 ++++++++++++-------
.github/workflows/test-performance.yml | 8 +--
9 files changed, 81 insertions(+), 49 deletions(-)
rename .github/workflows/{docs-deploy.yml => deploy-website.yml} (97%)
rename .github/workflows/{semantic-pr-linter.yml => lint-pull-request.yml} (85%)
rename .github/workflows/{lock.yml => lock-issues-pr.yml} (100%)
rename .github/workflows/{docs-test-a11y.yml => test-docs-a11y.yml} (92%)
rename .github/workflows/{docs-test-links.yml => test-docs-links.yml} (89%)
rename .github/workflows/{build-examples.yml => test-examples.yml} (87%)
rename .github/workflows/{build-test-indicators.yml => test-indicators.yml} (52%)
diff --git a/.github/workflows/deploy-package.yml b/.github/workflows/deploy-package.yml
index 78b206e9c..d63a54ff6 100644
--- a/.github/workflows/deploy-package.yml
+++ b/.github/workflows/deploy-package.yml
@@ -18,7 +18,7 @@ on:
required: true
concurrency:
- group: package-deployer
+ group: ${{ inputs.environment }}
cancel-in-progress: true
jobs:
@@ -29,12 +29,12 @@ jobs:
steps:
- - name: Checkout repository
+ - name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- - name: Install GitVersion
+ - name: Setup GitVersion
uses: gittools/actions/gitversion/setup@v1.1.1
with:
versionSpec: "5.x"
@@ -62,7 +62,7 @@ jobs:
replace: "https://github.com/DaveSkender/Stock.Indicators/releases/tag/${{ steps.compose.outputs.version }}"
regex: false
- - name: Install .NET SDK
+ - name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
@@ -85,7 +85,7 @@ jobs:
--output NuGet
-p:PackageVersion=${{ steps.compose.outputs.version }}
- - name: Save NuGet package
+ - name: Save package
uses: actions/upload-artifact@v3
with:
name: packages
@@ -127,19 +127,19 @@ jobs:
echo "| Version ID | ${{ needs.build.outputs.version }} |"
} >> $GITHUB_STEP_SUMMARY
- - name: Install .NET SDK
+ - name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
dotnet-quality: "ga"
- - name: Install NuGet tool
+ - name: Setup NuGet
uses: nuget/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.NUGET_TOKEN }}
nuget-version: '6.x'
- - name: Download NuGet package
+ - name: Download package
uses: actions/download-artifact@v3
with:
name: packages
diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/deploy-website.yml
similarity index 97%
rename from .github/workflows/docs-deploy.yml
rename to .github/workflows/deploy-website.yml
index 55c9e21f4..be87f08fd 100644
--- a/.github/workflows/docs-deploy.yml
+++ b/.github/workflows/deploy-website.yml
@@ -1,6 +1,6 @@
name: Deploy website
-on: [workflow_dispatch]
+on: workflow_dispatch
concurrency:
group: docs-website
@@ -20,7 +20,7 @@ jobs:
- name: Checkout source
uses: actions/checkout@v4
- - name: Install Ruby
+ - name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: docs
diff --git a/.github/workflows/semantic-pr-linter.yml b/.github/workflows/lint-pull-request.yml
similarity index 85%
rename from .github/workflows/semantic-pr-linter.yml
rename to .github/workflows/lint-pull-request.yml
index a4113f57f..0be571cee 100644
--- a/.github/workflows/semantic-pr-linter.yml
+++ b/.github/workflows/lint-pull-request.yml
@@ -1,4 +1,4 @@
-name: "Lint PR"
+name: "Pull request"
on:
pull_request_target:
@@ -12,7 +12,7 @@ permissions:
jobs:
main:
- name: validate PR title
+ name: lint PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
@@ -39,7 +39,7 @@ jobs:
# event triggers in your workflow.
ignoreLabels: |
bot
- ignore-semantic-pull-request
+ dependencies
- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
@@ -57,9 +57,15 @@ jobs:
#### Pull request title naming convention
Our PR title name taxonomy is `type: Subject`, where **type** is typically
- *feat*, *fix*, or *chore*, and **subject** is a phrase (proper noun) that starts with a capitalized letter.
- The *chore* type usually has a subject that starts with an action verb like *Add* or *Update*.
- Examples: `feat: Admin portal login`, `fix: Divide by zero bug in SMA`, and `chore: Update user docs`.
+ *feat*, *fix*, or *chore*, and **subject** is a phrase (proper noun) that starts
+ with a capitalized letter. The *chore* type usually has a subject that starts
+ with an action verb like *Add* or *Update*. Examples:
+
+ - _feat: Admin portal login_
+ - _fix: Divide by zero bug in SMA_
+ - _chore: Update packages_
+ - _docs: Improve setup guidance_
+
See the [Conventional Commits specification](https://www.conventionalcommits.org) for more information.
# Delete a previous comment when the issue has been resolved
diff --git a/.github/workflows/lock.yml b/.github/workflows/lock-issues-pr.yml
similarity index 100%
rename from .github/workflows/lock.yml
rename to .github/workflows/lock-issues-pr.yml
diff --git a/.github/workflows/docs-test-a11y.yml b/.github/workflows/test-docs-a11y.yml
similarity index 92%
rename from .github/workflows/docs-test-a11y.yml
rename to .github/workflows/test-docs-a11y.yml
index 4c6918c20..f6a62dd26 100644
--- a/.github/workflows/docs-test-a11y.yml
+++ b/.github/workflows/test-docs-a11y.yml
@@ -19,7 +19,7 @@ jobs:
- name: Checkout source
uses: actions/checkout@v4
- - name: Install Ruby
+ - name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: docs
@@ -56,3 +56,7 @@ jobs:
npx pa11y-ci \
--sitemap http://127.0.0.1:4000/sitemap.xml \
--sitemap-exclude "/*.pdf"
+
+ - name: Kill site (failsafe)
+ if: always()
+ run: pkill -f jekyll
diff --git a/.github/workflows/docs-test-links.yml b/.github/workflows/test-docs-links.yml
similarity index 89%
rename from .github/workflows/docs-test-links.yml
rename to .github/workflows/test-docs-links.yml
index 0c61cea03..28aa2d6de 100644
--- a/.github/workflows/docs-test-links.yml
+++ b/.github/workflows/test-docs-links.yml
@@ -19,7 +19,7 @@ jobs:
- name: Checkout source
uses: actions/checkout@v4
- - name: Install Ruby
+ - name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: docs
@@ -34,7 +34,7 @@ jobs:
pwd
bundle install
- - name: Install HTML Proofer
+ - name: Setup HTML Proofer
run: gem install html-proofer
- name: Replace "data-src"
@@ -68,6 +68,10 @@ jobs:
run: |
htmlproofer _site \
--no-enforce-https \
- --ignore-status-codes "0,403,406,408,429,503,999" \
+ --ignore-status-codes "0,302,403,406,408,429,503,999" \
--swap-urls "https\://dotnet.stockindicators.dev:http\://127.0.0.1:4000" \
--ignore-urls "/fonts.gstatic.com/"
+
+ - name: Kill site (failsafe)
+ if: always()
+ run: pkill -f jekyll
diff --git a/.github/workflows/build-examples.yml b/.github/workflows/test-examples.yml
similarity index 87%
rename from .github/workflows/build-examples.yml
rename to .github/workflows/test-examples.yml
index 8430468d9..5cdf1666a 100644
--- a/.github/workflows/build-examples.yml
+++ b/.github/workflows/test-examples.yml
@@ -14,15 +14,15 @@ on:
jobs:
build:
- name: build projects
+ name: build only
runs-on: ubuntu-latest
steps:
- - name: Checkout repository
+ - name: Checkout source
uses: actions/checkout@v4
- - name: Install .NET SDK
+ - name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
diff --git a/.github/workflows/build-test-indicators.yml b/.github/workflows/test-indicators.yml
similarity index 52%
rename from .github/workflows/build-test-indicators.yml
rename to .github/workflows/test-indicators.yml
index 6a784203f..8ef1d4afc 100644
--- a/.github/workflows/build-test-indicators.yml
+++ b/.github/workflows/test-indicators.yml
@@ -8,30 +8,48 @@ on:
branches: ["main"]
jobs:
-
test:
name: unit tests
- runs-on: ubuntu-latest
+ runs-on: ${{ matrix.os }}
- steps:
+ permissions:
+ contents: read
+ pull-requests: write
+
+ strategy:
+ matrix:
+ os: [windows-latest, ubuntu-latest, macos-latest]
+ dotnet-version: ["2.0.x", "6.x", "8.x"]
- - name: Clean workspace
- run: |
- rm -rf ./test-indicators/* || true
- rm -rf ./test-indicators/.??* || true
- rm -rf ./NuGet/* || true
- rm -rf ./NuGet/.??* || true
+ env:
- - name: Checkout repository
+ # identifying primary configuration so only one reports coverage
+ IS_PRIMARY: ${{ matrix.os == 'ubuntu-latest' && matrix.dotnet-version == '8.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", "8.x"]'), matrix.dotnet-version) }}
+
+ steps:
+
+ - name: Checkout source
uses: actions/checkout@v4
- - name: Install .NET SDK
+ - name: Setup .NET
+ id: dotnet-new
uses: actions/setup-dotnet@v4
+ if: env.SUPPORT_GA == 'true'
with:
- dotnet-version: "8.x"
+ dotnet-version: ${{ matrix.dotnet-version }}
dotnet-quality: "ga"
- - name: Build solution
+ - 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
--configuration Release
@@ -39,7 +57,6 @@ jobs:
-warnAsError
- name: Test indicators
- id: test-library
env:
ALPACA_KEY: ${{ secrets.ALPACA_KEY }}
ALPACA_SECRET: ${{ secrets.ALPACA_SECRET }}
@@ -52,8 +69,10 @@ jobs:
--collect:"XPlat Code Coverage"
--results-directory ./test-indicators
+ # the remaining steps are only needed from one primary instance
+
- name: Test other items
- id: test-other
+ if: env.IS_PRIMARY == 'true'
run: >
dotnet test tests/other/Tests.Other.csproj
--configuration Release
@@ -62,20 +81,19 @@ jobs:
--logger trx
--results-directory ./test-other
- - name: Post tests summary
- uses: bibipkins/dotnet-test-reporter@v1.3.3
- if: ${{ github.event_name == 'pull_request' && (success() || (failure() && (steps.test-library.conclusion == 'failure' || steps.test-other.conclusion == 'failure'))) }}
+ - name: Post test summary
+ uses: bibipkins/dotnet-test-reporter@v1.4.1
+ if: env.IS_PRIMARY == 'true' && always()
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-title: ""
- results-path: ./test-indicators/**/*.trx
+ results-path: ./test-indicators/**/*.trx
coverage-path: ./test-indicators/**/coverage.cobertura.xml
coverage-type: cobertura
- - name: Post coverage to Codacy
+ - name: Publish coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
+ if: env.IS_PRIMARY == 'true'
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./test-indicators/**/coverage.cobertura.xml
- # or a comma-separated list for multiple reports
- # coverage-reports: ,
diff --git a/.github/workflows/test-performance.yml b/.github/workflows/test-performance.yml
index 722fd0346..b5f40770c 100644
--- a/.github/workflows/test-performance.yml
+++ b/.github/workflows/test-performance.yml
@@ -4,7 +4,7 @@ concurrency:
group: test-performance
cancel-in-progress: true
-on: [workflow_dispatch]
+on: workflow_dispatch
jobs:
analyze:
@@ -12,12 +12,12 @@ jobs:
steps:
- - name: Checkout repository
+ - name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- - name: Install GitVersion
+ - name: Setup GitVersion
uses: gittools/actions/gitversion/setup@v1.1.1
with:
versionSpec: "5.x"
@@ -31,7 +31,7 @@ jobs:
useConfigFile: true
configFilePath: gitversion.yml
- - name: Install .NET SDK
+ - name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"