This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-locking-cil/.gitlab-ci.yml

83 lines
2.9 KiB
YAML

stages:
- test
- tag
- deploy
default:
before_script:
- curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
- apt-get install nodejs yarn
# 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:
- 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 add source "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
- dotnet nuget push "bin/*.nupkg" --source gitlab
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