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/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 000000000..b1f567269 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,140 @@ +name: build-and-test +on: + pull_request: + push: + branches: + - main +jobs: + build: + 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: Build + run: npm run build:ci + + - name: Archive build artifacts + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist + 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 + # Used by CCI uploader to detect base commit + 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: 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() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: test-results/**/*.xml + 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 + merge-publish: + if: github.event_name == 'push' + runs-on: ubuntu-20.04 + needs: [build, lint, test, validate-helm-charts] + 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 + + - 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 + with: + name: dist + path: dist + + - 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 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 diff --git a/.prettierignore b/.prettierignore index 5949b3583..945a2a585 100644 --- a/.prettierignore +++ b/.prettierignore @@ -12,3 +12,5 @@ Dockerfile nginx/ .* browserslist +LICENSE* +conf/