build: switching Nix layout
This commit is contained in:
parent
6365a1e8c9
commit
d0267b9428
11 changed files with 113 additions and 35 deletions
2
.envrc
2
.envrc
|
@ -1 +1 @@
|
||||||
use asdf
|
use flake
|
||||||
|
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -11,3 +11,9 @@ obj/
|
||||||
.idea/
|
.idea/
|
||||||
_ReSharper.Caches/
|
_ReSharper.Caches/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
.direnv/
|
||||||
|
coverage/
|
||||||
|
tests/artifacts/
|
||||||
|
TestResults/
|
||||||
|
.config/
|
||||||
|
.direnv/
|
||||||
|
|
|
@ -1,42 +1,25 @@
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
|
||||||
default:
|
default:
|
||||||
before_script:
|
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
|
||||||
- curl -sL https://deb.nodesource.com/setup_15.x | bash -
|
|
||||||
- apt-get install -y nodejs
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
image: mcr.microsoft.com/dotnet/sdk:5.0
|
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
# Set up the environment.
|
- nix develop --command scripts/ci-build.sh
|
||||||
- npx npm install --ci
|
|
||||||
- npx commitlint-gitlab-ci -x @commitlint/config-conventional
|
|
||||||
|
|
||||||
# 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"'
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# Perform the release.
|
|
||||||
- npx semantic-release
|
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_TITLE =~ /^chore\(release\)/'
|
- if: $CI_COMMIT_BRANCH
|
||||||
when: never
|
|
||||||
- if: '$CI_COMMIT_TAG'
|
|
||||||
when: never
|
|
||||||
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
||||||
when: never
|
|
||||||
- when: on_success
|
|
||||||
|
|
||||||
|
test:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- nix develop --command scripts/ci-test.sh
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH
|
||||||
|
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
paths:
|
paths:
|
||||||
|
@ -49,3 +32,10 @@ build:
|
||||||
- ./**/*test-result.xml
|
- ./**/*test-result.xml
|
||||||
cobertura:
|
cobertura:
|
||||||
- ./coverage/Cobertura.xml
|
- ./coverage/Cobertura.xml
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- nix develop --command scripts/ci-release.sh
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
dotnet-core 5.0.100
|
|
||||||
yarn 1.22.10
|
|
||||||
nodejs 15.0.1
|
|
|
@ -1,3 +1,6 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
extends: ["@commitlint/config-conventional"],
|
extends: ["@commitlint/config-conventional"],
|
||||||
|
rules: {
|
||||||
|
"body-max-line-length": [0],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
42
flake.lock
Normal file
42
flake.lock
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1638122382,
|
||||||
|
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1638198142,
|
||||||
|
"narHash": "sha256-plU9b8r4St6q4U7VHtG9V7oF8k9fIpfXl/KDaZLuY9k=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "8a308775674e178495767df90c419425474582a1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
17
flake.nix
Normal file
17
flake.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
description = "A .NET core library for building tools";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in {
|
||||||
|
devShell = pkgs.mkShell {
|
||||||
|
buildInputs = [ pkgs.dotnet-sdk_5 pkgs.nodejs-16_x pkgs.nixfmt ];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
extends: ["@commitlint/config-conventional"],
|
||||||
branches: ["main"],
|
branches: ["main"],
|
||||||
message: "chore(release): v${nextRelease.version}\n\n${nextRelease.notes}",
|
message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
|
||||||
plugins: [
|
plugins: [
|
||||||
[
|
[
|
||||||
"@semantic-release/commit-analyzer",
|
"@semantic-release/commit-analyzer",
|
||||||
|
@ -10,7 +11,12 @@ module.exports = {
|
||||||
],
|
],
|
||||||
"@semantic-release/release-notes-generator",
|
"@semantic-release/release-notes-generator",
|
||||||
"@semantic-release/npm",
|
"@semantic-release/npm",
|
||||||
|
[
|
||||||
"semantic-release-dotnet",
|
"semantic-release-dotnet",
|
||||||
|
{
|
||||||
|
paths: ["src/Directory.Build.props"],
|
||||||
|
},
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"semantic-release-nuget",
|
"semantic-release-nuget",
|
||||||
{
|
{
|
||||||
|
|
3
scripts/ci-build.sh
Executable file
3
scripts/ci-build.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
npm install --ci
|
||||||
|
dotnet restore
|
||||||
|
dotnet build
|
5
scripts/ci-release.sh
Executable file
5
scripts/ci-release.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
npm install --ci
|
||||||
|
dotnet restore
|
||||||
|
dotnet build
|
||||||
|
npm install --ci
|
||||||
|
npx semantic-release
|
9
scripts/ci-test.sh
Executable file
9
scripts/ci-test.sh
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
npm install --ci
|
||||||
|
npx commitlint-gitlab-ci -x @commitlint/config-conventional
|
||||||
|
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"
|
||||||
|
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
|
Reference in a new issue