From 15ccc8d71ebfcbffb7eb7f7b0b1c1e74acadbee9 Mon Sep 17 00:00:00 2001 From: Jordan Davidson <46907218+jordantomiko@users.noreply.github.com> Date: Mon, 27 Oct 2025 14:21:40 +0000 Subject: [PATCH 1/5] Copy over cloudbuild.yaml from existing project Copying over from search-service as a starting point and then will customise in next commit --- cloudbuild.yaml | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 cloudbuild.yaml diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..469084e --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,80 @@ +steps: + - id: 'Create .env file' + name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:alpine' + args: + - sh + - -c + - | + echo "SENTRY_DSN=''" > .env + - id: 'Build image' + name: 'gcr.io/cloud-builders/docker' + entrypoint: 'sh' + args: + - -c + - | + docker build \ + --target production \ + -t europe-west1-docker.pkg.dev/${PROJECT_ID}/hubblehq-docker/search-service \ + . + - id: 'Run linting' + name: 'gcr.io/cloud-builders/docker' + entrypoint: 'sh' + args: + - -c + - | + docker compose \ + -f docker-compose.yml \ + --profile production \ + run \ + --rm \ + production yarn lint:js + waitFor: ['Build image'] + + - id: 'Run tests' + name: 'gcr.io/cloud-builders/docker' + entrypoint: 'sh' + args: + - -c + - | + docker compose \ + -f docker-compose.yml \ + --profile production \ + run \ + --rm \ + production yarn test src\/* + waitFor: ['Build image', 'Run linting'] + + - id: 'Push to registry' + name: 'gcr.io/cloud-builders/docker' + entrypoint: 'sh' + args: + - -c + - docker push ${_DOCKER_TAG} + waitFor: ['Run tests', 'Run linting'] + + - id: 'Deploy to Cloud Run' + name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:alpine' + entrypoint: 'bash' + args: + - '-c' + - | + if [[ "$BRANCH_NAME" == "main" ]]; then + gcloud run deploy search-service \ + --platform managed \ + --region ${LOCATION} \ + --image ${_DOCKER_TAG} + else + echo "Skipping deploy - not on main branch" + fi + waitFor: ['Push to registry'] + +substitutions: + _SERVICE_NAME: search-service + _BUILD_ID_SHORT: ${BUILD_ID:0:8} + _DOCKER_TAG: ${LOCATION}-docker.pkg.dev/${PROJECT_ID}/hubblehq-docker/${_SERVICE_NAME} + _DOCKER_TAG_SCRIPTS: ${LOCATION}-docker.pkg.dev/${PROJECT_ID}/hubblehq-docker/${_SERVICE_NAME}-scripts + +options: + dynamicSubstitutions: true + machineType: 'E2_HIGHCPU_8' + logging: CLOUD_LOGGING_ONLY \ No newline at end of file From 3ed2d716f57f23d5cd96be6dad57fdf8e5e2bd44 Mon Sep 17 00:00:00 2001 From: Jordan Davidson <46907218+jordantomiko@users.noreply.github.com> Date: Mon, 27 Oct 2025 15:00:47 +0000 Subject: [PATCH 2/5] Customise cloudbuild.yaml file Remove the deployment steps as I believe this project just needs to run build and test as there are manual deployment steps. --- cloudbuild.yaml | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 469084e..ed8c2d6 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -14,7 +14,7 @@ steps: - | docker build \ --target production \ - -t europe-west1-docker.pkg.dev/${PROJECT_ID}/hubblehq-docker/search-service \ + -t europe-west1-docker.pkg.dev/${PROJECT_ID}/hubblehq-docker/request \ . - id: 'Run linting' name: 'gcr.io/cloud-builders/docker' @@ -41,35 +41,11 @@ steps: --profile production \ run \ --rm \ - production yarn test src\/* + production yarn test waitFor: ['Build image', 'Run linting'] - - id: 'Push to registry' - name: 'gcr.io/cloud-builders/docker' - entrypoint: 'sh' - args: - - -c - - docker push ${_DOCKER_TAG} - waitFor: ['Run tests', 'Run linting'] - - - id: 'Deploy to Cloud Run' - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:alpine' - entrypoint: 'bash' - args: - - '-c' - - | - if [[ "$BRANCH_NAME" == "main" ]]; then - gcloud run deploy search-service \ - --platform managed \ - --region ${LOCATION} \ - --image ${_DOCKER_TAG} - else - echo "Skipping deploy - not on main branch" - fi - waitFor: ['Push to registry'] - substitutions: - _SERVICE_NAME: search-service + _SERVICE_NAME: request _BUILD_ID_SHORT: ${BUILD_ID:0:8} _DOCKER_TAG: ${LOCATION}-docker.pkg.dev/${PROJECT_ID}/hubblehq-docker/${_SERVICE_NAME} _DOCKER_TAG_SCRIPTS: ${LOCATION}-docker.pkg.dev/${PROJECT_ID}/hubblehq-docker/${_SERVICE_NAME}-scripts From 6cf25612af645d2ae3483f02b1552f091df24b2f Mon Sep 17 00:00:00 2001 From: Jordan Davidson <46907218+jordantomiko@users.noreply.github.com> Date: Mon, 27 Oct 2025 15:03:28 +0000 Subject: [PATCH 3/5] Remove references to circle ci & config We're moving to cloudbuild so we don't need these --- .circleci/config.yml | 120 ------------------------------------------- .npmignore | 2 +- 2 files changed, 1 insertion(+), 121 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index e547844..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,120 +0,0 @@ -version: 2 - -# build job parameters as a template -defaults: &defaults - working_directory: ~/repo - docker: - # the Docker image with Cypress dependencies - - image: cimg/node:20.5.1 - auth: - username: $DOCKERHUB_USER - password: $DOCKERHUB_PASSWORD - environment: - ## this enables colors in the output - TERM: xterm - -default_cache_keys: &default_cache_keys - keys: - - v1-yarn-deps-{{ checksum "yarn.lock" }} - - v1-yarn-deps - -default_save_cache: &default_save_cache - key: v1-yarn-deps-{{ checksum "yarn.lock" }} - paths: - - node_modules - -install_yarn: &install_yarn - name: Install yarn - command: yarn policies set-version 1.x - -jobs: - install_packages: - # Main build process - <<: *defaults - steps: - # Checkout repo - - checkout - - run: *install_yarn - # Restore yarn cache - - restore_cache: *default_cache_keys - # Install & Build - - run: yarn install - # Save updated yarn cache - - save_cache: *default_save_cache - - build: - <<: *defaults - steps: - # Checkout repo - - checkout - - run: *install_yarn - # Restore yarn cache - - restore_cache: *default_cache_keys - # Create a build - - run: - name: Creating a build - command: yarn run build - # Save public repo to a shared workspace - # This way can be used in future tests - - persist_to_workspace: - root: ~/repo/dist - paths: - - ./* - - unitTests: - # Unit tests (jest) - <<: *defaults - parallelism: 3 - steps: - # Checkout git repo - - checkout - - run: *install_yarn - # Restore yarn cache - - restore_cache: *default_cache_keys - # Run the jest tests - - run: - name: Run tests - command: | - yarn test --ci --runInBand - environment: - JEST_JUNIT_OUTPUT_DIR: 'reports/junit/js-test-results.xml' - - store_test_results: - name: Store test results - path: ./reports/junit - - linting: - # Linting (eslint/prettier) - <<: *defaults - steps: - # Checkout git repo - - checkout - - run: *install_yarn - # Restore yarn cache - - restore_cache: *default_cache_keys - # Run eslint - - run: - name: Running lint processes - command: yarn lint - -workflows: - version: 2 - build_and_test: - jobs: - - install_packages: - context: - - hubblehq-docker - - build: - context: - - hubblehq-docker - requires: - - install_packages - - unitTests: - context: - - hubblehq-docker - requires: - - install_packages - - linting: - context: - - hubblehq-docker - requires: - - install_packages diff --git a/.npmignore b/.npmignore index 8ce2e1b..8283fcd 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,4 @@ -/.circleci +/cloudbuild.yaml /.jest /build-scripts /coverage From 451b2637df695872af8b836b20b80b73c5ebb29f Mon Sep 17 00:00:00 2001 From: Jordan Davidson <46907218+jordantomiko@users.noreply.github.com> Date: Mon, 27 Oct 2025 15:39:13 +0000 Subject: [PATCH 4/5] Update lint command --- cloudbuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index ed8c2d6..6ba2ec6 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -27,7 +27,7 @@ steps: --profile production \ run \ --rm \ - production yarn lint:js + production yarn lint waitFor: ['Build image'] - id: 'Run tests' From f47311b46062603e096927af957f179fda2b8772 Mon Sep 17 00:00:00 2001 From: Jordan Davidson <46907218+jordantomiko@users.noreply.github.com> Date: Mon, 27 Oct 2025 16:28:28 +0000 Subject: [PATCH 5/5] Change the target in the cloudbuild.yaml to dev There were failures because it relied on eslint being installed which is a dev dependency. The main reason we run checks against a production container is to ensure that the exact deployed environment works. Here, we only need build-and-test step as deployment is a manual process so the build isn't producing a production container (I THINK!) and so it should be ok to run tests and linting against a dev env. --- cloudbuild.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 6ba2ec6..bfaf5e9 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -13,7 +13,7 @@ steps: - -c - | docker build \ - --target production \ + --target dev \ -t europe-west1-docker.pkg.dev/${PROJECT_ID}/hubblehq-docker/request \ . - id: 'Run linting' @@ -24,10 +24,10 @@ steps: - | docker compose \ -f docker-compose.yml \ - --profile production \ + --profile dev \ run \ --rm \ - production yarn lint + dev yarn lint waitFor: ['Build image'] - id: 'Run tests' @@ -38,10 +38,10 @@ steps: - | docker compose \ -f docker-compose.yml \ - --profile production \ + --profile dev \ run \ --rm \ - production yarn test + dev yarn test waitFor: ['Build image', 'Run linting'] substitutions: