ci: switching to a Nix-based build environment

This commit is contained in:
Dylan R. E. Moonfire 2021-11-29 23:45:29 -06:00
parent 7cb572bd2e
commit df69c071ff
12 changed files with 3893 additions and 2639 deletions

2
.envrc
View file

@ -1 +1 @@
use asdf use flake

1
.gitignore vendored
View file

@ -11,3 +11,4 @@ obj/
.idea/ .idea/
_ReSharper.Caches/ _ReSharper.Caches/
node_modules/ node_modules/
.direnv/

View file

@ -1,56 +0,0 @@
include:
- template: Security/SAST.gitlab-ci.yml
stages:
- build
- test
- release
default:
before_script:
- curl -sL https://deb.nodesource.com/setup_15.x | bash -
- apt-get install -y nodejs
build:
image: mcr.microsoft.com/dotnet/sdk:5.0
stage: build
script:
- npx npm install --ci
- npx commitlint-gitlab-ci -x @commitlint/config-conventional
- dotnet restore
- dotnet build
rules:
- if: $CI_COMMIT_BRANCH
test:
image: mcr.microsoft.com/dotnet/sdk:5.0
stage: test
script:
- '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:tests/*/TestResults/*/coverage.cobertura.xml -targetdir:./coverage "-reporttypes:Cobertura;TextSummary"
- grep "Line coverage" coverage/Summary.txt
artifacts:
when: always
paths:
- ./**/*test-result.xml
- ./coverage/Cobertura.xml
- ./coverage/Summary.*
- ./**/*.nupkg
reports:
junit:
- ./**/*test-result.xml
cobertura:
- ./coverage/Cobertura.xml
publish:
image: mcr.microsoft.com/dotnet/sdk:5.0
stage: release
script:
- npm install --ci
- dotnet restore
- dotnet build
- npx semantic-release
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

3
.gitlab/build.sh Executable file
View file

@ -0,0 +1,3 @@
npm install --ci
npx commitlint-gitlab-ci -x @commitlint/config-conventional
npm run build

41
.gitlab/ci.yml Normal file
View file

@ -0,0 +1,41 @@
include:
- template: Security/SAST.gitlab-ci.yml
stages:
- build
- test
- release
default:
image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest
build:
stage: build
script:
- nix develop --command .gitlab/build.sh
rules:
- if: $CI_COMMIT_BRANCH
test:
stage: test
script:
- nix develop --command .gitlab/test.sh
artifacts:
when: always
paths:
- ./**/*test-result.xml
- ./coverage/Cobertura.xml
- ./coverage/Summary.*
- ./**/*.nupkg
reports:
junit:
- ./**/*test-result.xml
cobertura:
- ./coverage/Cobertura.xml
publish:
stage: release
script:
- nix develop --command .gitlab/release.sh
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

3
.gitlab/release.sh Executable file
View file

@ -0,0 +1,3 @@
npm install --ci
npm run build
npx semantic-release

5
.gitlab/test.sh Executable file
View file

@ -0,0 +1,5 @@
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:tests/*/TestResults/*/coverage.cobertura.xml -targetdir:./coverage "-reporttypes:Cobertura;TextSummary"
grep "Line coverage" coverage/Summary.txt

View file

@ -1,3 +0,0 @@
dotnet-core 5.0.100
yarn 1.22.10
nodejs 15.0.1

42
flake.lock Normal file
View 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
View 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 ];
};
});
}

6345
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -8,15 +8,15 @@
"test": "dotnet test" "test": "dotnet test"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^13.1.0", "@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^13.1.0", "@commitlint/config-conventional": "^15.0.0",
"@semantic-release/changelog": "^5.0.1", "@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^9.0.0", "@semantic-release/git": "^10.0.1",
"@semantic-release/gitlab": "^6.2.2", "@semantic-release/gitlab": "^7.0.4",
"@semantic-release/npm": "^7.1.3", "@semantic-release/npm": "^8.0.3",
"commitlint-gitlab-ci": "^0.0.4", "commitlint-gitlab-ci": "^0.0.4",
"husky": "^7.0.2", "husky": "^7.0.2",
"semantic-release": "^17.4.7", "semantic-release": "^18.0.1",
"semantic-release-dotnet": "^1.0.0", "semantic-release-dotnet": "^1.0.0",
"semantic-release-nuget": "^1.1.1" "semantic-release-nuget": "^1.1.1"
} }