From 10a3fff3bc1adf9e495ec45dd5e88895b4c58667 Mon Sep 17 00:00:00 2001 From: Kartik Shah Date: Tue, 9 Jan 2024 14:52:01 +0530 Subject: [PATCH] ci: cleanup unused scripts --- ci/tasks/bump-image-digest.sh | 47 ---------- ci/tasks/install-deps.sh | 13 --- ci/tasks/open-charts-pr.sh | 149 ------------------------------- ci/tasks/prepare-docker-build.sh | 3 - ci/tasks/test-integration.sh | 62 ------------- ci/tasks/unpack-deps.sh | 17 ---- 6 files changed, 291 deletions(-) delete mode 100755 ci/tasks/bump-image-digest.sh delete mode 100755 ci/tasks/install-deps.sh delete mode 100755 ci/tasks/open-charts-pr.sh delete mode 100755 ci/tasks/prepare-docker-build.sh delete mode 100755 ci/tasks/test-integration.sh delete mode 100755 ci/tasks/unpack-deps.sh diff --git a/ci/tasks/bump-image-digest.sh b/ci/tasks/bump-image-digest.sh deleted file mode 100755 index 1a68e6dd42..0000000000 --- a/ci/tasks/bump-image-digest.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -set -eu - -export digest=$(cat ./edge-image/digest) -export exporter_digest=$(cat ./exporter-edge-image/digest) -export trigger_digest=$(cat ./trigger-edge-image/digest) -export cron_digest=$(cat ./cron-edge-image/digest) -export migrate_digest=$(cat ./migrate-edge-image/digest) -export websocket_digest=$(cat ./websocket-edge-image/digest) -export api_keys_digest=$(cat ./api-keys-edge-image/digest) -export ref=$(cat ./repo/.git/short_ref) -export app_version=$(cat version/version) - -mkdir -p charts-repo/charts/galoy/apollo-router -cp ./repo/core/api/src/graphql/public/schema.graphql ./charts-repo/charts/galoy/apollo-router/public-schema.graphql -cp ./repo/core/api-keys/subgraph/schema.graphql ./charts-repo/charts/galoy/apollo-router/api-keys-schema.graphql - -# The supergraph being copied below is a composition of the schemas above -cp ./repo/dev/config/apollo-federation/supergraph.graphql ./charts-repo/charts/galoy/apollo-router/supergraph.graphql - -pushd charts-repo - -yq -i e '.galoy.images.app.digest = strenv(digest)' ./charts/galoy/values.yaml -yq -i e '.galoy.images.app.git_ref = strenv(ref)' ./charts/galoy/values.yaml -yq -i e '.galoy.images.mongodbMigrate.digest = strenv(migrate_digest)' ./charts/galoy/values.yaml -yq -i e '.galoy.images.websocket.digest = strenv(websocket_digest)' ./charts/galoy/values.yaml -yq -i e '.galoy.images.exporter.digest = strenv(exporter_digest)' ./charts/galoy/values.yaml -yq -i e '.galoy.images.trigger.digest = strenv(trigger_digest)' ./charts/galoy/values.yaml -yq -i e '.galoy.images.cron.digest = strenv(cron_digest)' ./charts/galoy/values.yaml -yq -i e '.galoy.images.apiKeys.digest = strenv(api_keys_digest)' ./charts/galoy/values.yaml -yq -i e '.appVersion = strenv(app_version)' ./charts/galoy/Chart.yaml - -if [[ -z $(git config --global user.email) ]]; then - git config --global user.email "bot@galoy.io" -fi -if [[ -z $(git config --global user.name) ]]; then - git config --global user.name "CI Bot" -fi - -( - cd $(git rev-parse --show-toplevel) - git merge --no-edit ${BRANCH} - git add -A - git status - git commit -m "chore(deps): bump galoy image to '${digest}'" -) diff --git a/ci/tasks/install-deps.sh b/ci/tasks/install-deps.sh deleted file mode 100755 index 3d696a1770..0000000000 --- a/ci/tasks/install-deps.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -eu - -tar_out="$(pwd)/bundled-deps" - -pushd deps/core/api -yarn install -git log --pretty=format:'%h' -n 1 > gitref - -tar -zcvf "${tar_out}/bundled-deps-v$(cat ../../../deps-version/number)-$(cat gitref).tgz" . > /dev/null - -popd diff --git a/ci/tasks/open-charts-pr.sh b/ci/tasks/open-charts-pr.sh deleted file mode 100755 index 0dcbf47031..0000000000 --- a/ci/tasks/open-charts-pr.sh +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/bash - -set -eu - -export digest=$(cat ./edge-image/digest) -export exporter_digest=$(cat ./exporter-edge-image/digest) -export trigger_digest=$(cat ./trigger-edge-image/digest) -export cron_digest=$(cat ./cron-edge-image/digest) -export migrate_digest=$(cat ./migrate-edge-image/digest) -export websocket_digest=$(cat ./websocket-edge-image/digest) -export api_keys_digest=$(cat ./api-keys-edge-image/digest) -export github_url=https://github.com/GaloyMoney/galoy - -pushd charts-repo - -ref=$(yq e '.galoy.images.app.git_ref' charts/galoy/values.yaml) -git checkout ${BRANCH} -old_ref=$(yq e '.galoy.images.app.git_ref' charts/galoy/values.yaml) - -pushd ../repo - -if [[ -z $(git config --global user.email) ]]; then - git config --global user.email "bot@galoy.io" -fi -if [[ -z $(git config --global user.name) ]]; then - git config --global user.name "CI Bot" -fi - -export GH_TOKEN="$(gh-token generate -b "${GH_APP_PRIVATE_KEY}" -i "${GH_APP_ID}" | jq -r '.token')" -gh auth setup-git -# switch to https to use the token -git remote set-url origin ${github_url} - -git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" - -git checkout ${ref} -app_src_files=($(buck2 uquery 'inputs(deps("//core/..."))' 2>/dev/null)) - -relevant_commits=() -for commit in $(git log --format="%H" ${old_ref}..${ref}); do - changed_files=$(git diff-tree --no-commit-id --name-only -r $commit) - - for file in ${changed_files[@]}; do - if printf '%s\n' "${app_src_files[@]}" | grep -Fxq "$file"; then - relevant_commits+=($commit) - break - fi - done -done - -# create a branch from the old state and commit the new state of core -set +e -git fetch origin core-${old_ref} -# if the above exits with 128, it means the branch doesn't exist yet -if [[ $? -eq 128 ]]; then - git checkout --orphan core-${old_ref} - git rm -rf . > /dev/null - for file in "${app_src_files[@]}"; do - git checkout "$old_ref" -- "$file" - done - git commit -m "Commit state of \`core\` at \`${old_ref}\`" - git push -fu origin core-${old_ref} -fi -set -e - -git checkout core-${old_ref} -git checkout -b core-${ref} -for file in "${app_src_files[@]}"; do - git checkout "$ref" -- "$file" -done - -git commit -m "Commit state of \`core\` at \`${ref}\`" --allow-empty -git push -fu origin core-${ref} - -cat <> ../body.md -# Bump galoy image - -Code diff contained in this image: - -${github_url}/compare/core-${old_ref}...core-${ref} - -Relevant commits: -EOF - -if [[ "${#relevant_commits[@]}" -eq 0 ]]; then - echo "- No relevant commits found" >> ../body.md -else - for commit in "${relevant_commits[@]}"; do - cat <<-EOF >> ../body.md - - ${github_url}/commit/${commit} - EOF - done -fi - -cat <> ../body.md - -The galoy api image will be bumped to digest: -\`\`\` -${digest} -\`\`\` - -The galoy trigger image will be bumped to digest: -\`\`\` -${trigger_digest} -\`\`\` - -The galoy exporter image will be bumped to digest: -\`\`\` -${exporter_digest} -\`\`\` - -The galoy cron image will be bumped to digest: -\`\`\` -${cron_digest} -\`\`\` - -The mongodbMigrate image will be bumped to digest: -\`\`\` -${migrate_digest} -\`\`\` - -The websocket image will be bumped to digest: -\`\`\` -${websocket_digest} -\`\`\` - -The api-keys image will be bumped to digest: -\`\`\` -${api_keys_digest} -\`\`\` -EOF - -git cliff --config ../pipeline-tasks/ci/vendor/config/git-cliff.toml ${old_ref}..${ref} > ../charts-repo/release_notes.md - -popd - -breaking="" -if [[ $(cat release_notes.md | grep breaking) != '' ]]; then - breaking="--label breaking" -fi - -gh pr close ${BOT_BRANCH} || true -gh pr create \ - --title "chore(deps): bump-galoy-image-${ref}" \ - --body-file ../body.md \ - --base ${BRANCH} \ - --head ${BOT_BRANCH} \ - --label galoybot \ - --label galoy ${breaking} diff --git a/ci/tasks/prepare-docker-build.sh b/ci/tasks/prepare-docker-build.sh deleted file mode 100755 index c9dd3dd12f..0000000000 --- a/ci/tasks/prepare-docker-build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -echo "COMMITHASH=$(cat repo/.git/ref)" > repo/.build-args diff --git a/ci/tasks/test-integration.sh b/ci/tasks/test-integration.sh deleted file mode 100755 index 3c61644c5b..0000000000 --- a/ci/tasks/test-integration.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -set -eu - -. pipeline-tasks/ci/tasks/helpers.sh - -CI_ROOT=$(pwd) - -unpack_deps - -cat < ${CI_ROOT}/gcloud-creds.json -${GOOGLE_CREDENTIALS} -EOF -cat < ${CI_ROOT}/login.ssh -${SSH_PRIVATE_KEY} -EOF -chmod 600 ${CI_ROOT}/login.ssh -cat < ${CI_ROOT}/login.ssh.pub -${SSH_PUB_KEY} -EOF -gcloud auth activate-service-account --key-file ${CI_ROOT}/gcloud-creds.json -gcloud compute os-login ssh-keys add --key-file=${CI_ROOT}/login.ssh.pub > /dev/null - -mkdir ~/.ssh -cp ${CI_ROOT}/login.ssh ~/.ssh/id_rsa -cp ${CI_ROOT}/login.ssh.pub ~/.ssh/id_rsa.pub - -export DOCKER_HOST_USER="sa_$(cat ${CI_ROOT}/gcloud-creds.json | jq -r '.client_id')" -export ADDITIONAL_SSH_OPTS="-o StrictHostKeyChecking=no -i ${CI_ROOT}/login.ssh" - -# Compiled js files are owned by root because they were created in a container. They must be deleted with "sudo". -ssh ${ADDITIONAL_SSH_OPTS} ${DOCKER_HOST_USER}@${DOCKER_HOST_IP} \ - "cd ${REPO_PATH}; sudo rm -rf lib .swc" - -echo "Syncing repo to docker-host... " -rsync --delete -avr -e "ssh -l ${DOCKER_HOST_USER} ${ADDITIONAL_SSH_OPTS}" \ - ${REPO_PATH}/ ${DOCKER_HOST_IP}:${REPO_PATH} > /dev/null -echo "Done!" - -ssh ${ADDITIONAL_SSH_OPTS} ${DOCKER_HOST_USER}@${DOCKER_HOST_IP} \ - "cd ${REPO_PATH}; docker compose down --volumes --remove-orphans --timeout 1; DOCKER_HOST_IP=${DOCKER_HOST_IP} docker compose -f docker-compose.yml up integration-deps -d" - -export DOCKER_HOST=ssh://${DOCKER_HOST_USER}@${DOCKER_HOST_IP} - -pushd ${REPO_PATH} - -make create-tmp-env-ci -echo "Syncing repo to docker-host... " -rsync --delete -avr -e "ssh -l ${DOCKER_HOST_USER} ${ADDITIONAL_SSH_OPTS}" \ - ./ ${DOCKER_HOST_IP}:${REPO_PATH} > /dev/null -echo "Done!" - -ssh ${ADDITIONAL_SSH_OPTS} ${DOCKER_HOST_USER}@${DOCKER_HOST_IP} \ - "cd ${REPO_PATH}; TMP_ENV_CI=tmp.env.ci docker compose -f docker-compose.yml up integration-tests" - -container_id=$(docker ps -q -f status=exited -f name="${PWD##*/}-integration-tests-") -test_status=$(docker inspect $container_id --format='{{.State.ExitCode}}') - -ssh ${ADDITIONAL_SSH_OPTS} ${DOCKER_HOST_USER}@${DOCKER_HOST_IP} \ - "cd ${REPO_PATH}; docker compose down --volumes --remove-orphans --timeout 1" - -exit $test_status diff --git a/ci/tasks/unpack-deps.sh b/ci/tasks/unpack-deps.sh deleted file mode 100755 index 8858962600..0000000000 --- a/ci/tasks/unpack-deps.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -set -eu - -echo "Unpacking deps... " - -tar -zxvf bundled-deps/bundled-deps-*.tgz ./node_modules/ ./yarn.lock -C repo/ > /dev/null - -pushd repo > /dev/null - -if [[ "$(git status -s -uno)" != "" ]]; then - echo "Extracting deps has created a diff - deps are not in sync" - git --no-pager diff - exit 1; -fi - -echo "Done!"