@leverege/build-tools 2.34.0 → 2.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -38,7 +38,11 @@ const INTERACTIVE_MODE = !TARGET;
38
38
  let exited = false;
39
39
  const SECRETS_DIR = 'secrets';
40
40
  const EXIT_EVENTS = ['SIGINT', 'exit', 'uncaughException', 'unhandledRejection'];
41
- const [firebaserc, firebaseJson, git] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json')), _zx.fs.exists(_zx.path.join(process.cwd(), '.git/HEAD'))]);
41
+ const [firebaserc, firebaseJson, gitBranch] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json')), (0, _zx.$)`git rev-parse --abbrev-ref HEAD -C ${process.cwd()}`.then(({
42
+ stdout
43
+ }) => {
44
+ return stdout.split('\n')[0];
45
+ })]);
42
46
  if (!firebaserc) {
43
47
  console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
44
48
  }
@@ -51,18 +55,6 @@ if (!firebaserc || !firebaseJson) {
51
55
  const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
52
56
  encoding: 'utf-8'
53
57
  }));
54
-
55
- // If in a git repo, fetch the name of the git branch to use as a default
56
- // name in case a deployment channel is needed. Examining this file directly
57
- // is less cumbersome then running an actual git command to fetch the
58
- // branch name
59
- let gitBranch;
60
- if (git) {
61
- const gitContent = (await _zx.fs.readFile(_zx.path.join(process.cwd(), '.git/HEAD'), {
62
- encoding: 'utf-8'
63
- }))?.split('/');
64
- gitBranch = gitContent[gitContent?.length - 1]?.trimEnd('\n');
65
- }
66
58
  let maxSiteIdLength = 0;
67
59
  const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
68
60
  Object.entries(config.hosting).forEach(([siteId, aliases]) => {
@@ -2,6 +2,8 @@
2
2
 
3
3
  /**
4
4
  * This script parses a firebase config into something useful.
5
+ *
6
+ * firebase --project leverege-dev-john apps:sdkconfig | getfbcfg
5
7
  */
6
8
  "use strict";
7
9
 
@@ -38,7 +38,11 @@ const INTERACTIVE_MODE = !TARGET;
38
38
  let exited = false;
39
39
  const SECRETS_DIR = 'secrets';
40
40
  const EXIT_EVENTS = ['SIGINT', 'exit', 'uncaughException', 'unhandledRejection'];
41
- const [firebaserc, firebaseJson, git] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json')), _zx.fs.exists(_zx.path.join(process.cwd(), '.git/HEAD'))]);
41
+ const [firebaserc, firebaseJson, gitBranch] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json')), (0, _zx.$)`git rev-parse --abbrev-ref HEAD -C ${process.cwd()}`.then(({
42
+ stdout
43
+ }) => {
44
+ return stdout.split('\n')[0];
45
+ })]);
42
46
  if (!firebaserc) {
43
47
  console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
44
48
  }
@@ -51,18 +55,6 @@ if (!firebaserc || !firebaseJson) {
51
55
  const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
52
56
  encoding: 'utf-8'
53
57
  }));
54
-
55
- // If in a git repo, fetch the name of the git branch to use as a default
56
- // name in case a deployment channel is needed. Examining this file directly
57
- // is less cumbersome then running an actual git command to fetch the
58
- // branch name
59
- let gitBranch;
60
- if (git) {
61
- const gitContent = (await _zx.fs.readFile(_zx.path.join(process.cwd(), '.git/HEAD'), {
62
- encoding: 'utf-8'
63
- }))?.split('/');
64
- gitBranch = gitContent[gitContent?.length - 1]?.trimEnd('\n');
65
- }
66
58
  let maxSiteIdLength = 0;
67
59
  const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
68
60
  Object.entries(config.hosting).forEach(([siteId, aliases]) => {
@@ -2,6 +2,8 @@
2
2
 
3
3
  /**
4
4
  * This script parses a firebase config into something useful.
5
+ *
6
+ * firebase --project leverege-dev-john apps:sdkconfig | getfbcfg
5
7
  */
6
8
  "use strict";
7
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.34.0",
3
+ "version": "2.34.3",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -57,7 +57,7 @@
57
57
  "command-line-usage": "^6.1.3",
58
58
  "deepmerge": "^4.3.1",
59
59
  "dotenv": "^16.3.1",
60
- "enquirer": "^2.3.6",
60
+ "enquirer": "^2.4.1",
61
61
  "execa": "^5.1.1",
62
62
  "get-bin-path": "^10.0.0",
63
63
  "glob": "^8.1.0",
@@ -75,6 +75,6 @@
75
75
  "@babel/core": "^7.22.9",
76
76
  "@leverege/babel-preset-leverege-node": "^2.0.0",
77
77
  "@leverege/eslint-config-leverege": "^3.0.1",
78
- "npm": "^9.8.0"
78
+ "npm": "^9.8.1"
79
79
  }
80
80
  }
package/src/bash-funcs CHANGED
@@ -129,3 +129,17 @@ function removeHelmRepo(){
129
129
  [ ! -z "$SKIP_RM_HELM_REPO" ] && return
130
130
  helm repo remove $1 &>/dev/null
131
131
  }
132
+
133
+ # initial use for logging helm activities
134
+ function postToSlack() {
135
+ local toPost="$@"
136
+ local running="`basename $0`"
137
+ local dts="`date +\"%c\"`"
138
+ local slackURL="https://hooks.slack.com/services/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"
139
+ local channel="#dev-ops-helm"
140
+ local slackmsg="\n--- $running by \`$USER\` in \`$GCP_PROJECT_ID\` @ $dts\n \`$toPost\`\n node `node --version` / `build-tools --version` / helm `helm version --short`\n"
141
+
142
+ curl -X POST -H 'Content-type: application/json' \
143
+ --data "{\"text\":\"$slackmsg\",\"channel\":\"$channel\"}" \
144
+ "$slackURL" &>/dev/null
145
+ }
package/src/dockreate CHANGED
@@ -249,7 +249,12 @@ runuser=$(packageJson '.leverege.runuser')
249
249
  [ -z "${runuser}" ] && runuser='node'
250
250
 
251
251
  npmlogging='--silent' # allow for verbose npm logs
252
- [ "$VERBOSE_DOCKREATE_NPM" == "yes" ] && npmlogging='--ddd'
252
+ if [ "$VERBOSE_DOCKREATE_NPM" == "yes" ];
253
+ then
254
+ npmlogging='--ddd'
255
+ else
256
+ hintverbose=1
257
+ fi
253
258
 
254
259
  echo "Updating dependencies and workspace..." && npm install
255
260
  if [ $? -ne 0 ];
@@ -362,7 +367,6 @@ cat<<IMGINFO
362
367
  Container: $(color g $container)
363
368
  NodeImage: $(color g $nodeimg)
364
369
  NopeOps: $(color y $nodeops)
365
- NPM Logs: $(color g $npmlogging)
366
370
  AddedPkgs: $(color g $apkadds)
367
371
  PluggedIn: ${pluggedIn}
368
372
  Version: $(color g $version) $tagstat
@@ -371,9 +375,12 @@ cat<<IMGINFO
371
375
  DateStamp: $(color g $pckgdts)
372
376
  GCImage: $(color g $gcimage:$version)
373
377
  Registry: $(color y $registry)
378
+ NPM Logs: $(color g $npmlogging)
374
379
 
375
380
  IMGINFO
376
381
 
382
+ [ $hintverbose ] && printf " Define $(color g VERBOSE_DOCKREATE_NPM=\"yes\") for verbose build logging\n\n"
383
+
377
384
  if [ "$pckgver" != "$version" ];
378
385
  then
379
386
  cat<<EOPKG
@@ -42,11 +42,14 @@ const EXIT_EVENTS = [ 'SIGINT', 'exit', 'uncaughException', 'unhandledRejection'
42
42
  const [
43
43
  firebaserc,
44
44
  firebaseJson,
45
- git
45
+ gitBranch
46
46
  ] = await Promise.all( [
47
47
  fs.exists( path.join( process.cwd(), '.firebaserc' ) ),
48
48
  fs.exists( path.join( process.cwd(), 'firebase.json' ) ),
49
- fs.exists( path.join( process.cwd(), '.git/HEAD' ) )
49
+ $`git rev-parse --abbrev-ref HEAD -C ${process.cwd()}`
50
+ .then( ( { stdout } ) => {
51
+ return stdout.split( '\n' )[0]
52
+ } )
50
53
  ] )
51
54
 
52
55
  if ( !firebaserc ) {
@@ -63,16 +66,6 @@ if ( !firebaserc || !firebaseJson ) {
63
66
 
64
67
  const firebasercContent = JSON.parse( await fs.readFile( path.join( process.cwd(), '.firebaserc' ), { encoding : 'utf-8' } ) )
65
68
 
66
- // If in a git repo, fetch the name of the git branch to use as a default
67
- // name in case a deployment channel is needed. Examining this file directly
68
- // is less cumbersome then running an actual git command to fetch the
69
- // branch name
70
- let gitBranch
71
- if ( git ) {
72
- const gitContent = ( await fs.readFile( path.join( process.cwd(), '.git/HEAD' ), { encoding : 'utf-8' } ) )?.split( '/' )
73
- gitBranch = gitContent[gitContent?.length - 1]?.trimEnd( '\n' )
74
- }
75
-
76
69
  let maxSiteIdLength = 0
77
70
 
78
71
  const targets = Object
package/src/getfbcfg.js CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  /**
4
4
  * This script parses a firebase config into something useful.
5
+ *
6
+ * firebase --project leverege-dev-john apps:sdkconfig | getfbcfg
5
7
  */
6
8
  const stdbuf = []
7
9
 
@@ -197,12 +197,12 @@ serverFiles:
197
197
 
198
198
  - alert: KubernetesPodNotHealthy
199
199
  expr: kube_pod_status_phase{phase=~"Pending|Unknown|Failed"} == 1
200
- for: 10m
200
+ for: 20m
201
201
  labels:
202
202
  severity: error
203
203
  annotations:
204
204
  summary: "Kubernetes Pod not healthy"
205
- description: "Pod {{ $labels.pod }} has been in a non-ready state for longer than 10 minutes."
205
+ description: "Pod {{ $labels.pod }} has been in a non-ready state for longer than 20 minutes."
206
206
  dashboard: "Check the pod status using the Kubernetes UI"
207
207
 
208
208
  - alert: KubernetesPodCrashLooping
package/src/helmdn CHANGED
@@ -1,27 +1,7 @@
1
1
  #!/bin/bash
2
- # TODO: maybe update this?
3
-
4
- # Simple ANSI color coded string generator.
5
- color() {
6
- local color=
7
- case "$1" in
8
- 'g') color="92m" ;; # green
9
- 'c') color="96m" ;; # lt blue
10
- 'y') color="93m" ;; # yellow
11
- 'r') color="91m" ;; # red
12
- 'toast') color="1;3;7;91;103;5m" ;;
13
- esac
14
- printf "\e[$color$2\e[0m"
15
- }
16
-
17
- clearlyWarn() {
18
- clear
19
- cat<<CLEARWARN
20
-
21
- `color toast '*** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING ***'`
22
2
 
23
- CLEARWARN
24
- }
3
+ # Load the standard helper functions
4
+ . `build-tools --bashfun`
25
5
 
26
6
  clearlyWarn
27
7
  cat<<ABOUT2NUKE
@@ -111,6 +91,13 @@ function annihilateVelero() {
111
91
  velero@${GCP_PROJECT_ID}.iam.gserviceaccount.com &>/dev/null
112
92
  }
113
93
 
94
+ function helmDown() {
95
+ local namespace=${2:-default}
96
+ local helmdn="helm uninstall $1 -n $namespace"
97
+ eval $helmdn
98
+ postToSlack $helmdn
99
+ }
100
+
114
101
  function doNuking() {
115
102
 
116
103
  for PARAM in "$@";
@@ -119,19 +106,19 @@ function doNuking() {
119
106
 
120
107
  case "$SERVICE" in
121
108
  "cert-manager")
122
- helm uninstall -n cert-manager cert-manager
109
+ helmDown cert-manager cert-manager
123
110
  ;;
124
111
 
125
112
  "elastic"|"elasticsearch")
126
- helm uninstall elasticsearch
113
+ helmDown elasticsearch
127
114
  ;;
128
115
 
129
116
  "estafette"|"preemptible-killer")
130
- helm uninstall -n estafette estafette-gke-preemptible-killer
117
+ helmDown estafette-gke-preemptible-killer estafette
131
118
  ;;
132
119
 
133
120
  "traefik")
134
- helm uninstall -n traefik traefik
121
+ helmDown traefik traefik
135
122
  ;;
136
123
 
137
124
  "monitoring")
@@ -169,7 +156,7 @@ NOGRESS
169
156
  ;;
170
157
 
171
158
  *)
172
- helm -n default uninstall $SERVICE
159
+ helmDown $SERVICE "default"
173
160
  esac
174
161
  done
175
162
  }
package/src/helmup CHANGED
@@ -39,6 +39,7 @@ SYSTEM=(
39
39
  monitoring # do monitoring last to show password
40
40
  )
41
41
 
42
+ # audit trail via slack
42
43
  # support for legacy bitnami charts
43
44
  function addBitnamiRepo() {
44
45
  if [ ! -z "$BITNAMI_LATEST" ] || [ "$1" == "latest" ];
@@ -317,40 +318,35 @@ function installPreemptibleKiller() {
317
318
  }
318
319
 
319
320
  function installCronZombieKiller() {
320
- local BATCH_SYNTAX='batch/v1' # GKE 1.21 and beyond
321
- [ ! -z "$PRE_GKE_21" ] && BATCH_SYNTAX='batch/v1beta1'
322
321
  cat<<END_OF_ZOMBIE | kubectl apply -f -
323
322
  apiVersion: v1
324
323
  kind: ServiceAccount
325
324
  metadata:
326
325
  name: cron-zombie-sa
327
- namespace: default
328
326
  ---
329
327
  apiVersion: rbac.authorization.k8s.io/v1
330
- kind: Role
328
+ kind: ClusterRole
331
329
  metadata:
332
- name: pod-accessor-role
333
- namespace: default
330
+ name: cron-zombie-role
334
331
  rules:
335
332
  - apiGroups: [""]
336
333
  resources: ["pods"]
337
- verbs: ["get","delete","watch","list"]
334
+ verbs: ["list", "delete"]
338
335
  ---
339
336
  apiVersion: rbac.authorization.k8s.io/v1
340
- kind: RoleBinding
337
+ kind: ClusterRoleBinding
341
338
  metadata:
342
- name: pod-access
343
- namespace: default
339
+ name: cron-zombie-role-binding
340
+ roleRef:
341
+ apiGroup: rbac.authorization.k8s.io
342
+ kind: ClusterRole
343
+ name: cron-zombie-role
344
344
  subjects:
345
345
  - kind: ServiceAccount
346
346
  name: cron-zombie-sa
347
347
  namespace: default
348
- roleRef:
349
- kind: Role
350
- name: pod-accessor-role
351
- apiGroup: ""
352
348
  ---
353
- apiVersion: $BATCH_SYNTAX
349
+ apiVersion: batch/v1
354
350
  kind: CronJob
355
351
  metadata:
356
352
  namespace: default
@@ -375,22 +371,9 @@ spec:
375
371
  - "/bin/sh"
376
372
  args:
377
373
  - "-c"
378
- - "echo Zombie Hunting `date` ; kubectl get pods -n default --field-selector='status.phase==Failed' -o name | xargs kubectl delete -n default 2> /dev/null"
374
+ - "echo 'Hunting Zombies' ; kubectl get pods --all-namespaces --field-selector=status.phase=Failed -o json | kubectl delete -f - 2> /dev/null"
379
375
  status: {}
380
376
  END_OF_ZOMBIE
381
-
382
- if [[ $? -eq 1 ]];
383
- then
384
- cat<<OLDER_GKE
385
-
386
- Deployment failed is the GKE version pre 1.21? Try rerunning with PRE_GKE_21 defined:
387
-
388
- $ `color y "PRE_GKE_21=1 helmup zombie-killer"`
389
-
390
-
391
- OLDER_GKE
392
- exit 1
393
- fi
394
377
  }
395
378
 
396
379
  function installCertManagerSecret() {
@@ -610,7 +593,8 @@ doHelmup() {
610
593
  local from=
611
594
  [ ! -z "$FROM_VERSIONS" ] && from="`color y \"<= from Versions.json\"`"
612
595
  printf "$doing $from\n"
613
- $helmup
596
+ eval $helmup
597
+ postToSlack "$helmup"
614
598
  }
615
599
 
616
600
  # not a fan of global vars but bash forced me to - set by getServiceAndChartVersion
package/src/k8scale CHANGED
@@ -1,22 +1,13 @@
1
1
  #!/bin/bash
2
2
 
3
- # Simple ANSI color coded string generator.
4
- function color() {
5
- local color=
6
- case "$1" in
7
- 'g') color="92m" ;; # green
8
- 'c') color="96m" ;; # lt blue
9
- 'y') color="93m" ;; # yellow
10
- 'r') color="91m" ;; # red
11
- 'toast') color="1;3;7;91;103;5m" ;;
12
- esac
13
- printf "\e[$color$2\e[0m"
14
- }
3
+ # Load the standard helper functions
4
+ . `build-tools --bashfun`
15
5
 
16
6
  GITTOP=`git rev-parse --show-toplevel` && cd $GITTOP
17
7
 
18
8
  overwhelm
19
9
  [ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
10
+ GCP_PROJECT_ID="$(getProjectIdFromK8sContext)"
20
11
 
21
12
  REPLICAS=
22
13
  DIRECTION=$1 && shift
@@ -40,5 +31,6 @@ do
40
31
  kubectl scale --replicas=$REPLICAS deployment $SERVICE &>/dev/null
41
32
  [ $? -eq 1 ] && RESULTS="`color r FAILURE`"
42
33
  printf " $RESULTS => $SERVICE\n"
34
+ postToSlack "k8scale $DIRECTION $SERVICE"
43
35
  done
44
36
  printf "\n\n"
@@ -1,150 +0,0 @@
1
- version: 2.1
2
- jobs:
3
- install:
4
- docker:
5
- - image: $CIRCLE_NODE_IMG
6
- steps:
7
- - checkout
8
- - restore_cache:
9
- keys:
10
- - v1-npm-deps-{{ checksum "package-lock.json" }}
11
- - v1-npm-deps-
12
-
13
- - run:
14
- name: Setup @leverege Token
15
- command: echo \${NPMRC} > ~/.npmrc
16
-
17
- - run: npm install
18
-
19
- - save_cache:
20
- key: v1-npm-deps-{{ checksum "package-lock.json" }}
21
- paths:
22
- - ./node_modules
23
-
24
- - persist_to_workspace:
25
- root: /home/circleci/project
26
- paths:
27
- - ./node_modules
28
-
29
- security-check:
30
- docker:
31
- - image: $CIRCLE_NODE_IMG
32
- steps:
33
- - checkout
34
- - attach_workspace:
35
- at: ~/project
36
- - run:
37
- name: Check for vulnerabilities
38
- command: npm audit --production --audit-level=moderate
39
-
40
- license-check:
41
- docker:
42
- - image: $CIRCLE_NODE_IMG
43
- steps:
44
- - checkout
45
- - attach_workspace:
46
- at: ~/project
47
- - run:
48
- name: Check for LICENSE and README files
49
- command: npm run pkglint
50
-
51
- - run:
52
- name: Check for license violations (e.g. GPL)
53
- command: npx license-checker --production --summary --failOn GPL
54
-
55
- lint:
56
- docker:
57
- - image: $CIRCLE_NODE_IMG
58
- steps:
59
- - checkout
60
- - attach_workspace:
61
- at: ~/project
62
- - run:
63
- name: Lint and save results
64
- command: npm run lint-ci
65
-
66
- - store_test_results:
67
- path: reports
68
-
69
- docs:
70
- docker:
71
- - image: $CIRCLE_NODE_IMG
72
- steps:
73
- - checkout
74
- - attach_workspace:
75
- at: ~/project
76
- - run:
77
- name: Generate docs
78
- command: npx jsdoc -r src -R README.md -d docs
79
- - store_artifacts:
80
- path: docs
81
- prefix: docs
82
-
83
- coverage:
84
- # coverage runs tests, generates coverage, and saves docs
85
- environment:
86
- TZ: 'America/New_York'
87
- docker:
88
- - image: $CIRCLE_NODE_IMG
89
- # IF YOU NEED ANY OF THESE, UNCOMMENT TO USE
90
- # - image: redis
91
- # - image: circleci/mysql:5.7
92
- # environment:
93
- # MYSQL_USER: root
94
- # MYSQL_ROOT_PASSWORD: root
95
- # MYSQL_ALLOW_EMPTY_PASSWORD: true
96
- # MYSQL_HOST: 127.0.0.1
97
- # - image: nsqio/nsq
98
- # command: /nsqlookupd -broadcast-address localhost:4160 -tcp-address 0.0.0.0:4160 -http-address 0.0.0.0:4161
99
-
100
- # - image: nsqio/nsq
101
- # command: >
102
- # /nsqd
103
- # -broadcast-address localhost:4150
104
- # -tcp-address 0.0.0.0:4150
105
- # -http-address 0.0.0.0:4151
106
- # -lookupd-tcp-address localhost:4160
107
-
108
- steps:
109
- - checkout
110
- - attach_workspace:
111
- at: ~/project
112
-
113
- # UNCOMMENT IF YOU NEED DECRYPTING SECRETS
114
- # - run:
115
- # name: Load secrets
116
- # command: npm run decrypt
117
-
118
- - run:
119
- name: Run Tests and Generate Code Coverage
120
- command: npm run coverage
121
-
122
- - run:
123
- name: Check if coverage meets at least 70%
124
- command: npx c8 check-coverage --functions 70 --lines 70 --statements 70
125
-
126
- - store_artifacts:
127
- path: coverage
128
- prefix: coverage
129
-
130
- workflows:
131
- version: 2.1
132
- test-build-deploy:
133
- jobs:
134
- - install:
135
- context: npm
136
- - security-check:
137
- requires:
138
- - install
139
- - license-check:
140
- requires:
141
- - install
142
- - lint:
143
- requires:
144
- - install
145
- - coverage:
146
- requires:
147
- - install
148
- - docs:
149
- requires:
150
- - install
@@ -1,213 +0,0 @@
1
- version: 2.1
2
- #orbs:
3
- # gcp-gcr: circleci/gcp-gcr@0.6.1
4
- executors:
5
- default:
6
- description: >
7
- A debian-based machine executor.
8
- machine: true
9
- jobs:
10
- install:
11
- docker:
12
- - image: $CIRCLE_NODE_IMG
13
- steps:
14
- - checkout
15
- - restore_cache:
16
- keys:
17
- - v1-npm-deps-{{ checksum "package-lock.json" }}
18
- - v1-npm-deps-
19
-
20
- - run:
21
- name: Setup @leverege Token
22
- command: echo \${NPMRC} > ~/.npmrc
23
-
24
- - run: npm install
25
-
26
- - save_cache:
27
- key: v1-npm-deps-{{ checksum "package-lock.json" }}
28
- paths:
29
- - ./node_modules
30
-
31
- - persist_to_workspace:
32
- root: /home/circleci/project
33
- paths:
34
- - ./node_modules
35
-
36
- security-check:
37
- docker:
38
- - image: $CIRCLE_NODE_IMG
39
- steps:
40
- - checkout
41
- - attach_workspace:
42
- at: ~/project
43
- - run:
44
- name: Check for vulnerabilities
45
- command: npm audit --production --audit-level=moderate
46
-
47
- license-check:
48
- docker:
49
- - image: $CIRCLE_NODE_IMG
50
- steps:
51
- - checkout
52
- - attach_workspace:
53
- at: ~/project
54
- - run:
55
- name: Check for LICENSE and README files
56
- command: npm run pkglint
57
-
58
- - run:
59
- name: Check for license violations (e.g. GPL)
60
- command: npx license-checker --production --summary --failOn GPL
61
-
62
- lint:
63
- docker:
64
- - image: $CIRCLE_NODE_IMG
65
- steps:
66
- - checkout
67
- - attach_workspace:
68
- at: ~/project
69
- - run:
70
- name: Lint and save results
71
- command: npm run lint-ci
72
-
73
- - store_test_results:
74
- path: reports
75
-
76
- docs:
77
- docker:
78
- - image: $CIRCLE_NODE_IMG
79
- steps:
80
- - checkout
81
- - attach_workspace:
82
- at: ~/project
83
- - run:
84
- name: Generate docs
85
- command: npx jsdoc -r src -R README.md -d docs
86
- - store_artifacts:
87
- path: docs
88
- prefix: docs
89
-
90
- coverage:
91
- # coverage runs tests, generates coverage, and saves docs
92
- environment:
93
- TZ: 'America/New_York'
94
- docker:
95
- - image: $CIRCLE_NODE_IMG
96
- # IF YOU NEED ANY OF THESE, UNCOMMENT TO USE
97
- # - image: redis
98
- # - image: circleci/mysql:5.7
99
- # environment:
100
- # MYSQL_USER: root
101
- # MYSQL_ROOT_PASSWORD: root
102
- # MYSQL_ALLOW_EMPTY_PASSWORD: true
103
- # MYSQL_HOST: 127.0.0.1
104
- # - image: nsqio/nsq
105
- # command: /nsqlookupd -broadcast-address localhost:4160 -tcp-address 0.0.0.0:4160 -http-address 0.0.0.0:4161
106
-
107
- # - image: nsqio/nsq
108
- # command: >
109
- # /nsqd
110
- # -broadcast-address localhost:4150
111
- # -tcp-address 0.0.0.0:4150
112
- # -http-address 0.0.0.0:4151
113
- # -lookupd-tcp-address localhost:4160
114
-
115
- steps:
116
- - checkout
117
- - attach_workspace:
118
- at: ~/project
119
-
120
- # UNCOMMENT IF YOU NEED DECRYPTING SECRETS
121
- # - run:
122
- # name: Load secrets
123
- # command: npm run decrypt
124
-
125
- - run:
126
- name: Run Tests and Generate Code Coverage
127
- command: npm run coverage
128
-
129
- - run:
130
- name: Check if coverage meets at least 70%
131
- command: npx c8 check-coverage --functions 70 --lines 70 --statements 70
132
-
133
- - store_artifacts:
134
- path: coverage
135
- prefix: coverage
136
-
137
- build:
138
- # build should make dist image and prepare docker file
139
- docker:
140
- - image: $CIRCLE_NODE_IMG
141
-
142
- steps:
143
- - checkout
144
- - attach_workspace:
145
- at: ~/project
146
-
147
- - run:
148
- name: Setup @leverege Token
149
- command: echo \${NPMRC} > ~/.npmrc.ro
150
-
151
- - run:
152
- name: Determine version number and container name
153
- command: |
154
- container="\`node -p \"require('./package.json').leverege.container\"\`"
155
- if [ "\$container" == "undefined" ];
156
- then
157
- container=\$CIRCLE_PROJECT_REPONAME
158
- fi
159
- NODE_IMAGE="\`node -p \"require('./package.json').leverege.nodeimg\"\`"
160
-
161
- echo \$(git describe --tags) > package_version
162
- echo \${container} > container_name
163
- echo \${NODE_IMAGE} > node_img
164
-
165
- - run:
166
- name: Create Dockerfile and build dist directory
167
- command: mkdir -p docker && npm run dockerize \$(git describe --tags)
168
-
169
- - persist_to_workspace:
170
- root: ~/project
171
- paths:
172
- - docker/*
173
- - package_version
174
- - container_name
175
- - node_img
176
-
177
- workflows:
178
- version: 2.1
179
- test-build-deploy:
180
- jobs:
181
- - install:
182
- context: npm
183
- - security-check:
184
- requires:
185
- - install
186
- - license-check:
187
- requires:
188
- - install
189
- - lint:
190
- requires:
191
- - install
192
- - coverage:
193
- requires:
194
- - install
195
- - docs:
196
- requires:
197
- - install
198
- - build:
199
- context: npm
200
- filters:
201
- branches:
202
- only:
203
- - development
204
- - /release-.*/
205
- - master
206
- requires:
207
- - install
208
- - security-check
209
- - license-check
210
- - lint
211
- - coverage
212
- - docs
213
-
File without changes
@@ -1 +0,0 @@
1
- geotile-local.yaml
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
- #
3
- showInstalling "Geotile Server"
4
-
5
- helm upgrade --install geotile-server leverege/geotile-server \
6
- --values geotile-server/geotile-values.yaml