build: working on build and ci

This commit is contained in:
Dylan R. E. Moonfire 2021-09-03 21:33:54 -05:00
parent 619d583446
commit 677b12f57c
7 changed files with 56 additions and 5202 deletions

View file

@ -1,23 +1,21 @@
stages:
- test
- tag
- deploy
- build
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:
build:
image: mcr.microsoft.com/dotnet/sdk:5.0
stage: test
stage: build
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
# Set up the environment.
- npx npm install --ci
- npx commitlint-gitlab-ci -x @commitlint/config-conventional
- npx semantic-release --publish
# Build and test the project.
# Build and test everything.
- 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"'
@ -27,34 +25,16 @@ test:
- 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
# Perform the release.
- npx semantic-release
# Create the NuGet packages.
- dotnet pack -c Release
- dotnet nuget push "bin/*.nupkg" --api-key $NUGET_TOKEN --source "$NUGET_PUSH_URL"
rules:
- if: '$CI_COMMIT_TITLE =~ /^(docs|chore\(release\))/'
- if: '$CI_COMMIT_TITLE =~ /^chore\(release\)/'
when: never
- if: '$CI_COMMIT_TAG'
when: never
@ -62,20 +42,15 @@ tag:
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" --api-key $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
artifacts:
when: always
paths:
- ./**/*test-result.xml
- ./coverage/Cobertura.xml
- ./coverage/Summary.*
- ./**/*.nupkg
reports:
junit:
- ./**/*test-result.xml
cobertura:
- ./coverage/Cobertura.xml

4
.husky/commit-msg Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit $1

3
commitlint.config.js Normal file
View file

@ -0,0 +1,3 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
};

View file

@ -3,42 +3,18 @@
"version": "1.1.1",
"private": true,
"scripts": {
"commitlint": "commitlint "
},
"release": {
"branch": "master",
"message": "chore(release): v${nextRelease.version}\n\n${nextRelease.notes}",
"verifyConditions": [
"@semantic-release/git"
],
"analyzeCommits": [
"@semantic-release/commit-analyzer"
],
"prepare": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
],
"publish": [],
"success": [],
"fail": []
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
"prepare": "husky install"
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"husky": "^4.3.6",
"semantic-release": "^17.3.0"
"@semantic-release/gitlab": "^6.2.2",
"@semantic-release/npm": "^7.1.3",
"commitlint-gitlab-ci": "^0.0.4",
"husky": "^7.0.2",
"semantic-release": "^17.4.7",
"semantic-release-dotnet": "^1.0.0"
}
}

13
release.config.js Normal file
View file

@ -0,0 +1,13 @@
module.exports = {
branches: ["main"],
message: "chore(release): v${nextRelease.version}\n\n${nextRelease.notes}",
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"semantic-release-dotnet",
"@semantic-release/changelog",
"@semantic-release/git",
"@semantic-release/gitlab",
],
};

View file

@ -1,21 +0,0 @@
#!/bin/bash
# This sets the build version using a `Directory.Build.props` at the top-level
# of the project.
# Move into the root directory.
cd $(dirname $0)
cd ..
# Get the version from `package.json`.
VERSION=$(grep '"version":' package.json | cut -f 4 -d '"')
cat > src/Directory.Build.props << EOL
<Project>
<PropertyGroup>
<Version>$VERSION</Version>
</PropertyGroup>
</Project>
EOL

5096
yarn.lock

File diff suppressed because it is too large Load diff