Skip to content

QA testing in CI/CD #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
112 changes: 94 additions & 18 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
default:
interruptible: true

variables:
GIT_SUBMODULE_STRATEGY: recursive

stages:
- check
- build
- quality
- release

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

lint:
stage: check
interruptible: true
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
Expand All @@ -20,7 +22,7 @@ lint:

test:
stage: check
interruptible: true
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run '
Expand All @@ -30,7 +32,7 @@ test:

nix-dry:
stage: check
interruptible: true
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,35 +42,109 @@ nix-dry:

nix:
stage: build
interruptible: true
image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner
script:
- mkdir -p ./builds
# nix-specific application target
- >
build_application="$(nix-build \
--max-jobs "$(nproc)" --cores "$(nproc)" \
./release.nix \
--attr application \
)"
- >
nix-build ./release.nix
--max-jobs $(nproc)
--attr application
--attr docker
nix-store --export $( \
nix-store --query --requisites "$build_application" \
) | gzip > ./builds/typescript-demo-lib.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:
- 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/typescript-demo-lib.closure.gz | \
nix-store --import | \
tail -1 \
)"
- $build_application/bin/typescript-demo-lib

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"

linux run:
stage: quality
image: ubuntu:latest
dependencies:
- nix
script:
- for f in ./builds/*-linux-*; do "$f"; done

windows run:
stage: quality
dependencies:
- nix
script:
- Get-ChildItem -File ./builds/*-win32-* | ForEach {& $_.FullName}
tags:
- windows

# macos is disabled until this repo has access
# macos run:
# stage: quality
# image: macos-11-xcode-12
# dependencies:
# - nix
# script:
# - for f in ./builds/*-macos-*; do "$f"; done
# 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/*-linux-* builds/*-win32-* builds/*-macos-* \
--title "Build-$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
--prerelease \
--notes "" \
--repo MatrixAI/TypeScript-Demo-Lib;
'
only:
- master

1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/tmp
/docs
/benches
/builds
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ nix-env -f ./release.nix --install --attr application
Install into Docker:

```sh
docker load --input "$(nix-build ./release.nix --attr docker)"
loaded="$(docker load --input "$(nix-build ./release.nix --attr docker)")"
image="$(cut -d' ' -f3 <<< "$loaded")"
docker run -it "$image"
```

## Development
Expand Down
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
2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/classes/lib_Library.default.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ <h3>some<wbr>Param</h3>
<li class=" tsd-kind-module">
<a href="../modules/lib_NumPair.html">lib/<wbr>Num<wbr>Pair</a>
</li>
<li class=" tsd-kind-module">
<a href="../modules/lib_test_fd_lock.html">lib/test-<wbr>fd-<wbr>lock</a>
</li>
<li class=" tsd-kind-module">
<a href="../modules/lib_test_level.html">lib/test-<wbr>level</a>
</li>
Expand Down
3 changes: 3 additions & 0 deletions docs/classes/lib_NumPair.default.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ <h3>num2</h3>
<li class="current tsd-kind-module">
<a href="../modules/lib_NumPair.html">lib/<wbr>Num<wbr>Pair</a>
</li>
<li class=" tsd-kind-module">
<a href="../modules/lib_test_fd_lock.html">lib/test-<wbr>fd-<wbr>lock</a>
</li>
<li class=" tsd-kind-module">
<a href="../modules/lib_test_level.html">lib/test-<wbr>level</a>
</li>
Expand Down
Loading