From 7ed9544f5bce96b5297512d6e8cb974706d8028c Mon Sep 17 00:00:00 2001 From: bodymindarts Date: Tue, 9 Jan 2024 15:57:30 +0100 Subject: [PATCH] ci: complete component ci --- ci/core/pipeline.yml | 30 ++++++++++---- ci/core/template.lib.yml | 88 ++++++++++++++++++++++++++++++++++++++++ dev/Tiltfile | 5 +++ 3 files changed, 116 insertions(+), 7 deletions(-) diff --git a/ci/core/pipeline.yml b/ci/core/pipeline.yml index bec3085965..ff432fd048 100644 --- a/ci/core/pipeline.yml +++ b/ci/core/pipeline.yml @@ -5,8 +5,11 @@ #@ "component_src_resource_name", #@ "core_bundle_src_resource", #@ "buck_test_name", -#@ "buck_test_name", #@ "buck_test", +#@ "component_bats_tests_name", +#@ "component_bats_tests", +#@ "bump_image_in_chart_name", +#@ "bump_image_in_chart", #@ "on_nix_host", #@ "core_bundle_components", #@ "edge_image_resource_name", @@ -48,11 +51,17 @@ groups: - name: #@ component jobs: - #@ buck_test_name(component) + - #@ component_bats_tests_name(component) + - #@ build_edge_image_name(component) + - #@ bump_image_in_chart_name(component) #@ end jobs: #@ for component in components: - #@ buck_test(component) +- #@ component_bats_tests(component) +- #@ build_edge_image(component) +- #@ bump_image_in_chart(component) #@ end - #@ buck_test("api") @@ -194,10 +203,9 @@ jobs: - get: #@ component_src_resource_name("api") trigger: true passed: - - #@ build_edge_image_name("api") - - #@ build_edge_image_name("api-migrate") - - #@ build_edge_image_name("api-ws-server") - - #@ build_edge_image_name("api-trigger") +#@ for component in ["api", "api-migrate", "api-ws-server", "api-trigger"]: + - #@ build_edge_image_name(component) +#@ end - get: pipeline-tasks #@ for component in ["api", "api-migrate", "api-ws-server", "api-trigger"]: - get: #@ edge_image_resource_name(component) @@ -257,12 +265,13 @@ jobs: rebase: true resources: -- #@ core_bundle_src_resource() - #@ for component in components: - #@ component_src_resource(component) +- #@ component_edge_image(component) #@ end +- #@ core_bundle_src_resource() + - name: repo-out type: git source: @@ -315,6 +324,13 @@ resources: branch: #@ data.values.git_charts_branch private_key: #@ data.values.github_private_key +- name: charts-repo-out + type: git + source: + uri: #@ data.values.git_charts_uri + branch: "image-bump-bot-branch" + private_key: #@ data.values.github_private_key + - name: charts-repo-bot-branch type: git source: diff --git a/ci/core/template.lib.yml b/ci/core/template.lib.yml index 3074d2a1c5..f4cc73abc6 100644 --- a/ci/core/template.lib.yml +++ b/ci/core/template.lib.yml @@ -41,6 +41,91 @@ plan: path: pipeline-tasks/ci/apps/tasks/buck-task.sh #@ end +#@ def component_bats_tests_name(component): +#@ return component + "-bats-tests" +#@ end + +#@ def component_bats_tests(component): +#@ return on_nix_host(component_bats_tests_name(component), component, "bats --setup-suite-file bats/ci_setup_suite.bash -t bats/core/" + component) +#@ end + +#@ def bump_image_in_chart_name(component): +#@ return "bump-" + component + "-in-chart" +#@ end + +#@ def bump_image_in_chart(component): +#@ component_lookup = { +#@ "api-keys": { +#@ "YAML_PATH": ".galoy.images.apiKeys.digest", +#@ "CHART": "galoy" +#@ } +#@ } +name: #@ bump_image_in_chart_name(component) +serial: true +plan: + - in_parallel: + - get: #@ component_src_resource_name(component) + trigger: true + passed: + - #@ build_edge_image_name(component) + - #@ buck_test_name(component) + - #@ component_bats_tests_name(component) + - get: #@ edge_image_resource_name(component) + passed: + - #@ build_edge_image_name(component) + params: { skip_download: true } + - get: charts-repo + params: + branch: #@ data.values.git_charts_branch + - get: pipeline-tasks + - task: bump-image-digest-in-values + config: + platform: linux + image_resource: #@ task_image_config() + inputs: + - name: #@ component_src_resource_name(component) + path: repo + - name: #@ edge_image_resource_name(component) + path: edge-image + - name: charts-repo + - name: pipeline-tasks + outputs: + - name: charts-repo + params: + BRANCH: #@ data.values.git_charts_branch + COMPONENT: #@ component + YAML_PATH: #@ component_lookup[component]["YAML_PATH"] + CHART: #@ component_lookup[component]["CHART"] + run: + path: pipeline-tasks/ci/core/tasks/bump-image-digest.sh + - put: charts-repo-out + params: + repository: charts-repo + force: true + branch: #@ "bump-" + component + "-component" + - task: open-charts-pr + config: + platform: linux + image_resource: #@ task_image_config() + inputs: + - name: #@ component_src_resource_name(component) + path: repo + - name: #@ edge_image_resource_name(component) + path: edge-image + - name: charts-repo + - name: pipeline-tasks + params: + GH_APP_ID: #@ data.values.github_app_id + GH_APP_PRIVATE_KEY: #@ data.values.github_app_private_key + COMPONENT: #@ component + BRANCH: #@ data.values.git_charts_branch + BOT_BRANCH: #@ "bump-" + component + "-component" + YAML_PATH: #@ component_lookup[component]["YAML_PATH"] + CHART: #@ component_lookup[component]["CHART"] + run: + path: pipeline-tasks/ci/core/tasks/open-charts-pr.sh +#@ end + #@ def on_nix_host(name, component, cmd, in_dir = ""): #@ params = {} #@ params["REPO_PATH"] = data.values.gh_repository + "-" + name @@ -163,6 +248,9 @@ source: - #@ "core/" + component - #@ "core/" + component + "/*" - #@ "core/" + component + "/**/*" + - #@ "bats/core/" + component + - #@ "bats/core/" + component + "/*" + - #@ "bats/core/" + component + "/**/*" - flake.nix - flake.lock - toolchains/ diff --git a/dev/Tiltfile b/dev/Tiltfile index 1097a10598..4890a1a77b 100644 --- a/dev/Tiltfile +++ b/dev/Tiltfile @@ -15,6 +15,7 @@ TEST_RESOURCES = { } is_ci=("ci" in sys.argv) or cfg.get("bats", False) +run_apps=not cfg.get("bats", False) # From the Tilt docs: # @@ -54,6 +55,7 @@ local_resource( }, deps = _buck2_dep_inputs(dashboard_target), allow_parallel = True, + auto_init = run_apps, resource_deps = [ "hydra-dashboard", "api-keys", @@ -103,6 +105,7 @@ local_resource( 'http://localhost:3001/api/auth/callback/blink', ], allow_parallel = True, + auto_init = run_apps, resource_deps = [ "hydra", "api", @@ -169,6 +172,7 @@ local_resource( serve_cmd = "buck2 run {}".format(consent_target), deps = _buck2_dep_inputs(consent_target), allow_parallel = True, + auto_init = run_apps, resource_deps = [ "hydra-consent", "apollo-router", @@ -193,6 +197,7 @@ local_resource( 'http://localhost:3000', ], allow_parallel = True, + auto_init = run_apps, resource_deps = [ "hydra", "api",