|
| 1 | +version: 2.1 |
| 2 | +orbs: |
| 3 | + codecov: codecov/codecov@1 |
| 4 | +executors: |
| 5 | + node: |
| 6 | + docker: |
| 7 | + - image: cimg/node:14.5 |
| 8 | + publisher: |
| 9 | + docker: |
| 10 | + - image: cimg/openjdk:11.0 |
| 11 | + helm: |
| 12 | + docker: |
| 13 | + - image: hypertrace/helm-gcs-packager:0.1.1 |
| 14 | +commands: |
| 15 | + update-submodule: |
| 16 | + description: 'Pull Submodules' |
| 17 | + steps: |
| 18 | + - run: |
| 19 | + name: Pull Submodules |
| 20 | + command: git submodule update --init |
| 21 | + - run: |
| 22 | + name: Ensure submodules point to commit from master branch |
| 23 | + command: git submodule foreach "git merge-base --is-ancestor HEAD origin/master" |
| 24 | + |
| 25 | + setup_for_building: |
| 26 | + description: 'Checks out code and restores node modules' |
| 27 | + steps: |
| 28 | + - checkout |
| 29 | + - update-submodule |
| 30 | + - restore_cache: |
| 31 | + keys: |
| 32 | + - node_modules-3-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} |
| 33 | + setup_for_publishing: |
| 34 | + description: 'Checks out code, sets up credentials, docker and attaches workspace' |
| 35 | + steps: |
| 36 | + - add_ssh_keys: |
| 37 | + fingerprints: |
| 38 | + - '2c:f1:1d:8b:a2:b4:6a:28:46:1d:5b:7c:b1:92:d4:ba' |
| 39 | + - checkout |
| 40 | + - update-submodule |
| 41 | + - attach_workspace: |
| 42 | + at: dist |
| 43 | + - setup_remote_docker |
| 44 | +jobs: |
| 45 | + npm-install-if-needed: |
| 46 | + executor: node |
| 47 | + steps: |
| 48 | + - setup_for_building |
| 49 | + - run: |
| 50 | + name: Install if cache missing |
| 51 | + command: | |
| 52 | + if [ ! -d node_modules ] ; |
| 53 | + then npm ci ; |
| 54 | + else echo "package.json and package-lock.json unchanged. Using cache." ; |
| 55 | + fi |
| 56 | + - run: |
| 57 | + name: Fail if git dirty after install |
| 58 | + command: test -z "$(git status --porcelain)" |
| 59 | + - save_cache: |
| 60 | + paths: |
| 61 | + - node_modules |
| 62 | + key: node_modules-3-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} |
| 63 | + build: |
| 64 | + executor: node |
| 65 | + steps: |
| 66 | + - setup_for_building |
| 67 | + - run: npm run build:ci |
| 68 | + - persist_to_workspace: |
| 69 | + root: dist |
| 70 | + paths: |
| 71 | + - hypertrace-ui |
| 72 | + lint: |
| 73 | + executor: node |
| 74 | + steps: |
| 75 | + - setup_for_building |
| 76 | + - run: npm run lint |
| 77 | + - run: npm run prettier:check |
| 78 | + test: |
| 79 | + executor: node |
| 80 | + parallelism: 2 |
| 81 | + steps: |
| 82 | + - setup_for_building |
| 83 | + - run: npm run test:ci -- $(circleci tests glob "{projects,src}/**/*.{spec,test}.ts" | circleci tests split --split-by=timings | xargs -n 1 echo --testPathPattern) |
| 84 | + - codecov/upload |
| 85 | + - store_test_results: |
| 86 | + path: test-results/hypertrace-ui |
| 87 | + - store_artifacts: |
| 88 | + path: test-results/hypertrace-ui |
| 89 | + destination: test-results |
| 90 | + validate-charts: |
| 91 | + executor: helm |
| 92 | + steps: |
| 93 | + - checkout |
| 94 | + - run: |
| 95 | + name: Helm Charts Lint and Template Render |
| 96 | + command: | |
| 97 | + helm lint --strict ./helm/ |
| 98 | + helm template ./helm/ |
| 99 | + publish: |
| 100 | + executor: publisher |
| 101 | + steps: |
| 102 | + - setup_for_publishing |
| 103 | + - run: ./gradlew :tag -Prelease |
| 104 | + - run: |
| 105 | + name: Push git tag |
| 106 | + command: git push origin $(./gradlew -q :printVersion) |
| 107 | + - run: ./gradlew dockerPushImages |
| 108 | + package-charts: |
| 109 | + executor: helm |
| 110 | + steps: |
| 111 | + - checkout |
| 112 | + - run: |
| 113 | + name: Package and Publish Helm Charts |
| 114 | + command: | |
| 115 | + CHART_VERSION=$(git describe --abbrev=0) |
| 116 | + CHART_NAME=$(awk '/^name:/ {print $2}' ./helm/Chart.yaml) |
| 117 | + export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/helm-gcs-key.json |
| 118 | + echo ${HELM_GCS_CREDENTIALS} > ${GOOGLE_APPLICATION_CREDENTIALS} |
| 119 | + helm repo add helm-gcs ${HELM_GCS_REPOSITORY} |
| 120 | + helm package --version ${CHART_VERSION} --app-version ${CHART_VERSION} ./helm/ |
| 121 | + helm gcs push ${CHART_NAME}-${CHART_VERSION}.tgz helm-gcs --public --retry |
| 122 | +workflows: |
| 123 | + version: 2 |
| 124 | + build-and-publish: |
| 125 | + jobs: |
| 126 | + - npm-install-if-needed |
| 127 | + - build: |
| 128 | + requires: |
| 129 | + - npm-install-if-needed |
| 130 | + - test: |
| 131 | + requires: |
| 132 | + - npm-install-if-needed |
| 133 | + - lint: |
| 134 | + requires: |
| 135 | + - npm-install-if-needed |
| 136 | + - validate-charts |
| 137 | + - publish: |
| 138 | + context: hypertrace-publishing |
| 139 | + requires: |
| 140 | + - build |
| 141 | + - test |
| 142 | + - lint |
| 143 | + - validate-charts |
| 144 | + filters: |
| 145 | + branches: |
| 146 | + only: |
| 147 | + - master |
| 148 | + - package-charts: |
| 149 | + context: hypertrace-publishing |
| 150 | + requires: |
| 151 | + - publish |
| 152 | + filters: |
| 153 | + branches: |
| 154 | + only: |
| 155 | + - master |
0 commit comments