81 lines
2.7 KiB
YAML
81 lines
2.7 KiB
YAML
stages:
|
|
- test
|
|
- tag
|
|
- deploy
|
|
|
|
default:
|
|
before_script:
|
|
- curl -sL https://deb.nodesource.com/setup_15.x | bash -
|
|
- apt-get install -y nodejs
|
|
|
|
# The test stage runs on every build and every branch.
|
|
test:
|
|
image: mcr.microsoft.com/dotnet/sdk:5.0
|
|
stage: test
|
|
script:
|
|
# Make sure the commits follow our rules.
|
|
- npx yarn install --frozen-lockfile
|
|
- if [ $CI_BUILD_BEFORE_SHA == "0000000000000000000000000000000000000000" ]; then npx commitlint --to=HEAD; else npx commitlint --from=$CI_BUILD_BEFORE_SHA; fi
|
|
|
|
# Build and test the project.
|
|
- dotnet restore
|
|
- dotnet build
|
|
- 'dotnet test --test-adapter-path:. --logger:"junit;LogFilePath=../artifacts/{assembly}-test-result.xml;MethodFormat=Default;FailureBodyFormat=Verbose" --collect:"XPlat Code Coverage"'
|
|
|
|
# Summarize the output for Gitlab CI reporting.
|
|
- dotnet new tool-manifest
|
|
- dotnet tool install dotnet-reportgenerator-globaltool
|
|
- dotnet tool run reportgenerator -reports:src/*/TestResults/*/coverage.cobertura.xml -targetdir:./coverage "-reporttypes:Cobertura;TextSummary"
|
|
- grep "Line coverage" coverage/Summary.txt
|
|
rules:
|
|
- if: '$CI_COMMIT_TITLE =~ /^(docs|chore\(release\))/'
|
|
when: never
|
|
- if: '$CI_COMMIT_TAG'
|
|
when: never
|
|
- when: on_success
|
|
artifacts:
|
|
when: always
|
|
paths:
|
|
- ./**/*test-result.xml
|
|
- ./coverage/Cobertura.xml
|
|
- ./coverage/Summary.*
|
|
reports:
|
|
junit:
|
|
- ./**/*test-result.xml
|
|
cobertura:
|
|
- ./coverage/Cobertura.xml
|
|
|
|
# Tagging only runs on the master branches and after testing.
|
|
tag:
|
|
image: mcr.microsoft.com/dotnet/sdk:5.0
|
|
stage: tag
|
|
needs: [test]
|
|
script:
|
|
- npx yarn install --frozen-lockfile
|
|
- npx semantic-release
|
|
rules:
|
|
- if: '$CI_COMMIT_TITLE =~ /^(docs|chore\(release\))/'
|
|
when: never
|
|
- if: '$CI_COMMIT_TAG'
|
|
when: never
|
|
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
when: never
|
|
- when: on_success
|
|
|
|
# Publish the packages.
|
|
deploy:
|
|
image: mcr.microsoft.com/dotnet/sdk:5.0
|
|
needs: []
|
|
stage: deploy
|
|
before_script: []
|
|
script:
|
|
- scripts/set-build-version.sh
|
|
- dotnet restore
|
|
- dotnet build
|
|
- dotnet pack -c Release
|
|
- dotnet nuget push "bin/*.nupkg" $NUGET_TOKEN --source "$NUGET_PUSH_URL"
|
|
rules:
|
|
- if: '$FORCE_DEPLOY'
|
|
- if: '$CI_COMMIT_TITLE =~ /^chore\(release\)/ && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
when: never
|