|
1 | 1 | variables: |
2 | | - GIT_SUBMODULE_STRATEGY: recursive |
| 2 | + GIT_SUBMODULE_STRATEGY: "recursive" |
| 3 | + # Cache .npm |
| 4 | + NPM_CONFIG_CACHE: "./tmp/npm" |
| 5 | + # Prefer offline node module installation |
| 6 | + NPM_CONFIG_PREFER_OFFLINE: "true" |
| 7 | + # `ts-node` has its own cache |
| 8 | + # It must use an absolute path, otherwise ts-node calls will CWD |
| 9 | + TS_CACHED_TRANSPILE_CACHE: "${CI_PROJECT_DIR}/tmp/ts-node-cache" |
| 10 | + TS_CACHED_TRANSPILE_PORTABLE: "true" |
| 11 | + |
| 12 | +# Cached directories shared between jobs & pipelines per-branch |
| 13 | +cache: |
| 14 | + key: $CI_COMMIT_REF_SLUG |
| 15 | + paths: |
| 16 | + - ./tmp/npm/ |
| 17 | + - ./tmp/ts-node-cache/ |
| 18 | + # `jest` cache is configured in jest.config.js |
| 19 | + - ./tmp/jest/ |
3 | 20 |
|
4 | 21 | stages: |
5 | 22 | - check |
| 23 | + - test |
6 | 24 | - build |
| 25 | + - quality |
7 | 26 | - release |
8 | 27 |
|
9 | | -image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner |
10 | | - |
11 | 28 | lint: |
| 29 | + image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner |
12 | 30 | stage: check |
13 | 31 | interruptible: true |
14 | 32 | script: |
15 | 33 | - > |
16 | 34 | nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run ' |
17 | | - npm install; |
| 35 | + npm ci; |
18 | 36 | npm run lint; |
19 | 37 | ' |
20 | 38 |
|
21 | | -test: |
22 | | - stage: check |
23 | | - interruptible: true |
24 | | - script: |
25 | | - - > |
26 | | - nix-shell -I nixpkgs=./pkgs.nix --packages nodejs --run ' |
27 | | - npm install; |
28 | | - npm run test; |
29 | | - ' |
30 | | -
|
31 | 39 | nix-dry: |
32 | 40 | stage: check |
33 | | - interruptible: true |
| 41 | + image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner |
34 | 42 | script: |
35 | 43 | - nix-build -v -v --dry-run ./release.nix --attr application |
36 | 44 | - nix-build -v -v --dry-run ./release.nix --attr docker |
37 | 45 | - nix-build -v -v --dry-run ./release.nix --attr package.linux.x64.elf |
38 | 46 | - nix-build -v -v --dry-run ./release.nix --attr package.windows.x64.exe |
39 | 47 | - nix-build -v -v --dry-run ./release.nix --attr package.macos.x64.macho |
40 | 48 |
|
| 49 | +test-generate: |
| 50 | + image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner |
| 51 | + stage: check |
| 52 | + interruptible: true |
| 53 | + script: |
| 54 | + - mkdir -p ./tmp |
| 55 | + - > |
| 56 | + nix-shell -I nixpkgs=./pkgs.nix --packages bash --run ' |
| 57 | + ./scripts/test-pipelines.sh > ./tmp/test-pipelines.yml |
| 58 | + ' |
| 59 | + artifacts: |
| 60 | + paths: |
| 61 | + - ./tmp/test-pipelines.yml |
| 62 | + |
| 63 | +test: |
| 64 | + stage: test |
| 65 | + # Don't implicitly inherit top-level variables in child pipeline |
| 66 | + # All inherited variables should be explicitly defined here |
| 67 | + # Note that variables defined here override any variables defined in the child pipeline |
| 68 | + # This causes a bug with $CI_PROJECT_DIR, which is expanded into an empty string |
| 69 | + inherit: |
| 70 | + variables: false |
| 71 | + trigger: |
| 72 | + include: |
| 73 | + - artifact: tmp/test-pipelines.yml |
| 74 | + job: test-generate |
| 75 | + strategy: depend |
| 76 | + |
41 | 77 | nix: |
42 | 78 | stage: build |
43 | | - interruptible: true |
| 79 | + image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner |
44 | 80 | script: |
| 81 | + - mkdir -p ./builds |
| 82 | + # nix-specific application target |
| 83 | + - > |
| 84 | + build_application="$(nix-build \ |
| 85 | + --max-jobs "$(nproc)" --cores "$(nproc)" \ |
| 86 | + ./release.nix \ |
| 87 | + --attr application \ |
| 88 | + )" |
| 89 | + - > |
| 90 | + nix-store --export $( \ |
| 91 | + nix-store --query --requisites "$build_application" \ |
| 92 | + ) | gzip > ./builds/js-polykey.closure.gz |
| 93 | + # non-nix targets |
45 | 94 | - > |
46 | | - nix-build ./release.nix |
47 | | - --max-jobs $(nproc) |
48 | | - --attr application |
49 | | - --attr docker |
| 95 | + builds="$(nix-build \ |
| 96 | + --max-jobs "$(nproc)" --cores "$(nproc)" \ |
| 97 | + ./release.nix \ |
| 98 | + --attr docker \ |
| 99 | + --attr package.linux.x64.elf \ |
| 100 | + --attr package.windows.x64.exe \ |
| 101 | + --attr package.macos.x64.macho)" |
| 102 | + - cp -r $builds ./builds/ |
| 103 | + only: |
| 104 | + - master |
| 105 | + artifacts: |
| 106 | + paths: |
| 107 | + - ./builds/ |
| 108 | + |
| 109 | +application run: |
| 110 | + stage: quality |
| 111 | + image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner |
| 112 | + dependencies: |
| 113 | + - nix |
| 114 | + script: |
| 115 | + - > |
| 116 | + build_application="$( \ |
| 117 | + gunzip -c ./builds/js-polykey.closure.gz | \ |
| 118 | + nix-store --import | \ |
| 119 | + tail -1 \ |
| 120 | + )" |
| 121 | + - $build_application/bin/polykey |
| 122 | + only: |
| 123 | + - master |
| 124 | + |
| 125 | +docker run: |
| 126 | + stage: quality |
| 127 | + image: docker:20.10.11 |
| 128 | + dependencies: |
| 129 | + - nix |
| 130 | + services: |
| 131 | + - docker:20.10.11-dind |
| 132 | + variables: |
| 133 | + DOCKER_TLS_CERTDIR: "/certs" |
| 134 | + before_script: |
| 135 | + - docker info |
| 136 | + script: |
| 137 | + - image="$(docker load --input ./builds/*docker* | cut -d' ' -f3)" |
| 138 | + - docker run "$image" |
| 139 | + only: |
| 140 | + - master |
| 141 | + |
| 142 | +linux run: |
| 143 | + stage: quality |
| 144 | + image: ubuntu:latest |
| 145 | + dependencies: |
| 146 | + - nix |
| 147 | + script: |
| 148 | + - for f in ./builds/*-linux-*; do "$f"; done |
| 149 | + only: |
| 150 | + - master |
| 151 | + |
| 152 | +windows run: |
| 153 | + stage: quality |
| 154 | + dependencies: |
| 155 | + - nix |
| 156 | + script: |
| 157 | + - Get-ChildItem -File ./builds/*-win32-* | ForEach {& $_.FullName} |
| 158 | + tags: |
| 159 | + - windows |
50 | 160 | only: |
51 | 161 | - master |
52 | 162 |
|
| 163 | +macos run: |
| 164 | + stage: quality |
| 165 | + image: macos-11-xcode-12 |
| 166 | + dependencies: |
| 167 | + - nix |
| 168 | + script: |
| 169 | + - for f in ./builds/*-macos-*; do "$f"; done |
| 170 | + only: |
| 171 | + - master |
| 172 | + tags: |
| 173 | + - shared-macos-amd64 |
| 174 | + |
53 | 175 | packages: |
54 | 176 | stage: release |
55 | | - interruptible: true |
| 177 | + image: registry.gitlab.com/matrixai/engineering/maintenance/gitlab-runner |
| 178 | + dependencies: |
| 179 | + - nix |
56 | 180 | script: |
57 | 181 | - > |
58 | 182 | nix-shell -I nixpkgs=./pkgs.nix --packages git gitAndTools.gh --run ' |
59 | | - builds="$(nix-build \ |
60 | | - --max-jobs $(nproc) --cores $(nproc) \ |
61 | | - ./release.nix \ |
62 | | - --attr package.linux.x64.elf \ |
63 | | - --attr package.windows.x64.exe \ |
64 | | - --attr package.macos.x64.macho)"; |
65 | 183 | commit="$(git rev-parse --short HEAD)"; |
66 | 184 | gh release \ |
67 | | - create "$commit" $builds \ |
| 185 | + create "$commit" \ |
| 186 | + builds/*.closure.gz \ |
| 187 | + builds/*-linux-* \ |
| 188 | + builds/*-win32-* \ |
| 189 | + builds/*-macos-* \ |
68 | 190 | --title "Build-$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ |
69 | 191 | --prerelease \ |
70 | 192 | --notes "" \ |
|
0 commit comments