From b2544e9dbab5a5891022e0789ca50178bb639a39 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Thu, 24 Dec 2020 07:32:03 -0500 Subject: [PATCH 01/13] ci: experiment with gha --- .github/workflows/pull-request.yml | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 000000000..c6bc1be41 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,52 @@ +name: pull-request +on: + pull_request: + +jobs: + test: + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2.3 + - name: Cache node modules + uses: actions/cache@v2.1 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ hashFiles('package.json') }}- + ${{ runner.os }}-node- + - name: Build + run: npm run build:ci + + - name: Copy unit test reports + run: ./gradlew copyAllReports --output-dir=/tmp/test-reports + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + name: codecov-line-smoothing + fail_ci_if_error: true + verbose: true + flags: unit + + - name: Integration test + run: ./gradlew jacocoIntegrationTestReport + + - name: Copy integration test reports + run: ./gradlew copyAllReports --output-dir=/tmp/test-reports + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + name: codecov-line-smoothing + fail_ci_if_error: true + verbose: true + flags: integration + + - name: Archive integration test report + uses: actions/upload-artifact@v1 + with: + name: test-reports + path: /tmp/test-reports + if: ${{ always() }} From ba8aa51526af6a218a635ca79ec0dcc5f3fd9ba0 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Thu, 24 Dec 2020 07:42:04 -0500 Subject: [PATCH 02/13] ci: iterate --- .circleci/config.yml | 226 ----------------------------- .github/workflows/pull-request.yml | 38 +---- 2 files changed, 3 insertions(+), 261 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 3c4f372c8..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,226 +0,0 @@ -version: 2.1 -orbs: - codecov: codecov/codecov@1 -executors: - node: - docker: - - image: cimg/node:14.5 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - publisher: - docker: - - image: cimg/openjdk:11.0 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - helm: - docker: - - image: hypertrace/helm-gcs-packager:0.3.0 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD -commands: - setup_for_building: - description: 'Checks out code and restores node modules' - steps: - - checkout - - restore_cache: - keys: - - node_modules-3-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} - setup_for_publishing: - description: 'Checks out code, sets up credentials, docker and attaches workspace' - steps: - - checkout - - attach_workspace: - at: dist - - setup_remote_docker: &latest_remote_docker - version: 19.03.12 - - run: - name: Dockerhub login - command: echo $DOCKERHUB_PASSWORD | docker login --username $DOCKERHUB_USERNAME --password-stdin -jobs: - npm-install-if-needed: - executor: node - steps: - - setup_for_building - - run: - name: Install if cache missing - command: | - if [ ! -d node_modules ] ; - then npm ci ; - else echo "package.json and package-lock.json unchanged. Using cache." ; - fi - - run: - name: Fail if git dirty after install - command: test -z "$(git status --porcelain)" - - save_cache: - paths: - - node_modules - key: node_modules-3-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} - build: - executor: node - steps: - - setup_for_building - - run: npm run build:ci - - persist_to_workspace: - root: dist - paths: - - hypertrace-ui - lint: - executor: node - steps: - - setup_for_building - - run: npm run lint - - run: npm run prettier:check - test: - executor: node - parallelism: 2 - steps: - - setup_for_building - - run: npm run test:ci -- $(circleci tests glob "{projects,src}/**/*.{spec,test}.ts" | circleci tests split --split-by=timings | xargs -n 1 echo --testPathPattern) - - codecov/upload - - store_test_results: - path: test-results/hypertrace-ui - - store_artifacts: - path: test-results/hypertrace-ui - destination: test-results - merge-publish: - executor: publisher - steps: - - setup_for_publishing - - run: ./gradlew dockerPushImages - release-publish: - executor: publisher - steps: - - setup_for_publishing - - run: ./gradlew dockerPushImages - validate-charts: - executor: helm - steps: - - checkout - - run: - name: Helm Charts Lint and Template Render - command: | - helm lint --strict ./helm/ - helm template ./helm/ - release-charts: - executor: helm - steps: - - checkout - - run: - name: Add release tag - command: | - git config --global user.email "${CIRCLE_USERNAME}@hypertrace.org" - git config --global user.name "$CIRCLE_USERNAME" - git tag -am "Released by $CIRCLE_USERNAME" $(git describe --abbrev=0 --tags | sed 's/^release-//') - - run: - name: Remove trigger tag - command: git tag -d release-$(git describe --abbrev=0) - - run: - name: Package and Publish Helm Charts - # Read the "name:" from Chart.yaml. The chart version is - - command: | - CHART_VERSION=$(git describe --abbrev=0) - CHART_NAME=$(awk '/^name:/ {print $2}' ./helm/Chart.yaml) - export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/helm-gcs-key.json - echo ${HELM_GCS_CREDENTIALS} > ${GOOGLE_APPLICATION_CREDENTIALS} - helm dependency update ./helm/ - helm repo add helm-gcs ${HELM_GCS_REPOSITORY} - helm package --version ${CHART_VERSION} --app-version ${CHART_VERSION} ./helm/ - helm gcs push ${CHART_NAME}-${CHART_VERSION}.tgz helm-gcs --public --retry - - add_ssh_keys: - fingerprints: - # This ssh key gives write permission needed for the following step. - - '2c:f1:1d:8b:a2:b4:6a:28:46:1d:5b:7c:b1:92:d4:ba' - - run: - name: Update remote tags - command: git push origin refs/tags/$(git describe --abbrev=0) :refs/tags/release-$(git describe --abbrev=0) -workflows: - version: 2 - build-and-publish: - jobs: - - npm-install-if-needed: - context: - - dockerhub-read - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - build: - context: - - dockerhub-read - requires: - - npm-install-if-needed - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - test: - context: - - dockerhub-read - requires: - - npm-install-if-needed - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - lint: - context: - - dockerhub-read - requires: - - npm-install-if-needed - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - validate-charts: - context: - - dockerhub-read - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - merge-publish: - context: - - hypertrace-publishing - - dockerhub-read - requires: - - build - - test - - lint - - validate-charts - filters: - branches: - only: - - main - - release-publish: - context: - - hypertrace-publishing - - dockerhub-read - requires: - - build - - test - - lint - - validate-charts - filters: - branches: - ignore: /.*/ - tags: - only: /^release-.*/ - - release-charts: - context: - - hypertrace-publishing - - dockerhub-read - requires: - - release-publish - filters: - branches: - ignore: /.*/ - tags: - only: /^release-.*/ diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c6bc1be41..33ef8c798 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -7,9 +7,9 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Check out code - uses: actions/checkout@v2.3 + uses: actions/checkout@v2 - name: Cache node modules - uses: actions/cache@v2.1 + uses: actions/cache@v2 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} @@ -17,36 +17,4 @@ jobs: ${{ runner.os }}-node-${{ hashFiles('package.json') }}- ${{ runner.os }}-node- - name: Build - run: npm run build:ci - - - name: Copy unit test reports - run: ./gradlew copyAllReports --output-dir=/tmp/test-reports - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - name: codecov-line-smoothing - fail_ci_if_error: true - verbose: true - flags: unit - - - name: Integration test - run: ./gradlew jacocoIntegrationTestReport - - - name: Copy integration test reports - run: ./gradlew copyAllReports --output-dir=/tmp/test-reports - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 - with: - name: codecov-line-smoothing - fail_ci_if_error: true - verbose: true - flags: integration - - - name: Archive integration test report - uses: actions/upload-artifact@v1 - with: - name: test-reports - path: /tmp/test-reports - if: ${{ always() }} + run: npm run build:ci \ No newline at end of file From 52bc9a60a51d2eedc7dd4369aac5107c6f805c60 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Thu, 24 Dec 2020 07:43:56 -0500 Subject: [PATCH 03/13] ci: iterate --- .github/workflows/pull-request.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 33ef8c798..c58eb3ce6 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -16,5 +16,7 @@ jobs: restore-keys: | ${{ runner.os }}-node-${{ hashFiles('package.json') }}- ${{ runner.os }}-node- + - name: NPM Install + run: npm ci - name: Build run: npm run build:ci \ No newline at end of file From 70cbfca00620a3117e16884696211bb8db1b287e Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 09:32:36 -0500 Subject: [PATCH 04/13] ci: add more jobs --- .github/workflows/pull-request.yml | 51 ++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c58eb3ce6..0e4c4e862 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -3,7 +3,7 @@ on: pull_request: jobs: - test: + build: runs-on: ubuntu-20.04 steps: - name: Check out code @@ -19,4 +19,51 @@ jobs: - name: NPM Install run: npm ci - name: Build - run: npm run build:ci \ No newline at end of file + run: npm run build:ci + lint: + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ hashFiles('package.json') }}- + ${{ runner.os }}-node- + - name: NPM Install + run: npm ci + - name: Lint + run: npm run lint + - name: Prettier Check + run: npm run prettier:check + test: + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Cache node modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ hashFiles('package.json') }}- + ${{ runner.os }}-node- + - name: NPM Install + run: npm ci + - name: Test + run: npm run tet:ci + validate-helm-charts: + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up Helm + uses: azure/setup-helm@v1 + with: + version: v3.3.0 + - name: validate charts + uses: hypertrace/actions/validate-charts@main From 64539367e04d3914cd73b521ddd3b301c53db690 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 09:38:51 -0500 Subject: [PATCH 05/13] ci: fix test typo, restore cci to compare timing --- .circleci/config.yml | 226 +++++++++++++++++++++++++++++ .github/workflows/pull-request.yml | 2 +- .prettierignore | 2 + 3 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..3c4f372c8 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,226 @@ +version: 2.1 +orbs: + codecov: codecov/codecov@1 +executors: + node: + docker: + - image: cimg/node:14.5 + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_PASSWORD + publisher: + docker: + - image: cimg/openjdk:11.0 + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_PASSWORD + helm: + docker: + - image: hypertrace/helm-gcs-packager:0.3.0 + auth: + username: $DOCKERHUB_USERNAME + password: $DOCKERHUB_PASSWORD +commands: + setup_for_building: + description: 'Checks out code and restores node modules' + steps: + - checkout + - restore_cache: + keys: + - node_modules-3-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} + setup_for_publishing: + description: 'Checks out code, sets up credentials, docker and attaches workspace' + steps: + - checkout + - attach_workspace: + at: dist + - setup_remote_docker: &latest_remote_docker + version: 19.03.12 + - run: + name: Dockerhub login + command: echo $DOCKERHUB_PASSWORD | docker login --username $DOCKERHUB_USERNAME --password-stdin +jobs: + npm-install-if-needed: + executor: node + steps: + - setup_for_building + - run: + name: Install if cache missing + command: | + if [ ! -d node_modules ] ; + then npm ci ; + else echo "package.json and package-lock.json unchanged. Using cache." ; + fi + - run: + name: Fail if git dirty after install + command: test -z "$(git status --porcelain)" + - save_cache: + paths: + - node_modules + key: node_modules-3-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} + build: + executor: node + steps: + - setup_for_building + - run: npm run build:ci + - persist_to_workspace: + root: dist + paths: + - hypertrace-ui + lint: + executor: node + steps: + - setup_for_building + - run: npm run lint + - run: npm run prettier:check + test: + executor: node + parallelism: 2 + steps: + - setup_for_building + - run: npm run test:ci -- $(circleci tests glob "{projects,src}/**/*.{spec,test}.ts" | circleci tests split --split-by=timings | xargs -n 1 echo --testPathPattern) + - codecov/upload + - store_test_results: + path: test-results/hypertrace-ui + - store_artifacts: + path: test-results/hypertrace-ui + destination: test-results + merge-publish: + executor: publisher + steps: + - setup_for_publishing + - run: ./gradlew dockerPushImages + release-publish: + executor: publisher + steps: + - setup_for_publishing + - run: ./gradlew dockerPushImages + validate-charts: + executor: helm + steps: + - checkout + - run: + name: Helm Charts Lint and Template Render + command: | + helm lint --strict ./helm/ + helm template ./helm/ + release-charts: + executor: helm + steps: + - checkout + - run: + name: Add release tag + command: | + git config --global user.email "${CIRCLE_USERNAME}@hypertrace.org" + git config --global user.name "$CIRCLE_USERNAME" + git tag -am "Released by $CIRCLE_USERNAME" $(git describe --abbrev=0 --tags | sed 's/^release-//') + - run: + name: Remove trigger tag + command: git tag -d release-$(git describe --abbrev=0) + - run: + name: Package and Publish Helm Charts + # Read the "name:" from Chart.yaml. The chart version is - + command: | + CHART_VERSION=$(git describe --abbrev=0) + CHART_NAME=$(awk '/^name:/ {print $2}' ./helm/Chart.yaml) + export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/helm-gcs-key.json + echo ${HELM_GCS_CREDENTIALS} > ${GOOGLE_APPLICATION_CREDENTIALS} + helm dependency update ./helm/ + helm repo add helm-gcs ${HELM_GCS_REPOSITORY} + helm package --version ${CHART_VERSION} --app-version ${CHART_VERSION} ./helm/ + helm gcs push ${CHART_NAME}-${CHART_VERSION}.tgz helm-gcs --public --retry + - add_ssh_keys: + fingerprints: + # This ssh key gives write permission needed for the following step. + - '2c:f1:1d:8b:a2:b4:6a:28:46:1d:5b:7c:b1:92:d4:ba' + - run: + name: Update remote tags + command: git push origin refs/tags/$(git describe --abbrev=0) :refs/tags/release-$(git describe --abbrev=0) +workflows: + version: 2 + build-and-publish: + jobs: + - npm-install-if-needed: + context: + - dockerhub-read + filters: + branches: + only: /.*/ + tags: + only: /^release-.*/ + - build: + context: + - dockerhub-read + requires: + - npm-install-if-needed + filters: + branches: + only: /.*/ + tags: + only: /^release-.*/ + - test: + context: + - dockerhub-read + requires: + - npm-install-if-needed + filters: + branches: + only: /.*/ + tags: + only: /^release-.*/ + - lint: + context: + - dockerhub-read + requires: + - npm-install-if-needed + filters: + branches: + only: /.*/ + tags: + only: /^release-.*/ + - validate-charts: + context: + - dockerhub-read + filters: + branches: + only: /.*/ + tags: + only: /^release-.*/ + - merge-publish: + context: + - hypertrace-publishing + - dockerhub-read + requires: + - build + - test + - lint + - validate-charts + filters: + branches: + only: + - main + - release-publish: + context: + - hypertrace-publishing + - dockerhub-read + requires: + - build + - test + - lint + - validate-charts + filters: + branches: + ignore: /.*/ + tags: + only: /^release-.*/ + - release-charts: + context: + - hypertrace-publishing + - dockerhub-read + requires: + - release-publish + filters: + branches: + ignore: /.*/ + tags: + only: /^release-.*/ diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 0e4c4e862..7d95198ad 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -55,7 +55,7 @@ jobs: - name: NPM Install run: npm ci - name: Test - run: npm run tet:ci + run: npm run test:ci validate-helm-charts: runs-on: ubuntu-20.04 steps: diff --git a/.prettierignore b/.prettierignore index 5949b3583..945a2a585 100644 --- a/.prettierignore +++ b/.prettierignore @@ -12,3 +12,5 @@ Dockerfile nginx/ .* browserslist +LICENSE* +conf/ From 567cecc4237bbcf45b81b2665b57dde38636d11e Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 09:57:35 -0500 Subject: [PATCH 06/13] ci: upload coverage and publish results --- .github/workflows/pull-request.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7d95198ad..3fbcf0f5c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -56,6 +56,16 @@ jobs: run: npm ci - name: Test run: npm run test:ci + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: true + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1.6 + if: always() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: test-results/**/*.xml validate-helm-charts: runs-on: ubuntu-20.04 steps: From 63e13460aa4577bfdcdf4c28f5469d52e17e793b Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 10:02:27 -0500 Subject: [PATCH 07/13] ci: bump From d4be83856608b0a7dd2acfeb5f12a465904fada9 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 10:26:47 -0500 Subject: [PATCH 08/13] ci: fix codecov upload, remove cci --- .circleci/config.yml | 226 ----------------------------- .github/workflows/pull-request.yml | 3 + 2 files changed, 3 insertions(+), 226 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 3c4f372c8..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,226 +0,0 @@ -version: 2.1 -orbs: - codecov: codecov/codecov@1 -executors: - node: - docker: - - image: cimg/node:14.5 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - publisher: - docker: - - image: cimg/openjdk:11.0 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD - helm: - docker: - - image: hypertrace/helm-gcs-packager:0.3.0 - auth: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_PASSWORD -commands: - setup_for_building: - description: 'Checks out code and restores node modules' - steps: - - checkout - - restore_cache: - keys: - - node_modules-3-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} - setup_for_publishing: - description: 'Checks out code, sets up credentials, docker and attaches workspace' - steps: - - checkout - - attach_workspace: - at: dist - - setup_remote_docker: &latest_remote_docker - version: 19.03.12 - - run: - name: Dockerhub login - command: echo $DOCKERHUB_PASSWORD | docker login --username $DOCKERHUB_USERNAME --password-stdin -jobs: - npm-install-if-needed: - executor: node - steps: - - setup_for_building - - run: - name: Install if cache missing - command: | - if [ ! -d node_modules ] ; - then npm ci ; - else echo "package.json and package-lock.json unchanged. Using cache." ; - fi - - run: - name: Fail if git dirty after install - command: test -z "$(git status --porcelain)" - - save_cache: - paths: - - node_modules - key: node_modules-3-{{ checksum "package.json" }}-{{ checksum "package-lock.json"}} - build: - executor: node - steps: - - setup_for_building - - run: npm run build:ci - - persist_to_workspace: - root: dist - paths: - - hypertrace-ui - lint: - executor: node - steps: - - setup_for_building - - run: npm run lint - - run: npm run prettier:check - test: - executor: node - parallelism: 2 - steps: - - setup_for_building - - run: npm run test:ci -- $(circleci tests glob "{projects,src}/**/*.{spec,test}.ts" | circleci tests split --split-by=timings | xargs -n 1 echo --testPathPattern) - - codecov/upload - - store_test_results: - path: test-results/hypertrace-ui - - store_artifacts: - path: test-results/hypertrace-ui - destination: test-results - merge-publish: - executor: publisher - steps: - - setup_for_publishing - - run: ./gradlew dockerPushImages - release-publish: - executor: publisher - steps: - - setup_for_publishing - - run: ./gradlew dockerPushImages - validate-charts: - executor: helm - steps: - - checkout - - run: - name: Helm Charts Lint and Template Render - command: | - helm lint --strict ./helm/ - helm template ./helm/ - release-charts: - executor: helm - steps: - - checkout - - run: - name: Add release tag - command: | - git config --global user.email "${CIRCLE_USERNAME}@hypertrace.org" - git config --global user.name "$CIRCLE_USERNAME" - git tag -am "Released by $CIRCLE_USERNAME" $(git describe --abbrev=0 --tags | sed 's/^release-//') - - run: - name: Remove trigger tag - command: git tag -d release-$(git describe --abbrev=0) - - run: - name: Package and Publish Helm Charts - # Read the "name:" from Chart.yaml. The chart version is - - command: | - CHART_VERSION=$(git describe --abbrev=0) - CHART_NAME=$(awk '/^name:/ {print $2}' ./helm/Chart.yaml) - export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/helm-gcs-key.json - echo ${HELM_GCS_CREDENTIALS} > ${GOOGLE_APPLICATION_CREDENTIALS} - helm dependency update ./helm/ - helm repo add helm-gcs ${HELM_GCS_REPOSITORY} - helm package --version ${CHART_VERSION} --app-version ${CHART_VERSION} ./helm/ - helm gcs push ${CHART_NAME}-${CHART_VERSION}.tgz helm-gcs --public --retry - - add_ssh_keys: - fingerprints: - # This ssh key gives write permission needed for the following step. - - '2c:f1:1d:8b:a2:b4:6a:28:46:1d:5b:7c:b1:92:d4:ba' - - run: - name: Update remote tags - command: git push origin refs/tags/$(git describe --abbrev=0) :refs/tags/release-$(git describe --abbrev=0) -workflows: - version: 2 - build-and-publish: - jobs: - - npm-install-if-needed: - context: - - dockerhub-read - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - build: - context: - - dockerhub-read - requires: - - npm-install-if-needed - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - test: - context: - - dockerhub-read - requires: - - npm-install-if-needed - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - lint: - context: - - dockerhub-read - requires: - - npm-install-if-needed - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - validate-charts: - context: - - dockerhub-read - filters: - branches: - only: /.*/ - tags: - only: /^release-.*/ - - merge-publish: - context: - - hypertrace-publishing - - dockerhub-read - requires: - - build - - test - - lint - - validate-charts - filters: - branches: - only: - - main - - release-publish: - context: - - hypertrace-publishing - - dockerhub-read - requires: - - build - - test - - lint - - validate-charts - filters: - branches: - ignore: /.*/ - tags: - only: /^release-.*/ - - release-charts: - context: - - hypertrace-publishing - - dockerhub-read - requires: - - release-publish - filters: - branches: - ignore: /.*/ - tags: - only: /^release-.*/ diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3fbcf0f5c..28a68d899 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -44,6 +44,9 @@ jobs: steps: - name: Check out code uses: actions/checkout@v2 + # Used by CCI uploader to detect base commit + with: + fetch-depth: 0 - name: Cache node modules uses: actions/cache@v2 with: From e96b6f72ef1f2271cf9198aa06c08664613d58d6 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 11:34:39 -0500 Subject: [PATCH 09/13] ci: more stuff --- .../{pull-request.yml => build-and-test.yml} | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) rename .github/workflows/{pull-request.yml => build-and-test.yml} (65%) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/build-and-test.yml similarity index 65% rename from .github/workflows/pull-request.yml rename to .github/workflows/build-and-test.yml index 28a68d899..596746159 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/build-and-test.yml @@ -1,7 +1,9 @@ -name: pull-request +name: build-and-test on: pull_request: - + push: + branches: + - main jobs: build: runs-on: ubuntu-20.04 @@ -20,6 +22,10 @@ jobs: run: npm ci - name: Build run: npm run build:ci + - name: Archive build artifacts + uses: actions/upload-artifact@v2 + with: + path: dist lint: runs-on: ubuntu-20.04 steps: @@ -64,7 +70,7 @@ jobs: with: fail_ci_if_error: true - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v1.6 + uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.6 if: always() with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -80,3 +86,35 @@ jobs: version: v3.3.0 - name: validate charts uses: hypertrace/actions/validate-charts@main + merge-publish: # TODO: only on push + runs-on: ubuntu-20.04 + needs: [build, lint, test, validate-helm-charts] + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Create checksum file + uses: hypertrace/actions/checksum@main + + - name: Cache gradle + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ runner.os }}-${{ hashFiles('**/checksum.txt') }} + restore-keys: | + gradle-${{ runner.os }} + + - name: Download build results + uses: actions/download-artifact@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_READ_USER }} + password: ${{ secrets.DOCKERHUB_READ_TOKEN }} + + - name: Push docker image + run: ./gradlew dockerBuildImages # TODO: convert to push, add creds + # env: + # DOCKER_USERNAME: ${{ secrets.DOCKERHUB_PUBLISH_USER }} + # DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PUBLISH_TOKEN }} From 6f55d52f845a4515d7c021c1a2341130985f0518 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 12:40:01 -0500 Subject: [PATCH 10/13] ci: bump From 435301a832ea03d2e7f92742687b248af9f035c5 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 12:57:21 -0500 Subject: [PATCH 11/13] ci: fix download path --- .github/workflows/build-and-test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 596746159..34121b10d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -25,6 +25,7 @@ jobs: - name: Archive build artifacts uses: actions/upload-artifact@v2 with: + name: dist path: dist lint: runs-on: ubuntu-20.04 @@ -92,6 +93,9 @@ jobs: steps: - name: Check out code uses: actions/checkout@v2 + # Used by gradle version calculation + with: + fetch-depth: 0 - name: Create checksum file uses: hypertrace/actions/checksum@main @@ -106,6 +110,8 @@ jobs: - name: Download build results uses: actions/download-artifact@v2 + with: + name: dist - name: Login to Docker Hub uses: docker/login-action@v1 From 019e5de1ed66cc91ad3711a71b82e04fdf23ee11 Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 13:19:50 -0500 Subject: [PATCH 12/13] ci: fix download --- .github/workflows/build-and-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 34121b10d..e2d90d2b9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -112,6 +112,10 @@ jobs: uses: actions/download-artifact@v2 with: name: dist + path: dist + - name: Display structure of downloaded files + run: ls -R + working-directory: dist - name: Login to Docker Hub uses: docker/login-action@v1 From e78390202a853915dc4a617e8c4d8d2c7cf6123e Mon Sep 17 00:00:00 2001 From: Aaron Steinfeld Date: Sun, 27 Dec 2020 14:04:34 -0500 Subject: [PATCH 13/13] ci: add publish --- .github/workflows/build-and-test.yml | 26 +++++++--- .github/workflows/publish.yml | 73 ++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e2d90d2b9..b1f567269 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -10,6 +10,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v2 + - name: Cache node modules uses: actions/cache@v2 with: @@ -18,10 +19,13 @@ jobs: restore-keys: | ${{ runner.os }}-node-${{ hashFiles('package.json') }}- ${{ runner.os }}-node- + - name: NPM Install run: npm ci + - name: Build run: npm run build:ci + - name: Archive build artifacts uses: actions/upload-artifact@v2 with: @@ -32,6 +36,7 @@ jobs: steps: - name: Check out code uses: actions/checkout@v2 + - name: Cache node modules uses: actions/cache@v2 with: @@ -42,8 +47,10 @@ jobs: ${{ runner.os }}-node- - name: NPM Install run: npm ci + - name: Lint run: npm run lint + - name: Prettier Check run: npm run prettier:check test: @@ -54,6 +61,7 @@ jobs: # Used by CCI uploader to detect base commit with: fetch-depth: 0 + - name: Cache node modules uses: actions/cache@v2 with: @@ -62,14 +70,18 @@ jobs: restore-keys: | ${{ runner.os }}-node-${{ hashFiles('package.json') }}- ${{ runner.os }}-node- + - name: NPM Install run: npm ci + - name: Test run: npm run test:ci + - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: fail_ci_if_error: true + - name: Publish Unit Test Results uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.6 if: always() @@ -87,7 +99,8 @@ jobs: version: v3.3.0 - name: validate charts uses: hypertrace/actions/validate-charts@main - merge-publish: # TODO: only on push + merge-publish: + if: github.event_name == 'push' runs-on: ubuntu-20.04 needs: [build, lint, test, validate-helm-charts] steps: @@ -113,9 +126,6 @@ jobs: with: name: dist path: dist - - name: Display structure of downloaded files - run: ls -R - working-directory: dist - name: Login to Docker Hub uses: docker/login-action@v1 @@ -124,7 +134,7 @@ jobs: password: ${{ secrets.DOCKERHUB_READ_TOKEN }} - name: Push docker image - run: ./gradlew dockerBuildImages # TODO: convert to push, add creds - # env: - # DOCKER_USERNAME: ${{ secrets.DOCKERHUB_PUBLISH_USER }} - # DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PUBLISH_TOKEN }} + run: ./gradlew dockerPushImages + env: + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_PUBLISH_USER }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PUBLISH_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..ae4d7e69f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,73 @@ +name: Publish artifacts +on: + # Will only run when release is published. + release: + types: + - created + workflow_dispatch: + +jobs: + publish-docker: + runs-on: ubuntu-20.04 + steps: + # Set fetch-depth: 0 to fetch commit history and tags for use in version calculation + - name: Check out code + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + + - name: Cache node modules + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node-${{ hashFiles('package.json') }}- + ${{ runner.os }}-node- + + - name: NPM Install + run: npm ci + + - name: Build + run: npm run build:ci + + - name: Create checksum file + uses: hypertrace/actions/checksum@main + + - name: Cache gradle + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ runner.os }}-${{ hashFiles('**/checksum.txt') }} + restore-keys: | + gradle-${{ runner.os }} + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_READ_USER }} + password: ${{ secrets.DOCKERHUB_READ_TOKEN }} + + - name: Publish docker image + run: ./gradlew dockerPushImages + env: + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_PUBLISH_USER }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PUBLISH_TOKEN }} + + publish-charts: + needs: publish-docker + runs-on: ubuntu-20.04 + container: + image: hypertrace/helm-gcs-packager:0.3.1 + credentials: + username: ${{ secrets.DOCKERHUB_READ_USER }} + password: ${{ secrets.DOCKERHUB_READ_TOKEN }} + steps: + - name: Checkout Repository + uses: actions/checkout@v2.3.4 + + - name: Package and release charts + env: + HELM_GCS_CREDENTIALS: ${{ secrets.HELM_GCS_CREDENTIALS }} + HELM_GCS_REPOSITORY: ${{ secrets.HELM_GCS_REPOSITORY }} + uses: hypertrace/actions/helm-gcs-publish@main