DOTNET CIパイプライン
25061 ワード
マイワークフロー
Note : # GITTUBアクションを使用してデモを行うプロジェクト.NETコア3.1プロジェクト.ユニットテスト、JSONスナップショット、Dockerサービスコンテナを使用したデータベーステストを使用します.GitHubアクション、Bitbucket、Azure devops、GitLabでの使用例を示します.
提出カテゴリ
Note : # メンテーナは必要である
YAMLファイルまたはコードへのリンク
lastlink / dotnet-ci-pipelines
GITHUB、Azure devops、gitlab、bitbucketなどのためのDOTNET CI CDパイプライン.
dotnet core ciパイプラインの例
GTTUB、Azure devops、Gitlab、Bitbucketなどを含む主要なGitソースコントロールのdev - opsのためのDotnet Core C Countというパイプラインを持つことを目標としています.新しいプルリクエストに対してのみ自動で実行する必要があります.バッジサポートネイティブも良いかhttps://shields.io/category/build . また、サービスコンテナとデータベースのユニットテストを試みる
もともとgitlab-ci-example-dotnetcore .
貢献
limits 2000(月)の20の同時ジョブサポート
name: .NET Core
# use https://marketplace.visualstudio.com/items?itemName=me-dutour-mathieu.vscode-github-actions to validate yml in vscode
env:
NUGET_PACKAGES_DIRECTORY: '.nupkg'
RESHARPER_CLI_NAME: 'JetBrains.ReSharper.CommandLineTools.Unix'
RESHARPER_CLI_VERSION: "2019.2.3"
DOCKER_DRIVER: overlay
CONTAINER_IMAGE: codeclimate/codeclimate
CONTAINER_TAG: '0.85.2'
rIds: ${{ secrets.rIds }}
dotnetVersion: 3.1.102
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Setup .NET Core
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnetVersion}}
- name: Build with dotnet
run: |
export DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet publish -c Release
- name: Tests
run: |
cp MyProject.Repository.Test/Data/appSettings.gitlab.json MyProject.Repository.Test/Data/AppSettings.json
dotnet test --logger "junit" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput='./TestResults/'
- name: Coverage Report
run: |
dotnet --version
dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
./tools/reportgenerator "-reports:**/TestResults/coverage.opencover.xml;" "-targetdir:Reports" -reportTypes:TextSummary;
./tools/reportgenerator "-reports:**/TestResults/coverage.opencover.xml;" "-targetdir:Reports" -reportTypes:Html;
./tools/reportgenerator "-reports:**/TestResults/coverage.opencover.xml;" "-targetdir:Reports" -reportTypes:Badges;
cat ./Reports/Summary.txt
- uses: actions/[email protected]
with:
name: CodeCoverage
path: Reports
- name: Resharper Code Quality
run: |
# apt update && apt install -y curl zip unzip
curl -LO "https://download.jetbrains.com/resharper/ReSharperUltimate.$RESHARPER_CLI_VERSION/$RESHARPER_CLI_NAME.$RESHARPER_CLI_VERSION.zip"
unzip -q $RESHARPER_CLI_NAME.$RESHARPER_CLI_VERSION.zip -d "resharper"
mkdir -p CodeQuality
files=(*.sln)
sh ./resharper/dupfinder.sh "${files[0]}" --output=CodeQuality/dupfinderReport.html --format=Html
sh ./resharper/inspectcode.sh "${files[0]}" --output=CodeQuality/inspectcodeReport.html --format=Html
- uses: actions/[email protected]
with:
name: CodeQuality
path: CodeQuality
- name: prerelease
if: ${{ env.rIds }} != ''
run: |
echo 'build, obfuscate, and release'
dotnet tool install Obfuscar.GlobalTool --tool-path tools --version 2.2.28
bash scripts/extractRelease.sh
export rIds=${{ env.rIds }}
bash ./scripts/pipeline.sh
bash ./scripts/finalRelease.sh
- name: upload release
uses: actions/[email protected]
if: ${{ env.rIds }} != ''
with:
name: Release_unix
path: Release/post
build-win:
runs-on: windows-latest
steps:
- uses: actions/[email protected]
- name: Setup .NET Core
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnetVersion}}
- name: Build with dotnet
run: |
set DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet publish -c Release
- name: Tests
run: |
copy MyProject.Repository.Test/Data/appSettings.gitlab.json MyProject.Repository.Test/Data/AppSettings.json
dotnet test --logger "junit" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput='.\TestResults\'
- name: prerelease
if: ${{ env.rIds }} != ''
run: |
echo "build, obfuscate, and release"
dotnet tool install Obfuscar.GlobalTool --tool-path tools --version 2.2.28
.\scripts\extractRelease.cmd
set rIds=$env:rIds
.\scripts\pipeline.cmd
.\scripts\finalRelease.cmd
- name: upload release
uses: actions/[email protected]
if: ${{ env.rIds }} != ''
with:
name: Release_win
path: Release\post
unit_test_db_mssql:
runs-on: ubuntu-latest
# Service containers to run with `runner-job`
services:
# Label used to access the service container
localhost_mysql:
# Docker Hub image
image: mcr.microsoft.com/mssql/server:2019-latest
#
ports:
# Opens tcp port 6379 on the host and service container
- 1433:1433
env:
GIT_SUBMODULE_STRATEGY: recursive
ACCEPT_EULA: Y
SA_PASSWORD: yourStrong(!)Password
steps:
- uses: actions/[email protected]
- name: Setup .NET Core
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnetVersion}}
- name: enabledb
run: cp ./MyProject.Repository.Test/Data/appSettings.bitbucket.mssql.json ./MyProject.Repository.Test/Data/AppSettings.json
- name: Tests
run: |
cd MyProject.Repository.Test
dotnet test --logger "junit" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput='./TestResults/'
unit_test_db_postgres:
runs-on: ubuntu-latest
# Service containers to run with `runner-job`
services:
# Label used to access the service container
redis:
# Docker Hub image
image: postgres:11
#
ports:
- 5432:5432
# Provide the password for postgres
env:
POSTGRES_DB: mockDb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: "mysecretpassword"
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/[email protected]
- name: Setup .NET Core
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnetVersion}}
- name: enabledb
run: cp ./MyProject.Repository.Test/Data/appSettings.devops.postgres.json ./MyProject.Repository.Test/Data/AppSettings.json
- name: Tests
run: |
cd MyProject.Repository.Test
dotnet test --logger "junit" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput='./TestResults/'
unit_test_db_mysql:
runs-on: ubuntu-latest
# Service containers to run with `runner-job`
services:
# Label used to access the service container
redis:
# Docker Hub image
image: mysql:5.7.29
#
ports:
- 3306:3306
env:
MYSQL_DATABASE: "mockDb"
MYSQL_ROOT_PASSWORD: "mysecretpw"
steps:
- uses: actions/[email protected]
- name: Setup .NET Core
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnetVersion}}
- name: enabledb
run: cp ./MyProject.Repository.Test/Data/appSettings.devops.mysql.json ./MyProject.Repository.Test/Data/AppSettings.json
- name: Tests
run: |
cd MyProject.Repository.Test
dotnet test --logger "junit" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput='./TestResults/'
code_docs:
runs-on: windows-latest
name: code documentation
steps:
- uses: actions/[email protected]
- name: docfx
run: |
curl -LO "https://github.com/dotnet/docfx/releases/download/v2.48/docfx.zip"
powershell.exe -NoP -NonI -Command "Expand-Archive '.\docfx.zip' '.\docfx\'"
./docfx/docfx.exe
- uses: actions/[email protected]
with:
name: CodeDocs
path: _site
security:
runs-on: ubuntu-latest
name: Snyk Security Scan
steps:
- uses: actions/[email protected]
- name: Setup .NET Core
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnetVersion}}
- name: Build with dotnet
run: |
export DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet build
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/[email protected]
with:
args: --file=MyProject.sln
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
追加情報
備考https://github.com/lastlink/dotnet-ci-pipelines/blob/master/.github/workflows/dotnetcore.yml
備考
[リマインダー]:懸(2021年12月8日(午後11時59分、2月6日午前12時)).
Reference
この問題について(DOTNET CIパイプライン), 我々は、より多くの情報をここで見つけました https://dev.to/lastlink/dotnet-ci-pipelines-opcテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol