diff --git a/.envrc b/.envrc index 13cea7a7a9..2e1551de22 100644 --- a/.envrc +++ b/.envrc @@ -8,12 +8,9 @@ then # for more details fi -local bbl_state_dir=../app-autoscaler-env-bbl-state/bbl-state -if has bbl && [[ -d "$bbl_state_dir" ]] -then - BBL_STATE_DIRECTORY="$(realpath "$bbl_state_dir")" - export BBL_STATE_DIRECTORY - eval "$(bbl print-env)" -fi +local bbl_state_dir=${BBL_STATE_PATH:-'../app-autoscaler-env-bbl-state/bbl-state'} +source './ci/autoscaler/scripts/common.sh' +bosh_login "${bbl_state_dir}" +echo '🚸 Login for bosh and concourse successful! For more execute: `make cf-login`' -export DBURL="postgres://postgres:postgres@localhost/autoscaler" +export DBURL='postgres://postgres:postgres@localhost/autoscaler' diff --git a/.gitignore b/.gitignore index d0eb559ca6..a313dba25a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,14 @@ +# # Edit: Please use global git-ignore for this, see official hints in the description of gitignore +# # on . +# +# # macOS system file that stores folder metadata (safe to ignore) +# .DS_Store + + +# ================================================================================ +# 🤖 Generated files +# ================================================================================ + config/dev.yml config/private.yml releases/*.tgz @@ -66,16 +77,11 @@ keys/ .trunk -# ==================== 📦 Devbox ==================== +# ==================== 📦 Devbox, ❄ Nix, direnv ==================== .devbox -# ==================== ❄ Nix ==================== - # Ignore links to build-output: /result /result-* .direnv - -# # macOS system file that stores folder metadata (safe to ignore) -.DS_Store diff --git a/Makefile b/Makefile index 66ab1aa0ea..51bb623ba1 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ export GOWORK = off $(shell mkdir -p target) $(shell mkdir -p build) -.DEFAULT_GOAL := build-all +.DEFAULT_GOAL := build_all .PHONY: check-type check-db_type: @@ -300,8 +300,11 @@ spec-test: bundle exec rspec .PHONY: bosh-release -bosh-release: go-mod-tidy go-mod-vendor scheduler db build/autoscaler-test.tgz -build/autoscaler-test.tgz: +bosh-release: build/autoscaler-test.tgz +# 🚸 In the next line, the order of the dependencies is important. Generated code needs to be +# already there for `go-mod-tidy` to work. See additional comment for that target in +# ./src/autoscaler/Makefile. +build/autoscaler-test.tgz: build_all go-mod-tidy go-mod-vendor @echo " - building bosh release into build/autoscaler-test.tgz" @mkdir -p build @bosh create-release --force --timestamp-version --tarball=build/autoscaler-test.tgz @@ -370,7 +373,7 @@ deploy-autoscaler-bosh: db.java-libs go-mod-vendor scheduler.build echo " - deploying autoscaler" DEBUG="${DEBUG}" ${CI_DIR}/autoscaler/scripts/deploy-autoscaler.sh deploy-cleanup: - ${CI_DIR}/autoscaler/scripts/cleanup-autoscaler.sh; + ${CI_DIR}/autoscaler/scripts/cleanup-autoscaler.sh bosh-release-path := ./target/bosh-releases prometheus-bosh-release-path := ${bosh-release-path}/prometheus @@ -442,8 +445,11 @@ cleanup-autoscaler-deployments: @${CI_DIR}/autoscaler/scripts/cleanup-autoscaler-deployments.sh .PHONY: cf-login -cf-login: ## Login to OSS CF dev environment - @${CI_DIR}/autoscaler/scripts/cf-login.sh +cf-login: + @echo '⚠️ Please note that this login only works for cf and concourse,' \ + 'in spite of performing a login as well on bosh and credhub.' \ + 'The necessary changes to the environment get lost when make exits its process.' + @${CI_DIR}/autoscaler/scripts/os-infrastructure-login.sh .PHONY: setup-performance setup-performance: build-test-app @@ -484,6 +490,7 @@ alerts-silence: ${CI_DIR}/autoscaler/scripts/silence_prometheus_alert.sh BOSHJobEphemeralDiskPredictWillFill ;\ ${CI_DIR}/autoscaler/scripts/silence_prometheus_alert.sh BOSHJobUnhealthy ; + .PHONY: docker-login docker docker-image docker-login: target/docker-login target/docker-login: @@ -493,7 +500,6 @@ docker-image: docker-login docker build -t ghcr.io/cloudfoundry/app-autoscaler-release-tools:latest ci/dockerfiles/autoscaler-tools docker push ghcr.io/cloudfoundry/app-autoscaler-release-tools:latest - validate-openapi-specs: $(wildcard ./api/*.openapi.yaml) for file in $^ ; do \ redocly lint --extends=minimal --format=$(if $(GITHUB_ACTIONS),github-actions,codeframe) "$${file}" ; \ diff --git a/ci/.gitignore b/ci/.gitignore new file mode 100644 index 0000000000..5104f2fce6 --- /dev/null +++ b/ci/.gitignore @@ -0,0 +1,3 @@ +# ================================================================================ +# 🤖 Generated files +# ================================================================================ diff --git a/ci/Makefile b/ci/Makefile index a524f9211d..d41da514f3 100644 --- a/ci/Makefile +++ b/ci/Makefile @@ -1,3 +1,30 @@ +.ONESHELL: +SHELL := /bin/bash +.SHELLFLAGS := -eu -o pipefail -c + +repository-root := $(shell realpath --relative-to $$(pwd) $$(git rev-parse --show-toplevel)) + +# All files that together define the development-environment: +development-environment-definition := \ + $(wildcard ${repository-root}/nix/**/*) \ + ${repository-root}/devbox.json \ + ${repository-root}/devbox.lock + +# 🚸 Overwrite the following parameters to work with a different repository on a different registry: +OCI_REGISTRY ?= ghcr.io +OCI_REPOSITORY ?= cloudfoundry/app-autoscaler-release-tools +OCI_TAG ?= main + +.PHONY: docker-login +docker-login: + @logged_in=$$(jq '.auths | has("${OCI_REGISTRY}")' ~/.docker/config.json) + readonly logged_in + if [[ "$${logged_in}" != 'true' ]] + then + docker login '${OCI_REGISTRY}' + else + echo 'Already logged in into ${OCI_REGISTRY}, skipping login.' + fi .PHONY: set-autoscaler-pipeline set-autoscaler-pipeline: @@ -15,10 +42,6 @@ unpause-pipeline: delete-pipeline: @./scripts/delete-pipeline.sh -.PHONY: set-target -set-target: - @fly --target app-autoscaler-release login --team-name app-autoscaler --concourse-url https://concourse.app-runtime-interfaces.ci.cloudfoundry.org - .PHONY: lint lint: @shellcheck --external-sources --shell='bash' **/scripts/*.sh diff --git a/ci/autoscaler/pipeline.yml b/ci/autoscaler/pipeline.yml index 4e51db285c..069735ab17 100644 --- a/ci/autoscaler/pipeline.yml +++ b/ci/autoscaler/pipeline.yml @@ -1,5 +1,20 @@ --- anchors: + make-prerelease-task: &make-prerelease-task + task: "make-prerelease" + image: "app-autoscaler-tools" + file: "ci/ci/autoscaler/tasks/make/make.yaml" + params: + TARGETS: "build_all" + timeout: "25m" + + deploy-autoscaler-task: &deploy-autoscaler-task + task: "deploy-autoscaler" + image: "app-autoscaler-tools" + file: "ci/ci/autoscaler/tasks/make/make.yaml" + params: + TARGETS: "deploy-autoscaler" + app-autoscaler-ops-files-log-cache-metron: &app-autoscaler-ops-files-log-cache-metron OPS_FILES: | operations/add-releases.yml @@ -86,6 +101,12 @@ resource_types: repository: frodenas/gcs-resource resources: +- name: "app-autoscaler-tools" + type: "registry-image" + source: + repository: "ghcr.io/cloudfoundry/app-autoscaler-release-tools" + tag: "main" + - name: every-night type: time source: @@ -204,10 +225,13 @@ jobs: serial: true plan: - in_parallel: + - get: "app-autoscaler-tools" + trigger: true - get: app-autoscaler-release trigger: true - get: ci - task: run-unit-tests + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-unit-tests.yml attempts: 3 timeout: 45m @@ -219,10 +243,13 @@ jobs: serial_groups: [integration] plan: - in_parallel: + - get: "app-autoscaler-tools" + trigger: true - get: app-autoscaler-release trigger: true - get: ci - task: run-integration-tests + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-integration-tests.yml timeout: 45m @@ -232,47 +259,49 @@ jobs: serial: true on_success: task: cleanup + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/cleanup-autoscaler.yml params: &acceptance-log-cache-metron-params DEPLOYMENT_NAME: ((acceptance_deployment_name_logcache_metron)) plan: - in_parallel: + - get: "app-autoscaler-tools" + trigger: true - get: bbl-state - get: app-autoscaler-release passed: [unit-tests, integration-tests] trigger: true - get: ci - - task: make-prerelease - file: ci/ci/autoscaler/tasks/make/make.yaml - params: - # ⚠️ Here it is used that make officially guarantees to reach the goals in the provided order. - TARGETS: generate-fakes generate-openapi-generated-clients-and-servers go-mod-tidy go-mod-vendor db scheduler - timeout: 15m - - task: deploy-autoscaler - file: ci/ci/autoscaler/tasks/deploy-autoscaler.yml + - *make-prerelease-task + - <<: *deploy-autoscaler-task params: + TARGETS: "deploy-autoscaler" <<: *acceptance-log-cache-metron-params <<: *app-autoscaler-ops-files-log-cache-metron - timeout: 30m + timeout: "30m" - task: register-broker + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/register-broker.yml params: <<: *acceptance-log-cache-metron-params timeout: 5m - in_parallel: - task: autoscaler-acceptance-api + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *acceptance-log-cache-metron-params SUITES: api timeout: 15m - task: autoscaler-acceptance-app + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *acceptance-log-cache-metron-params SUITES: app timeout: 45m - task: autoscaler-acceptance-broker + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *acceptance-log-cache-metron-params @@ -285,47 +314,49 @@ jobs: serial: true on_success: task: cleanup + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/cleanup-autoscaler.yml params: &acceptance-log-cache-syslog-params DEPLOYMENT_NAME: ((acceptance_deployment_name_logcache_syslog)) plan: - in_parallel: + - get: "app-autoscaler-tools" + trigger: true - get: bbl-state - get: app-autoscaler-release passed: [unit-tests, integration-tests] trigger: true - get: ci - - task: make-prerelease - file: ci/ci/autoscaler/tasks/make/make.yaml - params: - # ⚠️ Here it is used that make officially guarantees to reach the goals in the provided order. - TARGETS: generate-fakes generate-openapi-generated-clients-and-servers go-mod-tidy go-mod-vendor db scheduler - timeout: 15m - - task: deploy-autoscaler - file: ci/ci/autoscaler/tasks/deploy-autoscaler.yml + - *make-prerelease-task + - <<: *deploy-autoscaler-task params: + TARGETS: "deploy-autoscaler" <<: *acceptance-log-cache-syslog-params <<: *app-autoscaler-ops-files-log-cache-syslog timeout: 30m - task: register-broker + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/register-broker.yml params: <<: *acceptance-log-cache-syslog-params timeout: 5m - in_parallel: - task: autoscaler-acceptance-api + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *acceptance-log-cache-syslog-params SUITES: api timeout: 15m - task: autoscaler-acceptance-app + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *acceptance-log-cache-syslog-params SUITES: app timeout: 45m - task: autoscaler-acceptance-broker + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *acceptance-log-cache-syslog-params @@ -338,52 +369,55 @@ jobs: serial: true on_success: task: cleanup + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/cleanup-autoscaler.yml params: &acceptance-log-cache-syslog-cf-params DEPLOYMENT_NAME: ((acceptance_deployment_name_logcache_syslog_cf)) PR_NUMBER: ((pr_number)) plan: - in_parallel: + - get: "app-autoscaler-tools" + trigger: true - get: bbl-state - get: app-autoscaler-release passed: [unit-tests, integration-tests] trigger: true - get: ci - - task: make-prerelease - file: ci/ci/autoscaler/tasks/make/make.yaml - params: - # ⚠️ Here it is used that make officially guarantees to reach the goals in the provided order. - TARGETS: generate-fakes generate-openapi-generated-clients-and-servers go-mod-tidy go-mod-vendor db scheduler - timeout: 15m - - task: deploy-autoscaler - file: ci/ci/autoscaler/tasks/deploy-autoscaler.yml + - *make-prerelease-task + - <<: *deploy-autoscaler-task params: + TARGETS: "deploy-autoscaler" <<: *acceptance-log-cache-syslog-cf-params <<: *app-autoscaler-ops-files-log-cache-syslog-cf - task: deploy-apps + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/deploy-apps.yml params: <<: *acceptance-log-cache-syslog-cf-params timeout: 30m - task: register-broker + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/register-broker.yml params: <<: *acceptance-log-cache-syslog-cf-params timeout: 5m - in_parallel: - task: autoscaler-acceptance-api + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *acceptance-log-cache-syslog-cf-params SUITES: api timeout: 15m - task: autoscaler-acceptance-app + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *acceptance-log-cache-syslog-cf-params SUITES: app timeout: 45m - task: autoscaler-acceptance-broker + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *acceptance-log-cache-syslog-cf-params @@ -395,6 +429,7 @@ jobs: build_logs_to_retain: 100 on_failure: task: cleanup + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/cleanup-autoscaler.yml params: &performance-env DEPLOYMENT_NAME: "autoscaler-performance" @@ -403,34 +438,34 @@ jobs: SERIAL: "false" plan: - in_parallel: + - get: "app-autoscaler-tools" + trigger: true - get: ci - get: bbl-state - get: app-autoscaler-release passed: [unit-tests, integration-tests] trigger: true - - task: make-prerelease - file: ci/ci/autoscaler/tasks/make/make.yaml - params: - # ⚠️ Here it is used that make officially guarantees to reach the goals in the provided order. - TARGETS: generate-fakes generate-openapi-generated-clients-and-servers go-mod-tidy go-mod-vendor db scheduler - timeout: 15m - - task: deploy-autoscaler - file: ci/ci/autoscaler/tasks/deploy-autoscaler.yml + - *make-prerelease-task + - <<: *deploy-autoscaler-task params: + TARGETS: "deploy-autoscaler" <<: *performance-env <<: *app-autoscaler-ops-files-log-cache-syslog timeout: 30m - task: register-broker + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/register-broker.yml params: <<: *performance-env timeout: 5m - task: setup-performance + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/make/make.yaml params: TARGETS: setup-performance timeout: 15m - task: run-performance + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/make/make.yaml params: TARGETS: run-performance @@ -440,12 +475,15 @@ jobs: public: true build_logs_to_retain: 100 on_success: - task: cleanup - file: ci/ci/autoscaler/tasks/cleanup-autoscaler.yml - params: &upgrade-test-params - DEPLOYMENT_NAME: "upgrade-test" + task: cleanup + image: "app-autoscaler-tools" + file: ci/ci/autoscaler/tasks/cleanup-autoscaler.yml + params: &upgrade-test-params + DEPLOYMENT_NAME: "upgrade-test" plan: - in_parallel: + - get: "app-autoscaler-tools" + trigger: true - get: bbl-state - get: ci - get: app-autoscaler-release @@ -456,17 +494,20 @@ jobs: trigger: true - get: previous-stable-release - task: deploy-previous-stable-release + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/deploy-previous-autoscaler.yml params: <<: *upgrade-test-params <<: *app-autoscaler-ops-files-upgrade timeout: 30m - task: register-broker + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/register-broker.yml params: <<: *upgrade-test-params timeout: 5m - task: autoscaler-pre-upgrade + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *upgrade-test-params @@ -474,19 +515,15 @@ jobs: pre_upgrade NODES: 1 timeout: 30m - - task: make-prerelease - file: ci/ci/autoscaler/tasks/make/make.yaml - params: - # ⚠️ Here it is used that make officially guarantees to reach the goals in the provided order. - TARGETS: generate-fakes generate-openapi-generated-clients-and-servers go-mod-tidy go-mod-vendor db scheduler - timeout: 15m - - task: deploy-autoscaler - file: ci/ci/autoscaler/tasks/deploy-autoscaler.yml + - *make-prerelease-task + - <<: *deploy-autoscaler-task params: + TARGETS: "deploy-autoscaler" <<: *upgrade-test-params <<: *app-autoscaler-ops-files-upgrade timeout: 30m - task: autoscaler-post-upgrade + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/run-acceptance-tests.yml params: <<: *upgrade-test-params @@ -500,6 +537,7 @@ jobs: build_logs_to_retain: 100 plan: - in_parallel: + - get: "app-autoscaler-tools" - get: release-bucket - get: acceptance-tests-bucket - get: gh-release @@ -507,12 +545,9 @@ jobs: - get: app-autoscaler-release passed: [upgrade-test] - get: ci - - task: make-prerelease - file: ci/ci/autoscaler/tasks/make/make.yaml - params: - # ⚠️ Here it is used that make officially guarantees to reach the goals in the provided order. - TARGETS: generate-fakes generate-openapi-generated-clients-and-servers go-mod-tidy go-mod-vendor db scheduler + - *make-prerelease-task - task: release-autoscaler + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/release-autoscaler.yml params: UPLOADER_KEY: ((autoscaler_blobstore_uploader_key)) @@ -547,38 +582,45 @@ jobs: build_logs_to_retain: 100 plan: - in_parallel: + - get: "app-autoscaler-tools" - get: bbl-state - get: ci - get: every-night trigger: true - task: cleanup-autoscaler-deployments + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/cleanup-autoscaler-deployments.yml - name: fetch-latest-stemcell public: true build_logs_to_retain: 100 plan: - - in_parallel: - - get: bbl-state - - get: ci - - get: every-night - passed: [ cleanup-autoscaler-deployments ] - trigger: true - - get: gcp-jammy-stemcell - - task: fetch-latest-stemcell - file: ci/ci/autoscaler/tasks/fetch-latest-stemcell.yml + - in_parallel: + - get: "app-autoscaler-tools" + - get: bbl-state + - get: ci + - get: every-night + passed: [ cleanup-autoscaler-deployments ] + trigger: true + - get: gcp-jammy-stemcell + - task: fetch-latest-stemcell + image: "app-autoscaler-tools" + file: ci/ci/autoscaler/tasks/fetch-latest-stemcell.yml - name: draft public: true build_logs_to_retain: 100 plan: - in_parallel: + - get: "app-autoscaler-tools" + trigger: true - get: ci - get: gh-release - get: app-autoscaler-release passed: [upgrade-test] trigger: true - task: dummy-release-autoscaler + image: "app-autoscaler-tools" file: ci/ci/autoscaler/tasks/release-autoscaler.yml params: UPLOADER_KEY: ((autoscaler_blobstore_uploader_key)) diff --git a/ci/autoscaler/scripts/acceptance-tests-config.sh b/ci/autoscaler/scripts/acceptance-tests-config.sh index 6b07caf9b1..22dd059da0 100755 --- a/ci/autoscaler/scripts/acceptance-tests-config.sh +++ b/ci/autoscaler/scripts/acceptance-tests-config.sh @@ -4,6 +4,7 @@ set -eu -o pipefail script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" source "${script_dir}/vars.source.sh" +source "${script_dir}/common.sh" cf_admin_password="${CF_ADMIN_PASSWORD:-}" skip_ssl_validation="${SKIP_SSL_VALIDATION:-true}" @@ -19,10 +20,7 @@ cpu_upper_threshold=${CPU_UPPER_THRESHOLD:-100} if [[ -z "${cf_admin_password}" ]] then - pushd "${bbl_state_path}" - eval "$(bbl print-env)" - popd - + bosh_login "${BBL_STATE_PATH}" cf_admin_password="$(credhub get --quiet --name='/bosh-autoscaler/cf/cf_admin_password')" fi diff --git a/ci/autoscaler/scripts/cf-login.sh b/ci/autoscaler/scripts/cf-login.sh deleted file mode 100755 index f1b5a73e54..0000000000 --- a/ci/autoscaler/scripts/cf-login.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC2086 -set -euo pipefail -script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source "${script_dir}/common.sh" - -bosh_login -cf_login -cf_target "${AUTOSCALER_ORG}" "${AUTOSCALER_SPACE}" - - -cf autoscaling-api "https://autoscaler-${PR_NUMBER}.${SYSTEM_DOMAIN}" diff --git a/ci/autoscaler/scripts/cleanup-autoscaler-deployments.sh b/ci/autoscaler/scripts/cleanup-autoscaler-deployments.sh index dff4b5e979..a88e5a20f6 100755 --- a/ci/autoscaler/scripts/cleanup-autoscaler-deployments.sh +++ b/ci/autoscaler/scripts/cleanup-autoscaler-deployments.sh @@ -2,28 +2,30 @@ set -euo pipefail script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +source "${script_dir}/vars.source.sh" source "${script_dir}/common.sh" function get_autoscaler_deployments(){ - bosh deployments --json | jq -r '.Tables[0].Rows[] | select(.release_s | contains("app-autoscaler/")) | .name' + bosh deployments --json | jq -r '.Tables[0].Rows[] | select(.release_s | contains("app-autoscaler/")) | .name' } function main(){ - bosh_login - cf_login - step "Deployments to cleanup: $(get_autoscaler_deployments)" - while IFS='' read -r deployment; do - unset_vars - export DEPLOYMENT_NAME="${deployment}" - source "${script_dir}/vars.source.sh" + bosh_login "${BBL_STATE_PATH}" + cf_login + step "Deployments to cleanup: $(get_autoscaler_deployments)" + while IFS='' read -r deployment + do + unset_vars + export DEPLOYMENT_NAME="${deployment}" + source "${script_dir}/vars.source.sh" - cleanup_acceptance_run - cleanup_service_broker - cleanup_bosh_deployment - cleanup_credhub - done < <(get_autoscaler_deployments) + cleanup_acceptance_run + cleanup_service_broker + cleanup_bosh_deployment + cleanup_credhub + done < <(get_autoscaler_deployments) - cleanup_bosh + cleanup_bosh } [ "${BASH_SOURCE[0]}" == "${0}" ] && main "$@" diff --git a/ci/autoscaler/scripts/cleanup-autoscaler.sh b/ci/autoscaler/scripts/cleanup-autoscaler.sh index ddc15a98a4..eb6b671bb4 100755 --- a/ci/autoscaler/scripts/cleanup-autoscaler.sh +++ b/ci/autoscaler/scripts/cleanup-autoscaler.sh @@ -3,19 +3,20 @@ set -eu -o pipefail script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) +source "${script_dir}/vars.source.sh" source "${script_dir}/common.sh" function main() { - step "cleaning up deployment ${DEPLOYMENT_NAME}" - bosh_login - cf_login + step "cleaning up deployment ${DEPLOYMENT_NAME}" + bosh_login "${BBL_STATE_PATH}" + cf_login - cleanup_apps - cleanup_acceptance_run - cleanup_service_broker - cleanup_bosh_deployment - delete_releases - cleanup_credhub + cleanup_apps + cleanup_acceptance_run + cleanup_service_broker + cleanup_bosh_deployment + delete_releases + cleanup_credhub } [ "${BASH_SOURCE[0]}" == "${0}" ] && main "$@" diff --git a/ci/autoscaler/scripts/common.sh b/ci/autoscaler/scripts/common.sh index cba16a635a..14d0c796d9 100644 --- a/ci/autoscaler/scripts/common.sh +++ b/ci/autoscaler/scripts/common.sh @@ -1,150 +1,169 @@ -#!/bin/bash -script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -source "${script_dir}/vars.source.sh" -set -euo pipefail +#! /usr/bin/env bash -function retry(){ - max_retries=$1 - shift - retries=0 - command="$*" - until [ "${retries}" -eq "${max_retries}" ] || $command; do - ((retries=retries+1)) - echo " - retrying command '${command}' attempt: ${retries}" - done - [ "${retries}" -lt "${max_retries}" ] || { echo "ERROR: Command '$*' failed after ${max_retries} attempts"; return 1; } +# This file is intended to be loaded via the `source`-command. + +function step(){ + echo "# $1" } +function retry(){ + max_retries=$1 + shift + retries=0 + command="$*" + until [ "${retries}" -eq "${max_retries}" ] || $command; do + ((retries=retries+1)) + echo " - retrying command '${command}' attempt: ${retries}" + done + [ "${retries}" -lt "${max_retries}" ] || { echo "ERROR: Command '$*' failed after ${max_retries} attempts"; return 1; } +} -function bosh_login(){ - step "bosh login" - if [[ ! -d ${bbl_state_path} ]]; then - echo "FAILED: Did not find bbl-state folder at ${bbl_state_path}" - echo "Make sure you have checked out the app-autoscaler-env-bbl-state repository next to the app-autoscaler-release repository to run this target or indicate its location via BBL_STATE_PATH"; - exit 1; - fi +function concourse_login() { + local -r concourse_aas_release_target="${1}" + if ! fly targets | rg --only-matching --regexp="^${concourse_aas_release_target}[[:space:]]" > /dev/null + then + echo "There is no concourse-target for precicely \"${concourse_aas_release_target}\"." \ + 'Login required!' + fly --target="${concourse_aas_release_target}" login \ + --team-name='app-autoscaler'\ + --concourse-url='https://concourse.app-runtime-interfaces.ci.cloudfoundry.org' + fi +} - pushd "${bbl_state_path}" > /dev/null - eval "$(bbl print-env)" - popd > /dev/null +function bosh_login() { + step "bosh login" + local -r bbl_state_path="${1}" + if [[ ! -d "${bbl_state_path}" ]] + then + echo "⛔ FAILED: Did not find bbl-state folder at ${bbl_state_path}" + echo 'Make sure you have checked out the app-autoscaler-env-bbl-state repository next to the app-autoscaler-release repository to run this target or indicate its location via BBL_STATE_PATH' + exit 1; + fi + + pushd "${bbl_state_path}" > /dev/null + eval "$(bbl print-env)" + popd > /dev/null } function cf_login(){ - step "login to cf" - cf api "https://api.${system_domain}" --skip-ssl-validation - cf_admin_password="$(credhub get --quiet --name='/bosh-autoscaler/cf/cf_admin_password')" - cf auth admin "$cf_admin_password" + step 'login to cf' + cf api "https://api.${system_domain}" --skip-ssl-validation + cf_admin_password="$(credhub get --quiet --name='/bosh-autoscaler/cf/cf_admin_password')" + cf auth admin "$cf_admin_password" } function cleanup_acceptance_run(){ - step "cleaning up from acceptance tests" - pushd "${ci_dir}/../src/acceptance" > /dev/null - retry 5 ./cleanup.sh - popd > /dev/null + step "cleaning up from acceptance tests" + pushd "${ci_dir}/../src/acceptance" > /dev/null + retry 5 ./cleanup.sh + popd > /dev/null } function cleanup_service_broker(){ - step "deleting service broker for deployment '${deployment_name}'" - SERVICE_BROKER_EXISTS=$(cf service-brokers | grep -c "${service_broker_name}.${system_domain}" || true) - if [[ $SERVICE_BROKER_EXISTS == 1 ]]; then - echo "- Service Broker exists, deleting broker '${deployment_name}'" - retry 3 cf delete-service-broker "${deployment_name}" -f - fi + step "deleting service broker for deployment '${deployment_name}'" + SERVICE_BROKER_EXISTS=$(cf service-brokers | grep -c "${service_broker_name}.${system_domain}" || true) + if [[ $SERVICE_BROKER_EXISTS == 1 ]]; then + echo "- Service Broker exists, deleting broker '${deployment_name}'" + retry 3 cf delete-service-broker "${deployment_name}" -f + fi } function cleanup_bosh_deployment(){ - step "deleting bosh deployment '${deployment_name}'" - retry 3 bosh delete-deployment -d "${deployment_name}" -n + step "deleting bosh deployment '${deployment_name}'" + retry 3 bosh delete-deployment -d "${deployment_name}" -n } function delete_releases(){ - step "deleting releases" - if [ -n "${deployment_name}" ] - then - for release in $(bosh releases | grep -E "${deployment_name}\s+" | awk '{print $2}') - do - echo "- Deleting bosh release '${release}'" - bosh delete-release -n "app-autoscaler/${release}" & - done - wait - fi + step "deleting releases" + if [ -n "${deployment_name}" ] + then + for release in $(bosh releases | grep -E "${deployment_name}\s+" | awk '{print $2}') + do + echo "- Deleting bosh release '${release}'" + bosh delete-release -n "app-autoscaler/${release}" & + done + wait + fi } function cleanup_bosh(){ - step "cleaning up bosh" - retry 3 bosh clean-up --all -n + step "cleaning up bosh" + retry 3 bosh clean-up --all -n } function cleanup_credhub(){ - step "cleaning up credhub: '/bosh-autoscaler/${deployment_name}/*'" - retry 3 credhub delete --path="/bosh-autoscaler/${deployment_name}" + step "cleaning up credhub: '/bosh-autoscaler/${deployment_name}/*'" + retry 3 credhub delete --path="/bosh-autoscaler/${deployment_name}" } function cleanup_apps(){ - step "cleaning up apps" - local mtar_app - local space_guid - - cf_target "${autoscaler_org}" "${autoscaler_space}" - - space_guid="$(cf space --guid "${autoscaler_space}")" - mtar_app="$(curl --header "Authorization: $(cf oauth-token)" "deploy-service.${system_domain}/api/v2/spaces/${space_guid}/mtas" | jq ". | .[] | .metadata | .id" -r)" - - if [ -n "${mtar_app}" ]; then - set +e - cf undeploy "${mtar_app}" -f --delete-service-brokers --delete-service-keys --delete-services --do-not-fail-on-missing-permissions - set -e - else - echo "No app to undeploy" - fi - - if cf spaces | grep --quiet --regexp="^${AUTOSCALER_SPACE}$"; then - cf delete-space -f "${AUTOSCALER_SPACE}" - fi - - if cf orgs | grep --quiet --regexp="^${AUTOSCALER_ORG}$"; then - cf delete-org -f "${AUTOSCALER_ORG}" - fi + step "cleaning up apps" + local mtar_app + local space_guid + + cf_target "${autoscaler_org}" "${autoscaler_space}" + + space_guid="$(cf space --guid "${autoscaler_space}")" + mtar_app="$(curl --header "Authorization: $(cf oauth-token)" "deploy-service.${system_domain}/api/v2/spaces/${space_guid}/mtas" | jq ". | .[] | .metadata | .id" -r)" + + if [ -n "${mtar_app}" ]; then + set +e + cf undeploy "${mtar_app}" -f --delete-service-brokers --delete-service-keys --delete-services --do-not-fail-on-missing-permissions + set -e + else + echo "No app to undeploy" + fi + + if cf spaces | grep --quiet --regexp="^${AUTOSCALER_SPACE}$"; then + cf delete-space -f "${AUTOSCALER_SPACE}" + fi + + if cf orgs | grep --quiet --regexp="^${AUTOSCALER_ORG}$" + then + cf delete-org -f "${AUTOSCALER_ORG}" + fi } function unset_vars() { - unset PR_NUMBER - unset DEPLOYMENT_NAME - unset SYSTEM_DOMAIN - unset BBL_STATE_PATH - unset AUTOSCALER_DIR - unset CI_DIR - unset SERVICE_NAME - unset SERVICE_BROKER_NAME - unset NAME_PREFIX - unset GINKGO_OPTS + unset PR_NUMBER + unset DEPLOYMENT_NAME + unset SYSTEM_DOMAIN + unset BBL_STATE_PATH + unset AUTOSCALER_DIR + unset CI_DIR + unset SERVICE_NAME + unset SERVICE_BROKER_NAME + unset NAME_PREFIX + unset GINKGO_OPTS } function find_or_create_org(){ - step "finding or creating org" - local org_name="$1" - if ! cf orgs | grep --quiet --regexp="^${org_name}$"; then - cf create-org "${org_name}" - fi - echo "targeting org ${org_name}" - cf target -o "${org_name}" + step "finding or creating org" + local org_name="$1" + if ! cf orgs | grep --quiet --regexp="^${org_name}$" + then + cf create-org "${org_name}" + fi + echo "targeting org ${org_name}" + cf target -o "${org_name}" } function find_or_create_space(){ - step "finding or creating space" - local space_name="$1" - if ! cf spaces | grep --quiet --regexp="^${space_name}$"; then - cf create-space "${space_name}" - fi - echo "targeting space ${space_name}" - cf target -s "${space_name}" + step "finding or creating space" + local space_name="$1" + if ! cf spaces | grep --quiet --regexp="^${space_name}$" + then + cf create-space "${space_name}" + fi + echo "targeting space ${space_name}" + cf target -s "${space_name}" } function cf_target(){ - local org_name="$1" - local space_name="$2" + local org_name="$1" + local space_name="$2" - find_or_create_org "${org_name}" - find_or_create_space "${space_name}" + find_or_create_org "${org_name}" + find_or_create_space "${space_name}" } diff --git a/ci/autoscaler/scripts/deploy-apps.sh b/ci/autoscaler/scripts/deploy-apps.sh index 2603a4d55f..0572b4b228 100755 --- a/ci/autoscaler/scripts/deploy-apps.sh +++ b/ci/autoscaler/scripts/deploy-apps.sh @@ -1,23 +1,21 @@ #! /usr/bin/env bash # shellcheck disable=SC2086,SC2034,SC2155 -set -euo pipefail +set -eu -o pipefail script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source "${script_dir}/common.sh" source "${script_dir}/vars.source.sh" -pushd "${bbl_state_path}" > /dev/null - eval "$(bbl print-env)" -popd > /dev/null +bosh_login "${BBL_STATE_PATH}" function deploy() { - log "Deploying autoscaler apps for bosh deployment '${deployment_name}' " - pushd "${autoscaler_dir}/src/autoscaler" > /dev/null - make mta-deploy - popd > /dev/null + log "Deploying autoscaler apps for bosh deployment '${deployment_name}' " + pushd "${autoscaler_dir}/src/autoscaler" > /dev/null + make mta-deploy + popd > /dev/null } -bosh_login + cf_login cf_target "${autoscaler_org}" "${autoscaler_space}" deploy diff --git a/ci/autoscaler/scripts/deploy-autoscaler.sh b/ci/autoscaler/scripts/deploy-autoscaler.sh index 07865b8eef..4b1cc79b6d 100755 --- a/ci/autoscaler/scripts/deploy-autoscaler.sh +++ b/ci/autoscaler/scripts/deploy-autoscaler.sh @@ -29,47 +29,45 @@ EOF CURRENT_COMMIT_HASH=$(cd "${autoscaler_dir}"; git log -1 --pretty=format:"%H") bosh_release_version=${RELEASE_VERSION:-${CURRENT_COMMIT_HASH}-${deployment_name}} -pushd "${bbl_state_path}" > /dev/null -eval "$(bbl print-env)" -popd > /dev/null +bosh_login "${BBL_STATE_PATH}" function setup_autoscaler_uaac() { - local uaac_authorities="cloud_controller.read,cloud_controller.admin,uaa.resource,routing.routes.write,routing.routes.read,routing.router_groups.read" - local autoscaler_secret="autoscaler_client_secret" - local uaa_client_secret=$(credhub get -n /bosh-autoscaler/cf/uaa_admin_client_secret --quiet) - - uaac target "https://uaa.${system_domain}" --skip-ssl-validation > /dev/null - uaac token client get admin -s "${uaa_client_secret}" > /dev/null - - if uaac client get autoscaler_client_id >/dev/null; then - step "updating autoscaler uaac client" - uaac client update "autoscaler_client_id" --authorities "$uaac_authorities" > /dev/null - else - step "creating autoscaler uaac client" - uaac client add "autoscaler_client_id" \ - --authorized_grant_types "client_credentials" \ - --authorities "$uaac_authorities" \ - --secret "$autoscaler_secret" > /dev/null - fi + local uaac_authorities="cloud_controller.read,cloud_controller.admin,uaa.resource,routing.routes.write,routing.routes.read,routing.router_groups.read" + local autoscaler_secret="autoscaler_client_secret" + local uaa_client_secret=$(credhub get -n /bosh-autoscaler/cf/uaa_admin_client_secret --quiet) + + uaac target "https://uaa.${system_domain}" --skip-ssl-validation > /dev/null + uaac token client get admin -s "${uaa_client_secret}" > /dev/null + + if uaac client get autoscaler_client_id >/dev/null; then + step "updating autoscaler uaac client" + uaac client update "autoscaler_client_id" --authorities "$uaac_authorities" > /dev/null + else + step "creating autoscaler uaac client" + uaac client add "autoscaler_client_id" \ + --authorized_grant_types "client_credentials" \ + --authorities "$uaac_authorities" \ + --secret "$autoscaler_secret" > /dev/null + fi } function get_postgres_external_port() { - [[ -z "${PR_NUMBER}" ]] && echo "5432" || echo "${PR_NUMBER}" + [[ -z "${PR_NUMBER}" ]] && echo "5432" || echo "${PR_NUMBER}" } function create_manifest() { - local tmp_dir - local perform_as_gh_action="${GITHUB_ACTIONS:-false}" + local tmp_dir + local perform_as_gh_action="${GITHUB_ACTIONS:-false}" - if "${perform_as_gh_action}" != 'false'; then - tmp_dir="${RUNNER_TEMP}" - else - tmp_dir="$(pwd)/dev_releases" - mkdir -p "${tmp_dir}" - fi + if "${perform_as_gh_action}" != 'false'; then + tmp_dir="${RUNNER_TEMP}" + else + tmp_dir="$(pwd)/dev_releases" + mkdir -p "${tmp_dir}" + fi - tmp_manifest_file="$(mktemp "${tmp_dir}/${deployment_name}.bosh-manifest.yaml.XXX")" - credhub interpolate -f "${autoscaler_dir}/ci/autoscaler/scripts/autoscaler-secrets.yml.tpl" > /tmp/autoscaler-secrets.yml + tmp_manifest_file="$(mktemp "${tmp_dir}/${deployment_name}.bosh-manifest.yaml.XXX")" + credhub interpolate -f "${autoscaler_dir}/ci/autoscaler/scripts/autoscaler-secrets.yml.tpl" > /tmp/autoscaler-secrets.yml add_variable "deployment_name" "${deployment_name}" add_variable "system_domain" "${system_domain}" @@ -82,14 +80,14 @@ function create_manifest() { bosh_deploy_vars="" # add deployment name - bosh -n -d "${deployment_name}" interpolate "${deployment_manifest}" ${OPS_FILES_TO_USE} \ - ${bosh_deploy_opts} ${BOSH_DEPLOY_VARS} \ - --vars-file=/tmp/autoscaler-secrets.yml -v skip_ssl_validation=true > "${tmp_manifest_file}" - - if [[ -z "${debug}" || "${debug}" = "false" ]]; then - # shellcheck disable=SC2064 - trap "rm ${tmp_manifest_file}" EXIT - fi + bosh -n -d "${deployment_name}" interpolate "${deployment_manifest}" ${OPS_FILES_TO_USE} \ + ${bosh_deploy_opts} ${BOSH_DEPLOY_VARS} \ + --vars-file=/tmp/autoscaler-secrets.yml -v skip_ssl_validation=true > "${tmp_manifest_file}" + + if [[ -z "${debug}" || "${debug}" = "false" ]]; then + # shellcheck disable=SC2064 + trap "rm ${tmp_manifest_file}" EXIT + fi } add_variable() { @@ -99,62 +97,62 @@ add_variable() { } function check_ops_files() { - step "Using Ops files: '${ops_files}'" - - OPS_FILES_TO_USE="" - for OPS_FILE in ${ops_files}; do - if [[ -f "${OPS_FILE}" ]]; then - OPS_FILES_TO_USE="${OPS_FILES_TO_USE} -o ${OPS_FILE}" - else - echo "ERROR: could not find ops file ${OPS_FILE} in ${PWD}" - exit 1 - fi - done + step "Using Ops files: '${ops_files}'" + + OPS_FILES_TO_USE="" + for OPS_FILE in ${ops_files}; do + if [[ -f "${OPS_FILE}" ]]; then + OPS_FILES_TO_USE="${OPS_FILES_TO_USE} -o ${OPS_FILE}" + else + echo "ERROR: could not find ops file ${OPS_FILE} in ${PWD}" + exit 1 + fi + done } function deploy() { - create_manifest - log "creating Bosh deployment '${deployment_name}' with version '${bosh_release_version}' in system domain '${system_domain}'" - debug "tmp_manifest_file=${tmp_manifest_file}" - step "Using Ops files: '${OPS_FILES_TO_USE}'" - step "Deploy options: '${bosh_deploy_opts}'" - bosh -n -d "${deployment_name}" deploy "${tmp_manifest_file}" - postgres_ip="$(bosh curl "/deployments/${deployment_name}/vms" | jq '. | .[] | select(.job == "postgres") | .ips[0]' -r)" - credhub set -n "/bosh-autoscaler/${deployment_name}/postgres_ip" -t value -v "${postgres_ip}" + create_manifest + log "creating Bosh deployment '${deployment_name}' with version '${bosh_release_version}' in system domain '${system_domain}'" + debug "tmp_manifest_file=${tmp_manifest_file}" + step "Using Ops files: '${OPS_FILES_TO_USE}'" + step "Deploy options: '${bosh_deploy_opts}'" + bosh -n -d "${deployment_name}" deploy "${tmp_manifest_file}" + postgres_ip="$(bosh curl "/deployments/${deployment_name}/vms" | jq '. | .[] | select(.job == "postgres") | .ips[0]' -r)" + credhub set -n "/bosh-autoscaler/${deployment_name}/postgres_ip" -t value -v "${postgres_ip}" } function find_or_upload_stemcell() { - local stemcell_os stemcell_version stemcell_name - stemcell_os=$(yq eval '.stemcells[] | select(.alias == "default").os' "${deployment_manifest}") - stemcell_version=$(yq eval '.stemcells[] | select(.alias == "default").version' "${deployment_manifest}") - stemcell_name="bosh-google-kvm-${stemcell_os}-go_agent" - - if ! bosh stemcells | grep "${stemcell_name}" >/dev/null; then - local URL="https://bosh.io/d/stemcells/${stemcell_name}" - [[ "${stemcell_version}" != "latest" ]] && URL="${URL}?v=${stemcell_version}" - wget "${URL}" -O stemcell.tgz - bosh -n upload-stemcell $bosh_upload_stemcell_opts stemcell.tgz - fi + local stemcell_os stemcell_version stemcell_name + stemcell_os=$(yq eval '.stemcells[] | select(.alias == "default").os' "${deployment_manifest}") + stemcell_version=$(yq eval '.stemcells[] | select(.alias == "default").version' "${deployment_manifest}") + stemcell_name="bosh-google-kvm-${stemcell_os}-go_agent" + + if ! bosh stemcells | grep "${stemcell_name}" >/dev/null; then + local URL="https://bosh.io/d/stemcells/${stemcell_name}" + [[ "${stemcell_version}" != "latest" ]] && URL="${URL}?v=${stemcell_version}" + wget "${URL}" -O stemcell.tgz + bosh -n upload-stemcell $bosh_upload_stemcell_opts stemcell.tgz + fi } function find_or_upload_release() { - if ! bosh releases | grep -E "${bosh_release_version}[*]*\s" > /dev/null; then - local release_desc_file="dev_releases/app-autoscaler/app-autoscaler-${bosh_release_version}.yml" - if [[ ! -f "${release_desc_file}" ]]; then - echo "Creating Release with bosh version ${bosh_release_version}" - bosh create-release --force --version="${bosh_release_version}" - else - # shellcheck disable=SC2006 - echo -e "Release with bosh-version ${bosh_release_version} already locally present. Reusing it."\ - "\n\tIf this does not work, please consider executing `bosh reset-release`." - fi - - echo "Uploading Release" - bosh upload-release ${bosh_upload_release_opts} "${release_desc_file}" - else - echo "the app-autoscaler release is already uploaded with the commit ${bosh_release_version}" - echo "Attempting redeploy..." - fi + if ! bosh releases | grep -E "${bosh_release_version}[*]*\s" > /dev/null; then + local release_desc_file="dev_releases/app-autoscaler/app-autoscaler-${bosh_release_version}.yml" + if [[ ! -f "${release_desc_file}" ]]; then + echo "Creating Release with bosh version ${bosh_release_version}" + bosh create-release --force --version="${bosh_release_version}" + else + # shellcheck disable=SC2006 + echo -e "Release with bosh-version ${bosh_release_version} already locally present. Reusing it."\ + "\n\tIf this does not work, please consider executing `bosh reset-release`." + fi + + echo "Uploading Release" + bosh upload-release ${bosh_upload_release_opts} "${release_desc_file}" + else + echo "the app-autoscaler release is already uploaded with the commit ${bosh_release_version}" + echo "Attempting redeploy..." + fi } function pre_deploy() { @@ -189,4 +187,3 @@ find_or_upload_stemcell find_or_upload_release deploy popd > /dev/null - diff --git a/ci/autoscaler/scripts/deploy-previous-autoscaler.sh b/ci/autoscaler/scripts/deploy-previous-autoscaler.sh index 4e0d3d568f..c33d584fe5 100755 --- a/ci/autoscaler/scripts/deploy-previous-autoscaler.sh +++ b/ci/autoscaler/scripts/deploy-previous-autoscaler.sh @@ -2,10 +2,9 @@ set -euo pipefail script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source "${script_dir}/vars.source.sh" +source "${script_dir}/common.sh" -pushd "${bbl_state_path}" > /dev/null - eval "$(bbl print-env)" -popd > /dev/null +bosh_login "${BBL_STATE_PATH}" RELEASE_URL="$(cat previous-stable-release/url)" RELEASE_SHA="$(cat previous-stable-release/sha1)" @@ -14,4 +13,4 @@ RELEASE_VERSION="$(cat previous-stable-release/version)" echo "Downloading release '$RELEASE_VERSION'/${RELEASE_SHA} from '$RELEASE_URL'" bosh upload-release --sha1 "${RELEASE_SHA}" "${RELEASE_URL}" export RELEASE_VERSION -"${script_dir}/deploy-autoscaler.sh" \ No newline at end of file +"${script_dir}/deploy-autoscaler.sh" diff --git a/ci/autoscaler/scripts/fetch-latest-stemcell.sh b/ci/autoscaler/scripts/fetch-latest-stemcell.sh index acd0602c6c..48d872cbf1 100755 --- a/ci/autoscaler/scripts/fetch-latest-stemcell.sh +++ b/ci/autoscaler/scripts/fetch-latest-stemcell.sh @@ -1,13 +1,13 @@ -#!/bin/bash +#! /usr/bin/env bash -set -euo pipefail +set -eu -o pipefail script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +source "${script_dir}/vars.source.sh" source "${script_dir}/common.sh" - function main(){ - bosh_login - bosh upload-stemcell --sha1 "sha256:$(cat gcp-jammy-stemcell/sha256)" "$(cat gcp-jammy-stemcell/url)" + bosh_login "${BBL_STATE_PATH}" + bosh upload-stemcell --sha1 "sha256:$(cat gcp-jammy-stemcell/sha256)" "$(cat gcp-jammy-stemcell/url)" } [ "${BASH_SOURCE[0]}" == "${0}" ] && main "$@" diff --git a/ci/autoscaler/scripts/os-infrastructure-login.sh b/ci/autoscaler/scripts/os-infrastructure-login.sh new file mode 100755 index 0000000000..ca5f815e51 --- /dev/null +++ b/ci/autoscaler/scripts/os-infrastructure-login.sh @@ -0,0 +1,14 @@ +#! /usr/bin/env bash +# shellcheck disable=SC2086 +set -eu -o pipefail +script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +source "${script_dir}/vars.source.sh" +source "${script_dir}/common.sh" + +bosh_login "${BBL_STATE_PATH}" +concourse_login "${CONCOURSE_AAS_RELEASE_TARGET}" +cf_login +cf_target "${AUTOSCALER_ORG}" "${AUTOSCALER_SPACE}" + + +cf autoscaling-api "https://autoscaler-${PR_NUMBER}.${SYSTEM_DOMAIN}" diff --git a/ci/autoscaler/scripts/register-broker.sh b/ci/autoscaler/scripts/register-broker.sh index 363c08c01f..e8bf9d8a97 100755 --- a/ci/autoscaler/scripts/register-broker.sh +++ b/ci/autoscaler/scripts/register-broker.sh @@ -1,33 +1,33 @@ -#!/bin/bash +#! /usr/bin/env bash -set -euo pipefail +set -eu -o pipefail script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source "${script_dir}/vars.source.sh" +source "${script_dir}/common.sh" -pushd "${bbl_state_path}" - eval "$(bbl print-env)" -popd - -cf api "https://api.${system_domain}" --skip-ssl-validation - -cf_admin_password="$(credhub get -n /bosh-autoscaler/cf/cf_admin_password -q)" -cf auth admin "${cf_admin_password}" +bosh_login "${BBL_STATE_PATH}" +cf_login set +e -existing_service_broker="$(cf curl v3/service_brokers | jq -r --arg service_broker_name "${deployment_name}" -r '.resources[] | select(.name == $service_broker_name) | .name')" +existing_service_broker="$(cf curl v3/service_brokers | jq --raw-output \ + --arg service_broker_name "${deployment_name}" \ + '.resources[] | select(.name == $service_broker_name) | .name')" set -e -if [[ -n "$existing_service_broker" ]]; then - echo "Service Broker ${existing_service_broker} already exists" - echo " - cleaning up pr" - pushd "${autoscaler_dir}/src/acceptance" > /dev/null && ./cleanup.sh && popd > /dev/null - echo " - deleting broker" - cf delete-service-broker -f "${existing_service_broker}" +if [[ -n "${existing_service_broker}" ]] +then + echo "Service Broker ${existing_service_broker} already exists" + echo " - cleaning up pr" + pushd "${autoscaler_dir}/src/acceptance" > /dev/null + ./cleanup.sh + popd > /dev/null + echo ' - deleting broker' + cf delete-service-broker -f "${existing_service_broker}" fi echo "Creating service broker ${deployment_name} at 'https://${service_broker_name}.${system_domain}'" -autoscaler_service_broker_password=$(credhub get -n "/bosh-autoscaler/${deployment_name}/service_broker_password" -q) +autoscaler_service_broker_password=$(credhub get --quiet --name="/bosh-autoscaler/${deployment_name}/service_broker_password") cf create-service-broker "${deployment_name}" autoscaler-broker-user "$autoscaler_service_broker_password" "https://${service_broker_name}.${system_domain}" cf logout diff --git a/ci/autoscaler/scripts/run-acceptance-tests.sh b/ci/autoscaler/scripts/run-acceptance-tests.sh index 97edf99eef..f086eb462f 100755 --- a/ci/autoscaler/scripts/run-acceptance-tests.sh +++ b/ci/autoscaler/scripts/run-acceptance-tests.sh @@ -1,17 +1,18 @@ -#!/usr/bin/env bash +#! /usr/bin/env bash set -eu -o pipefail script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" source "${script_dir}/vars.source.sh" +source "${script_dir}/common.sh" skip_teardown="${SKIP_TEARDOWN:-false}" suites="${SUITES:-"api app broker"}" ginkgo_opts="${GINKGO_OPTS:-}" nodes="${NODES:-3}" -if [[ ! -d "${bbl_state_path}" ]] +if [[ ! -d "${BBL_STATE_PATH}" ]] then - echo "FAILED: Did not find bbl-state folder at ${bbl_state_path}" + echo "FAILED: Did not find bbl-state folder at ${BBL_STATE_PATH}" echo "Make sure you have checked out the app-autoscaler-env-bbl-state repository next to the app-autoscaler-release repository to run this target or indicate its location via BBL_STATE_PATH"; exit 1; fi @@ -23,7 +24,8 @@ then fi suites_to_run="" -for suite in $suites; do +for suite in $suites +do log "checking suite ${suite}" if [[ -d "${suite}" ]] then @@ -35,7 +37,8 @@ done step "running ${suites_to_run}" #run suites -if [ "${suites_to_run}" != "" ]; then +if [ "${suites_to_run}" != "" ] +then # shellcheck disable=SC2086 SKIP_TEARDOWN="${skip_teardown}" CONFIG="${PWD}/acceptance_config.json" DEBUG='true' ./bin/test -race -nodes="${nodes}" -trace $ginkgo_opts ${suites_to_run} else diff --git a/ci/autoscaler/scripts/run-integration-tests.sh b/ci/autoscaler/scripts/run-integration-tests.sh index d66ebf8471..aafb9614d8 100755 --- a/ci/autoscaler/scripts/run-integration-tests.sh +++ b/ci/autoscaler/scripts/run-integration-tests.sh @@ -1,15 +1,11 @@ -#!/bin/bash +#! /usr/bin/env bash + # shellcheck disable=SC2086 -set -euo pipefail +set -eu -o pipefail pg_ctlcluster "$(pg_lsclusters -j | jq -r '.[0].version')" main start - psql postgres://postgres@127.0.0.1:5432 -c 'DROP DATABASE IF EXISTS autoscaler' psql postgres://postgres@127.0.0.1:5432 -c 'CREATE DATABASE autoscaler' -pushd app-autoscaler-release - - CI=true make integration - -popd +CI='true' make --directory='app-autoscaler-release' integration diff --git a/ci/autoscaler/scripts/run-unit-tests.sh b/ci/autoscaler/scripts/run-unit-tests.sh index 3265dac224..4990044cf8 100755 --- a/ci/autoscaler/scripts/run-unit-tests.sh +++ b/ci/autoscaler/scripts/run-unit-tests.sh @@ -1,17 +1,12 @@ -#!/bin/bash -# shellcheck disable=SC2086 +#! /usr/bin/env bash -set -euo pipefail +# shellcheck disable=SC2086 -export DB_HOST="localhost" +set -eu -o pipefail +export DB_HOST='localhost' # 🚧 To-do: Can we skip this? pg_ctlcluster "$(pg_lsclusters -j | jq -r '.[0].version')" main start - psql postgres://postgres@127.0.0.1:5432 -c 'DROP DATABASE IF EXISTS autoscaler' psql postgres://postgres@127.0.0.1:5432 -c 'CREATE DATABASE autoscaler' -pushd app-autoscaler-release - - CI=true make test - -popd +CI='true' make --directory='./app-autoscaler-release' test diff --git a/ci/autoscaler/scripts/vars.source.sh b/ci/autoscaler/scripts/vars.source.sh index c4c15b2d04..c9261a1a52 100644 --- a/ci/autoscaler/scripts/vars.source.sh +++ b/ci/autoscaler/scripts/vars.source.sh @@ -1,48 +1,51 @@ -#!/usr/bin/env bash -# NOTE: to turn on debug use DEBUG=true +#! /usr/bin/env bash + +# 🪧 NOTE: to turn on debug use DEBUG=true # shellcheck disable=SC2155,SC2034 # if [ -z "${BASH_SOURCE[0]}" ]; then - echo "### Source this from inside a script only! " - echo "### =======================================" - echo - return + echo "### Source this from inside a script only! " + echo "### =======================================" + echo + return fi write_error_state() { - echo "Error failed execution of \"$1\" at line $2" - local frame=0 - while true ; do - caller $frame && break - ((frame++)); - done + echo "Error failed execution of \"$1\" at line $2" + local frame=0 + while true ; do + caller $frame && break + ((frame++)); + done } trap 'write_error_state "$BASH_COMMAND" "$LINENO"' ERR debug=${DEBUG:-} if [ -n "${debug}" ] && [ ! "${debug}" = "false" ]; then - function debug(){ echo " -> $1"; } + function debug(){ echo " -> $1"; } else - function debug(){ :; } + function debug(){ :; } fi function warn(){ - echo " - WARN: $1" + echo " - WARN: $1" } function log(){ - echo " - $1" -} - -function step(){ - echo "# $1" + echo " - $1" } script_dir="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root_dir=$(realpath -e "${script_dir}/../../..") +# This environment-variable is used as the target-name for concourse that is used to communicate +# with the concourse-instance that manages the os-pipelines of this repository under +# +CONCOURSE_AAS_RELEASE_TARGET="${CONCOURSE_AAS_RELEASE_TARGET:-app-autoscaler-release}" +debug "CONCOURSE_AAS_RELEASE_TARGET: ${CONCOURSE_AAS_RELEASE_TARGET}" + export PR_NUMBER=${PR_NUMBER:-$(gh pr view --json number --jq '.number' )} debug "PR_NUMBER: '${PR_NUMBER}'" user=${USER:-"test"} @@ -68,10 +71,12 @@ debug "SYSTEM_DOMAIN: ${SYSTEM_DOMAIN}" system_domain="${SYSTEM_DOMAIN}" BBL_STATE_PATH="${BBL_STATE_PATH:-$( realpath -e "${root_dir}/../app-autoscaler-env-bbl-state/bbl-state" 2> /dev/null || echo "${root_dir}/../bbl-state/bbl-state" )}" -BBL_STATE_PATH="$(realpath -e "${BBL_STATE_PATH}" || echo "ERR_invalid_state_path" )" +# We want to print out the name of the variable literally and marked as shell-variable, therefore: +# shellcheck disable=SC2016 +BBL_STATE_PATH="$(realpath --canonicalize-existing "${BBL_STATE_PATH}" \ + || echo 'ERR_invalid_state_path, please set ${BBL_STATE_PATH}' )" export BBL_STATE_PATH -debug "BBL_STATE_PATH: ${BBL_STATE_PATH}" -bbl_state_path="${BBL_STATE_PATH}" +debug "BBL_STATE_PATH: ${BBL_STATE_PATH}" AUTOSCALER_DIR="${AUTOSCALER_DIR:-${root_dir}}" export AUTOSCALER_DIR="$(realpath -e "${AUTOSCALER_DIR}" )" diff --git a/ci/autoscaler/set-pipeline.sh b/ci/autoscaler/set-pipeline.sh index e7de3fe9ac..4cf5f80d64 100755 --- a/ci/autoscaler/set-pipeline.sh +++ b/ci/autoscaler/set-pipeline.sh @@ -3,91 +3,100 @@ # To run this script you need to have set up the target using # fly login -t app-autoscaler-release -c https://concourse.app-runtime-interfaces.ci.cloudfoundry.org -n app-autoscaler # -# When running concourse locally: ` fly -t "local" login -c "http://localhost:8080" ` +# When running concourse locally: `fly --target="local" login -c "http://localhost:8080"` # Then `TARGET=local set-pipeline.sh` -set -euo pipefail +set -eu -o pipefail -if "$(which gh)" > /dev/null; then - echo "gh cli found" - gh --version +if command -v gh &> /dev/null +then + echo "gh cli found" + gh --version else - echo "no gh cli found!" - exit 1 + echo "no gh cli found!" + exit 1 fi -export PR_NUMBER=${PR_NUMBER:-$(gh pr view --json number --jq '.number' )} +PR_NUMBER="${PR_NUMBER:-$(gh pr view --json number --jq '.number' )}" +readonly PR_NUMBER +export PR_NUMBER fly_args="" add_var() { - fly_args="${fly_args} -v ${1}=${2}" + fly_args="${fly_args} --var ${1}=${2}" } TARGET="${TARGET:-app-autoscaler-release}" function set_pipeline(){ - local pipeline_name="$1" - add_var branch_name "${CURRENT_BRANCH}" - if [[ -z $PR_NUMBER ]]; then - add_var pr_number "${PR_NUMBER}" - add_var acceptance_deployment_name "acceptance" - add_var acceptance_deployment_name_logcache_metron "acceptance-lc" - add_var acceptance_deployment_name_logcache_syslog "acceptance-lc-sl" - add_var acceptance_deployment_name_logcache_syslog_cf "acceptance-lc-sl-cf" - else - add_var pr_number "${PR_NUMBER}" - add_var acceptance_deployment_name "${PR_NUMBER}-acceptance" - add_var acceptance_deployment_name_logcache_metron "${PR_NUMBER}-acceptance-lc" - add_var acceptance_deployment_name_logcache_syslog "${PR_NUMBER}-acceptance-lc-sl" - add_var acceptance_deployment_name_logcache_syslog_cf "${PR_NUMBER}-acceptance-lc-sl-cf" - fi - - # shellcheck disable=SC2086 - fly -t "${TARGET}" set-pipeline --config="pipeline.yml" --pipeline="${pipeline_name}" $fly_args - fly -t "${TARGET}" unpause-pipeline -p "${pipeline_name}" + local -r pipeline_name="$1" + add_var branch_name "${CURRENT_BRANCH}" + if [[ -z $PR_NUMBER ]]; then + add_var pr_number "${PR_NUMBER}" + add_var acceptance_deployment_name "acceptance" + add_var acceptance_deployment_name_logcache_metron "acceptance-lc" + add_var acceptance_deployment_name_logcache_syslog "acceptance-lc-sl" + add_var acceptance_deployment_name_logcache_syslog_cf "acceptance-lc-sl-cf" + else + add_var pr_number "${PR_NUMBER}" + add_var acceptance_deployment_name "${PR_NUMBER}-acceptance" + add_var acceptance_deployment_name_logcache_metron "${PR_NUMBER}-acceptance-lc" + add_var acceptance_deployment_name_logcache_syslog "${PR_NUMBER}-acceptance-lc-sl" + add_var acceptance_deployment_name_logcache_syslog_cf "${PR_NUMBER}-acceptance-lc-sl-cf" + fi + + # shellcheck disable=SC2086 + fly --target="${TARGET}" set-pipeline --config="pipeline.yml" --pipeline="${pipeline_name}" ${fly_args} + fly --target="${TARGET}" unpause-pipeline --pipeline="${pipeline_name}" } function pause_job(){ - local job_name="$1" - fly -t "${TARGET}" pause-job -j "${job_name}" + local job_name="$1" + fly --target="${TARGET}" pause-job -j "${job_name}" } function unpause_job(){ - local job_name="$1" - fly -t "${TARGET}" unpause-job -j "${job_name}" + local job_name="$1" + fly --target="${TARGET}" unpause-job -j "${job_name}" } function get_jobs(){ - local pipeline_name="$1" - fly -t "${TARGET}" jobs --pipeline="${pipeline_name}" --json | jq ".[].name" -r + local pipeline_name="$1" + fly --target="${TARGET}" jobs --pipeline="${pipeline_name}" --json | jq ".[].name" -r } function pause_jobs(){ - local pipeline_name="$1" - for job in $(get_jobs "$pipeline_name"); do - pause_job "${pipeline_name}/$job" - done + local pipeline_name="$1" + for job in $(get_jobs "$pipeline_name"); do + pause_job "${pipeline_name}/$job" + done } function main(){ - SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}") - pushd "${SCRIPT_RELATIVE_DIR}" > /dev/null - CURRENT_BRANCH="$(git symbolic-ref --short HEAD)" - - if [[ "$CURRENT_BRANCH" == "main" ]];then - export PIPELINE_NAME="app-autoscaler-release" - set_pipeline $PIPELINE_NAME - else - local current_branch_without_slashes - current_branch_without_slashes="$(echo "${CURRENT_BRANCH}" | sed 's/\//-/g')" # Concourse can't handle slashes in pipeline names - - export PIPELINE_NAME="app-autoscaler-release-${current_branch_without_slashes}" - set_pipeline "$PIPELINE_NAME" - pause_jobs "$PIPELINE_NAME" - fi - - popd > /dev/null + SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}") + pushd "${SCRIPT_RELATIVE_DIR}" > /dev/null + CURRENT_BRANCH="$(git symbolic-ref --short HEAD)" + + if [[ "${CURRENT_BRANCH}" == "main" ]] + then + export PIPELINE_NAME='app-autoscaler-release' + set_pipeline "${PIPELINE_NAME}" + else + # Concourse can't handle slashes in pipeline names + local current_branch_without_slashes + current_branch_without_slashes="$(echo "${CURRENT_BRANCH}" | sed 's/\//-/g')" + + export PIPELINE_NAME="app-autoscaler-release-${current_branch_without_slashes}" + set_pipeline "${PIPELINE_NAME}" + pause_jobs "${PIPELINE_NAME}" + fi + + popd > /dev/null } -[ "${BASH_SOURCE[0]}" == "${0}" ] && main "$@" + +if [ "${BASH_SOURCE[0]}" == "${0}" ] +then + main "$@" +fi diff --git a/ci/autoscaler/tasks/cleanup-autoscaler-deployments.yml b/ci/autoscaler/tasks/cleanup-autoscaler-deployments.yml index 107dfea27e..a078e163cd 100644 --- a/ci/autoscaler/tasks/cleanup-autoscaler-deployments.yml +++ b/ci/autoscaler/tasks/cleanup-autoscaler-deployments.yml @@ -1,12 +1,6 @@ --- platform: linux -image_resource: - type: registry-image - source: - repository: ghcr.io/cloudfoundry/app-autoscaler-release-tools - tag: main - params: AUTOSCALER_DIR: app-autoscaler-release diff --git a/ci/autoscaler/tasks/fetch-latest-stemcell.yml b/ci/autoscaler/tasks/fetch-latest-stemcell.yml index 7033e4bd95..38145d83c5 100644 --- a/ci/autoscaler/tasks/fetch-latest-stemcell.yml +++ b/ci/autoscaler/tasks/fetch-latest-stemcell.yml @@ -1,12 +1,6 @@ --- platform: linux -image_resource: - type: registry-image - source: - repository: ghcr.io/cloudfoundry/app-autoscaler-release-tools - tag: main - inputs: - name: ci - name: bbl-state diff --git a/ci/autoscaler/tasks/make/make.yaml b/ci/autoscaler/tasks/make/make.yaml index 4e7b41ba32..10d3aa926e 100644 --- a/ci/autoscaler/tasks/make/make.yaml +++ b/ci/autoscaler/tasks/make/make.yaml @@ -1,12 +1,6 @@ --- platform: linux -image_resource: - type: registry-image - source: - repository: ghcr.io/cloudfoundry/app-autoscaler-release-tools - tag: main - params: TARGETS: diff --git a/ci/autoscaler/tasks/release-autoscaler.yml b/ci/autoscaler/tasks/release-autoscaler.yml index 7a78a822c4..cbce59e8dd 100644 --- a/ci/autoscaler/tasks/release-autoscaler.yml +++ b/ci/autoscaler/tasks/release-autoscaler.yml @@ -1,12 +1,6 @@ --- platform: linux -image_resource: - type: registry-image - source: - repository: ghcr.io/cloudfoundry/app-autoscaler-release-tools - tag: main - params: # The GCP key to use to configure the generated private.yml UPLOADER_KEY: diff --git a/ci/autoscaler/tasks/run-acceptance-tests.yml b/ci/autoscaler/tasks/run-acceptance-tests.yml index d81222a7f9..165c1f0361 100644 --- a/ci/autoscaler/tasks/run-acceptance-tests.yml +++ b/ci/autoscaler/tasks/run-acceptance-tests.yml @@ -1,12 +1,6 @@ --- platform: linux -image_resource: - type: registry-image - source: - repository: ghcr.io/cloudfoundry/app-autoscaler-release-tools - tag: main - params: NODES: 3 inputs: diff --git a/ci/autoscaler/tasks/run-unit-tests.yml b/ci/autoscaler/tasks/run-unit-tests.yml index 73cea7833f..31db6de811 100644 --- a/ci/autoscaler/tasks/run-unit-tests.yml +++ b/ci/autoscaler/tasks/run-unit-tests.yml @@ -1,12 +1,6 @@ --- platform: linux -image_resource: - type: registry-image - source: - repository: ghcr.io/cloudfoundry/app-autoscaler-release-tools - tag: main - inputs: - name: app-autoscaler-release diff --git a/ci/autoscaler/tasks/update-sdk/update_package.sh b/ci/autoscaler/tasks/update-sdk/update_package.sh index 7de50cc03b..a2023eef64 100755 --- a/ci/autoscaler/tasks/update-sdk/update_package.sh +++ b/ci/autoscaler/tasks/update-sdk/update_package.sh @@ -1,10 +1,10 @@ #! /usr/bin/env bash [ -n "${DEBUG}" ] && set -x -set -euo pipefail +set -eu -o pipefail script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" source "${script_dir}/vars.source.sh" -create_pr=${CREATE_PR:-"false"} +create_pr="${CREATE_PR:-'false'}" # shellcheck disable=SC2154 devbox run --config app-autoscaler-release -- "cd ..; ${script_dir}/update_${type}_package.sh" diff --git a/devbox.json b/devbox.json index 74d49d703c..71a19cf670 100644 --- a/devbox.json +++ b/devbox.json @@ -15,7 +15,7 @@ "credhub-cli": "2.9.44", "delve": "1.24.2", "direnv": "2.36.0", - "fly": "7.13.0", + "fly": "7.12.0", "gh": "2.69.0", "ginkgo": "2.23.4", "gnumake": "4.4", @@ -33,6 +33,7 @@ "postgresql": "latest", "python": "3.13.2", "redocly": "1.34.0", + "ripgrep": "latest", "ruby": "3.4.2", "shellcheck": "0.10.0", "temurin-bin-21": "21.0.3", diff --git a/devbox.lock b/devbox.lock index d8e9b2c52e..836c4a038f 100644 --- a/devbox.lock +++ b/devbox.lock @@ -457,51 +457,51 @@ } } }, - "fly@7.13.0": { - "last_modified": "2025-04-13T09:22:33Z", - "resolved": "github:NixOS/nixpkgs/18dd725c29603f582cf1900e0d25f9f1063dbf11#fly", + "fly@7.12.0": { + "last_modified": "2025-01-19T08:16:51Z", + "resolved": "github:NixOS/nixpkgs/50165c4f7eb48ce82bd063e1fb8047a0f515f8ce#fly", "source": "devbox-search", - "version": "7.13.0", + "version": "7.12.0", "systems": { "aarch64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/xag669v1qd9jsxmplnxwm3zn5hz9kxrn-fly-7.13.0", + "path": "/nix/store/18b6ivnni1azzymzzlgy9dqzrh5cr3va-fly-7.12.0", "default": true } ], - "store_path": "/nix/store/xag669v1qd9jsxmplnxwm3zn5hz9kxrn-fly-7.13.0" + "store_path": "/nix/store/18b6ivnni1azzymzzlgy9dqzrh5cr3va-fly-7.12.0" }, "aarch64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/z2gc8f7xxp0q55qgj4s8q0c7dbakwggj-fly-7.13.0", + "path": "/nix/store/7l0qwz5riwcxf5aa30nkry32jzckr037-fly-7.12.0", "default": true } ], - "store_path": "/nix/store/z2gc8f7xxp0q55qgj4s8q0c7dbakwggj-fly-7.13.0" + "store_path": "/nix/store/7l0qwz5riwcxf5aa30nkry32jzckr037-fly-7.12.0" }, "x86_64-darwin": { "outputs": [ { "name": "out", - "path": "/nix/store/5c8fhscc39q9cjj6bdh3qh50kabq3y0b-fly-7.13.0", + "path": "/nix/store/25zv07kj03kspmby0sarihsq4ssb1g9b-fly-7.12.0", "default": true } ], - "store_path": "/nix/store/5c8fhscc39q9cjj6bdh3qh50kabq3y0b-fly-7.13.0" + "store_path": "/nix/store/25zv07kj03kspmby0sarihsq4ssb1g9b-fly-7.12.0" }, "x86_64-linux": { "outputs": [ { "name": "out", - "path": "/nix/store/z14jxic9f4jd0szznk5sh5wsb14lpc1v-fly-7.13.0", + "path": "/nix/store/s7rfg1gxlsylvnd6x01vaznzhasrjxp4-fly-7.12.0", "default": true } ], - "store_path": "/nix/store/z14jxic9f4jd0szznk5sh5wsb14lpc1v-fly-7.13.0" + "store_path": "/nix/store/s7rfg1gxlsylvnd6x01vaznzhasrjxp4-fly-7.12.0" } } }, @@ -601,38 +601,6 @@ } } }, - "github:NixOS/nixpkgs/nixpkgs-unstable": { - "last_modified": "2025-04-23T03:04:08Z", - "resolved": "github:NixOS/nixpkgs/507b63021ada5fee621b6ca371c4fca9ca46f52c?lastModified=1745377448&narHash=sha256-jhZDfXVKdD7TSEGgzFJQvEEZ2K65UMiqW5YJ2aIqxMA%3D" - }, - "glibcLocales@latest": { - "last_modified": "2025-03-11T17:52:14Z", - "resolved": "github:NixOS/nixpkgs/0d534853a55b5d02a4ababa1d71921ce8f0aee4c#glibcLocales", - "source": "devbox-search", - "version": "2.40-66", - "systems": { - "aarch64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/iv7avlnmk2cx79xpi4mr8sk1kxvlvm9l-glibc-locales-2.40-66", - "default": true - } - ], - "store_path": "/nix/store/iv7avlnmk2cx79xpi4mr8sk1kxvlvm9l-glibc-locales-2.40-66" - }, - "x86_64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/hgybbbzg778wasmw5g1hzm7a8n4wwd5h-glibc-locales-2.40-66", - "default": true - } - ], - "store_path": "/nix/store/hgybbbzg778wasmw5g1hzm7a8n4wwd5h-glibc-locales-2.40-66" - } - } - }, "gnumake@4.4": { "last_modified": "2025-03-11T15:50:42Z", "resolved": "github:NixOS/nixpkgs/b62d2a95c72fb068aecd374a7262b37ed92df82b#gnumake", @@ -1291,7 +1259,7 @@ }, "mysql@10.6.12": { "last_modified": "2023-02-24T09:01:09Z", - "plugin_version": "0.0.4", + "plugin_version": "0.0.3", "resolved": "github:NixOS/nixpkgs/7d0ed7f2e5aea07ab22ccb338d27fbe347ed2f11#mysql", "source": "devbox-search", "version": "10.6.12" @@ -1471,7 +1439,7 @@ }, "python@3.13.2": { "last_modified": "2025-03-03T13:00:40Z", - "plugin_version": "0.0.4", + "plugin_version": "0.0.3", "resolved": "github:NixOS/nixpkgs/95eacfb6d1accf8d59a9e570d26d04ad693d2ec3#python313", "source": "devbox-search", "version": "3.13.2", @@ -1574,6 +1542,54 @@ } } }, + "ripgrep@latest": { + "last_modified": "2025-03-11T17:52:14Z", + "resolved": "github:NixOS/nixpkgs/0d534853a55b5d02a4ababa1d71921ce8f0aee4c#ripgrep", + "source": "devbox-search", + "version": "14.1.1", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/8jp8ck4gl2gcnl84bm9kjl4fakpdkk7z-ripgrep-14.1.1", + "default": true + } + ], + "store_path": "/nix/store/8jp8ck4gl2gcnl84bm9kjl4fakpdkk7z-ripgrep-14.1.1" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/w01qdshvhg0mhwfdlfb43w8qbi13x4rd-ripgrep-14.1.1", + "default": true + } + ], + "store_path": "/nix/store/w01qdshvhg0mhwfdlfb43w8qbi13x4rd-ripgrep-14.1.1" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/38dfkpikydr5yai23ns7j1c07k42ddkf-ripgrep-14.1.1", + "default": true + } + ], + "store_path": "/nix/store/38dfkpikydr5yai23ns7j1c07k42ddkf-ripgrep-14.1.1" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/3mlj8k3yn1nmc6qa0snnqmjxqvfd467n-ripgrep-14.1.1", + "default": true + } + ], + "store_path": "/nix/store/3mlj8k3yn1nmc6qa0snnqmjxqvfd467n-ripgrep-14.1.1" + } + } + }, "ruby@3.4.2": { "last_modified": "2025-03-11T17:52:14Z", "plugin_version": "0.0.2", diff --git a/flake.lock b/flake.lock new file mode 120000 index 0000000000..cacaa4c37d --- /dev/null +++ b/flake.lock @@ -0,0 +1 @@ +./nix/flake.lock \ No newline at end of file diff --git a/flake.nix b/flake.nix new file mode 120000 index 0000000000..56d30a1329 --- /dev/null +++ b/flake.nix @@ -0,0 +1 @@ +./nix/flake.nix \ No newline at end of file diff --git a/nix/flake.nix b/nix/flake.nix index 2686ebf4fb..71bf87e5d7 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -21,5 +21,16 @@ callPackages = nixpkgs.lib.customisation.callPackagesWith nixpkgs; in callPackages ./packages.nix {} ); + + # 🚸 Having flake.nix on top-level makes this definition easily consumable with Nix, e.g. for + # other repositories of Autoscaler. ⚠️ This currently is for internal use only. Autoscaler does + # not officially support this flake-output. + openapi-specifications = { + app-autoscaler-api = + let apiPath = ./api; + in builtins.filterSource + (path: type: builtins.match ".*\.ya?ml" (baseNameOf path) != null && type == "regular") + apiPath; + }; }; }