Skip to content

Commit

Permalink
Adding QA jobs and expanding test jobs for CI/CD.
Browse files Browse the repository at this point in the history
  • Loading branch information
tegefaulkes committed Nov 25, 2021
1 parent 6ecb478 commit 84e4909
Show file tree
Hide file tree
Showing 8 changed files with 508 additions and 299 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.env*
!.env.example
/result*
/builds

# Logs
logs
Expand Down
305 changes: 285 additions & 20 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
default:
interruptible: true

variables:
GIT_SUBMODULE_STRATEGY: recursive

stages:
- check
- build
- quality
- release

image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner

lint:
.lint:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
Expand All @@ -18,19 +21,185 @@ lint:
npm run lint;
'
test:
.test 1/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test;
npm run test -- tests/client;
'
nix-dry:
.test 2/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/agent;
'
.test 3/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/bin;
'
.test 4/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/bootstrap;
'
.test 5/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/network;
'
.test 6/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/vaults;
'
.test 7/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/workers;
'
.test 8/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/grpc;
'
.test 9/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/http;
'
.test 10/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/GenericIdTypes.test.ts tests/index.test.ts tests/PolykeyAgent.test.ts tests/utils.test.ts;
'
.test 11/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/claims;
'
.test 12/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/gestalts;
'
.test 13/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/nodes;
'
.test 14/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/git;
'
.test 15/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/keys;
'
.test 16/16:
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
stage: check
interruptible: true
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
npm install;
npm run test -- tests/acl tests/discovery tests/lockfile tests/notifications tests/session tests/sigchain tests/identities;
'
.nix-dry:
stage: check
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
script:
- nix-build -v -v --dry-run ./release.nix --attr application
- nix-build -v -v --dry-run ./release.nix --attr docker
Expand All @@ -40,31 +209,127 @@ nix-dry:

nix:
stage: build
interruptible: true
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
script:
- mkdir -p ./builds
# nix-specific application target
- >
nix-build ./release.nix
--max-jobs $(nproc)
--attr application
--attr docker
build_application="$(nix-build \
--max-jobs "$(nproc)" --cores "$(nproc)" \
./release.nix \
--attr application \
)"
- >
nix-store --export $( \
nix-store --query --requisites "$build_application" \
) | gzip > ./builds/js-polykey.closure.gz
# non-nix targets
- >
builds="$(nix-build \
--max-jobs "$(nproc)" --cores "$(nproc)" \
./release.nix \
--attr docker \
--attr package.linux.x64.elf \
--attr package.windows.x64.exe \
--attr package.macos.x64.macho)"
- cp -r $builds ./builds/
only:
- qa-testing
- master
artifacts:
paths:
- ./builds/

application run:
stage: quality
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
dependencies:
- nix
script:
- >
build_application="$( \
gunzip -c ./builds/js-polykey.closure.gz | \
nix-store --import | \
tail -1 \
)"
- echo password > testPassword
- $build_application/bin/polykey agent start -np ./nodePath --password-file ./testPassword --test
only:
- master
- qa-testing

docker run:
stage: quality
image: docker:20.10.11
dependencies:
- nix
services:
- docker:20.10.11-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- docker info
script:
- image="$(docker load --input ./builds/*docker* | cut -d' ' -f3)"
- docker run "$image"
only:
- qa-testing
- master

linux run:
stage: quality
image: ubuntu:latest
dependencies:
- nix
script:
- echo password > testPassword
- for f in ./builds/*-linux-*; do "$f" agent start -np ./nodePath --password-file ./testPassword --test; done
only:
- qa-testing
- master

windows run:
stage: quality
dependencies:
- nix
script:
- echo password > testPassword
- Get-ChildItem -File ./builds/*-win32-* | ForEach {& $_.FullName agent start -np ./nodePath --password-file ./testPassword --test}
tags:
- windows
only:
- qa-testing
- master

packages:
macos run:
stage: quality
image: macos-11-xcode-12
dependencies:
- nix
script:
- echo password > testPassword
- for f in ./builds/*-macos-*; do "$f" agent start -np ./nodePath --password-file ./testPassword --test; done
only:
- qa-testing
- master
tags:
- shared-macos-amd64

.packages:
stage: release
interruptible: true
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
dependencies:
- nix
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages git gitAndTools.gh --run '
builds="$(nix-build \
--max-jobs $(nproc) --cores $(nproc) \
./release.nix \
--attr package.linux.x64.elf \
--attr package.windows.x64.exe \
--attr package.macos.x64.macho)";
commit="$(git rev-parse --short HEAD)";
gh release \
create "$commit" $builds \
create "$commit" \
builds/*.closure.gz \
builds/*-linux-* \
builds/*-win32-* \
builds/*-macos-* \
--title "Build-$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--prerelease \
--notes "" \
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
/tmp
/docs
/benches
/builds
4 changes: 3 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ let
}
''
mkdir -p $out/lib/node_modules/${utils.node2nixDev.packageName}
# copy only the dist
# copy the package.json
cp ${utils.node2nixDev}/lib/node_modules/${utils.node2nixDev.packageName}/package.json $out/lib/node_modules/${utils.node2nixDev.packageName}/
# copy the dist
cp -r ${utils.node2nixDev}/lib/node_modules/${utils.node2nixDev.packageName}/dist $out/lib/node_modules/${utils.node2nixDev.packageName}/
# copy over the production dependencies
if [ -d "${utils.node2nixProd}/lib/node_modules" ]; then
Expand Down
Loading

0 comments on commit 84e4909

Please sign in to comment.