From 3ef974f98f823f3808dfa4497086300735455c7a Mon Sep 17 00:00:00 2001 From: "Dylan R. E. Moonfire" Date: Thu, 18 Nov 2021 01:36:13 -0600 Subject: [PATCH] build: switching build to use Nix --- .gitlab-ci.yml | 57 +++++++++++++++++++++++++++++------------------ package-lock.json | 6 +++++ package.json | 4 +++- release.config.js | 2 +- shell.nix | 2 +- 5 files changed, 46 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1d4e850..08c5ed4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/package-lock.json b/package-lock.json index 7e21cb2..8ce9cfe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" } diff --git a/package.json b/package.json index d8e2770..ae917d9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/release.config.js b/release.config.js index e0233f1..08dda12 100644 --- a/release.config.js +++ b/release.config.js @@ -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", diff --git a/shell.nix b/shell.nix index b1f5cec..039edc2 100644 --- a/shell.nix +++ b/shell.nix @@ -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