From dc186243239be9e921e16c6a595c3779bf37b8bc Mon Sep 17 00:00:00 2001 From: Mustafa Gezen Date: Sun, 30 Oct 2022 09:44:59 +0100 Subject: [PATCH] Add config to build impacted frontends --- config/jobs/presubmits.yaml | 18 ++++++++++++++++++ hack/build_impacted_frontend.sh | 16 ++++++++++++++++ hack/frontend_build.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100755 hack/build_impacted_frontend.sh create mode 100644 hack/frontend_build.sh diff --git a/config/jobs/presubmits.yaml b/config/jobs/presubmits.yaml index 0f59c7b..9bff83c 100644 --- a/config/jobs/presubmits.yaml +++ b/config/jobs/presubmits.yaml @@ -50,6 +50,24 @@ presubmits: command: - hack/non_manual_build.sh + - name: pull-peridot-build-impacted-frontend + branches: + - main + always_run: true + decorate: true + spec: + tolerations: + - key: peridot.rockylinux.org/workflow-tolerates-arch + operator: Equal + value: amd64 + effect: NoSchedule + nodeSelector: + peridot.rockylinux.org/workflow-tolerates-arch: amd64 + containers: + - image: quay.io/peridot/ci:v0.3.16 + command: + - hack/frontend_build.sh + - name: pull-peridot-gofmt-check branches: - main diff --git a/hack/build_impacted_frontend.sh b/hack/build_impacted_frontend.sh new file mode 100755 index 0000000..5da67b8 --- /dev/null +++ b/hack/build_impacted_frontend.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -o errexit + +source hack/bazel_setup.sh + +starting_query="attr(tags, 'resf_frontend_bundle'," + +for t in `cat impacted_targets`; do + starting_query="$starting_query $t union" +done + +starting_query=${starting_query%" union"} +starting_query="$starting_query)" + +$BAZEL_B $($BAZEL_QR "$starting_query") diff --git a/hack/frontend_build.sh b/hack/frontend_build.sh new file mode 100644 index 0000000..2dc4135 --- /dev/null +++ b/hack/frontend_build.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -o errexit + +source hack/bazel_setup.sh + +bazel_bin="$(which bazel)" +workspace_dir="$(pwd)" + +$BAZEL_B //:bazel-diff + +# Generate starting hashes +git checkout "$PULL_BASE_SHA" --quiet +bazel-bin/bazel-diff generate-hashes -w "$workspace_dir" -b "$bazel_bin" starting_hashes_json + +# Generate ending hashes +git checkout "$PULL_PULL_SHA" --quiet +bazel-bin/bazel-diff generate-hashes -w "$workspace_dir" -b "$bazel_bin" ending_hashes_json + +# Get impacted targets +bazel-bin/bazel-diff get-impacted-targets -sh starting_hashes_json -fh ending_hashes_json impacted_targets + +# Build impacted targets +hack/build_impacted_frontend.sh + +