2021-01-22 00:02:19 +00:00
|
|
|
stages:
|
|
|
|
- test
|
|
|
|
- tag
|
|
|
|
- deploy
|
|
|
|
|
2021-01-22 00:25:40 +00:00
|
|
|
default:
|
|
|
|
before_script:
|
2021-01-22 00:28:50 +00:00
|
|
|
- curl -sL https://deb.nodesource.com/setup_15.x | bash -
|
2021-01-22 00:32:14 +00:00
|
|
|
- apt-get install -y nodejs
|
2021-01-22 00:25:40 +00:00
|
|
|
|
2021-01-22 00:02:19 +00:00
|
|
|
# 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.
|
2021-01-22 00:20:05 +00:00
|
|
|
- npx yarn install --frozen-lockfile
|
2021-01-22 00:02:19 +00:00
|
|
|
- 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:
|
2021-01-22 00:49:27 +00:00
|
|
|
- npx yarn install --frozen-lockfile
|
2021-01-22 00:02:19 +00:00
|
|
|
- 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
|
2021-01-22 00:25:40 +00:00
|
|
|
before_script: []
|
2021-01-22 00:02:19 +00:00
|
|
|
script:
|
2021-01-22 00:03:54 +00:00
|
|
|
- scripts/set-build-version.sh
|
2021-01-22 00:02:19 +00:00
|
|
|
- dotnet restore
|
|
|
|
- dotnet build
|
|
|
|
- dotnet pack -c Release
|
2021-09-04 02:11:28 +00:00
|
|
|
- dotnet nuget push "bin/*.nupkg" --api-key $NUGET_TOKEN --source "$NUGET_PUSH_URL"
|
2021-01-22 00:02:19 +00:00
|
|
|
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
|