build: switching build to use Nix

This commit is contained in:
Dylan R. E. Moonfire 2021-11-18 01:36:13 -06:00
parent 40cac44e6d
commit 3ef974f98f
5 changed files with 46 additions and 25 deletions

View file

@ -1,22 +1,41 @@
# Nix handling based on https://gitlab.com/Vonfry/gitlab-ci-nix/-/blob/master/.gitlab-ci.yml
stages:
- build
- test
- release
variables:
GIT_SUBMODULE_STRATEGY: recursive
LOCAL_NIX_STORE: $CI_PROJECT_DIR/.nix/store
default:
image: nixos/nix:latest
before_script:
- curl -sL https://deb.nodesource.com/setup_15.x | bash -
- apt-get install -y nodejs
- nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
- nix-channel --update
- "[ -f $LOCAL_NIX_STORE ] && nix-store --import < $LOCAL_NIX_STORE"
after_script:
- "[ ! -d $(dirname \"$LOCAL_NIX_STORE\") ] && mkdir -p $LOCAL_NIX_STORE"
- "[ -h ./result ] && nix-store --export $(nix-store --query --requisites --include-outputs ./result) > $LOCAL_NIX_STORE"
cache:
paths:
- .nix/
build:
image: mcr.microsoft.com/dotnet/sdk:5.0
stage: build
script:
# Set up the environment.
- npx npm install --ci
- npx commitlint-gitlab-ci -x @commitlint/config-conventional
- nix-shell --run "npm run install --ci"
- nix-shell --run "npx commitlint-gitlab-ci -x @commitlint/config-conventional"
- nix-shell --run "npm run build"
# Build and test everything.
- dotnet restore
- dotnet build
rules:
- if: $CI_COMMIT_BRANCH
test:
stage: test
script:
- nix-shell --run "npm run test"
# Testing is currently not working.
#- '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.
@ -24,19 +43,6 @@ build:
#- 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:
- if: '$CI_COMMIT_TITLE =~ /^chore\(release\)/'
when: never
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
when: never
- when: on_success
artifacts:
when: always
paths:
@ -49,3 +55,10 @@ build:
- ./**/*test-result.xml
cobertura:
- ./coverage/Cobertura.xml
publish:
stage: release
script:
- nix-shell --run "npm run semantic-release"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

6
package-lock.json generated
View file

@ -5,6 +5,7 @@
"requires": true,
"packages": {
"": {
"name": "nitride-cil",
"version": "1.0.0",
"devDependencies": {
"@commitlint/cli": "^13.1.0",
@ -5845,6 +5846,11 @@
"safer-buffer": "^2.0.2",
"tweetnacl": "~0.14.0"
},
"bin": {
"sshpk-conv": "bin/sshpk-conv",
"sshpk-sign": "bin/sshpk-sign",
"sshpk-verify": "bin/sshpk-verify"
},
"engines": {
"node": ">=0.10.0"
}

View file

@ -3,7 +3,9 @@
"version": "1.0.0",
"private": true,
"scripts": {
"prepare": "husky install"
"prepare": "husky install",
"build": "dotnet build",
"test": "dotnet test"
},
"devDependencies": {
"@commitlint/cli": "^13.1.0",

View file

@ -1,6 +1,6 @@
module.exports = {
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: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",

View file

@ -4,7 +4,7 @@ let
in
pkgs.mkShell {
buildInputs = [
pkgs.nodejs-14_x
pkgs.nodejs-16_x
pkgs.yarn
pkgs.dotnet-sdk_5
pkgs.niv