From fd1c84181040fb7d8c402971fd1573d4b96b2353 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Mon, 15 Aug 2022 18:46:19 +0300 Subject: [PATCH] Pull request: Separate front- and back- end builds Merge in DNS/adguard-home from imp-bamboo-specs to master Squashed commit of the following: commit 3415b650e48aefef3ad16030be3d797de4015403 Merge: e37c0a2b f58265ec Author: Eugene Burkov Date: Mon Aug 15 18:42:42 2022 +0300 Merge branch 'master' into imp-bamboo-specs commit e37c0a2bb52fab98e133332e8f54d500d0f96b06 Author: Ainar Garipov Date: Mon Aug 15 18:30:33 2022 +0300 scripts: replace find with loop commit 826a02f6a11000cce4b3205229d6bbb050c8dd73 Author: Eugene Burkov Date: Mon Aug 15 18:00:41 2022 +0300 all: ...again commit 54aebf5d4aeba35e3dc320436236759f4d1ccdad Author: Eugene Burkov Date: Mon Aug 15 17:59:24 2022 +0300 all: fix spec yaml commit 87b92b30504f2427c40303265354afba4855e0bb Author: Eugene Burkov Date: Mon Aug 15 17:48:19 2022 +0300 all: separate front- and back-end builds --- Makefile | 2 +- bamboo-specs/release.yaml | 39 +++++++++++++++++++++++++++++- scripts/make/build-release.sh | 45 +++++++++++++++++++++++++++-------- 3 files changed, 74 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 7c8f205f..b4823bb7 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ V1API = 0 # into BUILD_RELEASE_DEPS_0, and so both frontend and backend # dependencies are fetched and the frontend is built. Otherwise, if # FRONTEND_PREBUILT is 1, only backend dependencies are fetched and the -# frontend isn't reuilt. +# frontend isn't rebuilt. # # TODO(a.garipov): We could probably do that from .../build-release.sh, # but that would mean either calling make from inside make or diff --git a/bamboo-specs/release.yaml b/bamboo-specs/release.yaml index 7dd9a859..e3451bdc 100644 --- a/bamboo-specs/release.yaml +++ b/bamboo-specs/release.yaml @@ -10,6 +10,12 @@ 'dockerGo': 'adguard/golang-ubuntu:5.0' 'stages': +- 'Build frontend': + 'manual': false + 'final': false + 'jobs': + - 'Build frontend' + - 'Make release': 'manual': false 'final': false @@ -40,11 +46,41 @@ 'jobs': - 'Publish to GitHub Releases' -'Make release': +'Build frontend': 'docker': 'image': '${bamboo.dockerGo}' 'volumes': '${system.YARN_DIR}': '${bamboo.cacheYarn}' + 'key': 'BF' + 'other': + 'clean-working-dir': true + 'tasks': + - 'checkout': + 'force-clean-build': true + - 'script': + 'interpreter': 'SHELL' + 'scripts': + - | + #!/bin/sh + + set -e -f -u -x + + # Explicitly checkout the revision that we need. + git checkout "${bamboo.repository.revision.number}" + + make js-build + 'artifacts': + - 'name': 'AdGuardHome frontend' + 'pattern': 'build*/**' + 'shared': true + 'required': true + 'requirements': + - 'adg-docker': 'true' + +'Make release': + 'docker': + 'image': '${bamboo.dockerGo}' + 'volumes': '${system.GO_CACHE_DIR}': '${bamboo.cacheGo}' '${system.GO_PKG_CACHE_DIR}': '${bamboo.cacheGoPkg}' 'key': 'MR' @@ -72,6 +108,7 @@ make\ CHANNEL=${bamboo.channel}\ GPG_KEY_PASSPHRASE=${bamboo.gpgPassword}\ + FRONTEND_PREBUILT=1\ VERBOSE=1\ build-release # TODO(a.garipov): Use more fine-grained artifact rules. diff --git a/scripts/make/build-release.sh b/scripts/make/build-release.sh index 072dfe7a..1c8cb9c0 100644 --- a/scripts/make/build-release.sh +++ b/scripts/make/build-release.sh @@ -109,17 +109,17 @@ log "checking tools" # Make sure we fail gracefully if one of the tools we need is missing. Use # alternatives when available. -sha256sum_cmd='sha256sum' -for tool in gpg gzip sed "$sha256sum_cmd" snapcraft tar zip +use_shasum='0' +for tool in gpg gzip sed sha256sum snapcraft tar zip do if ! command -v "$tool" > /dev/null then - if [ "$tool" = "$sha256sum_cmd" ] && command -v 'shasum' > /dev/null + if [ "$tool" = 'sha256sum' ] && command -v 'shasum' > /dev/null then - # macOS doesn't have sha256sum installed by default, but - # it does have shasum. + # macOS doesn't have sha256sum installed by default, but it does + # have shasum. log 'replacing sha256sum with shasum -a 256' - sha256sum_cmd='shasum -a 256' + use_shasum='1' else log "pieces don't fit, '$tool' not found" @@ -127,7 +127,7 @@ do fi fi done -readonly sha256sum_cmd +readonly use_shasum # Data section. Arrange data into space-separated tables for read -r to read. # Use a hyphen for missing values. @@ -332,15 +332,40 @@ log "$build_archive" log "calculating checksums" +# calculate_checksums uses the previously detected SHA-256 tool to calculate +# checksums. Do not use find with -exec, since shasum requires arguments. +calculate_checksums() { + if [ "$use_shasum" -eq '0' ] + then + sha256sum "$@" + else + shasum -a 256 "$@" + fi +} + # Calculate the checksums of the files in a subshell with a different working # directory. Don't use ls, because files matching one of the patterns may be # absent, which will make ls return with a non-zero status code. +# +# TODO(a.garipov): Consider calculating these as the build goes. ( + set +f + cd "./${dist}" - find . ! -name . -prune \( -name '*.tar.gz' -o -name '*.zip' \)\ - -exec "$sha256sum_cmd" {} +\ - > ./checksums.txt + : > ./checksums.txt + + for archive in ./*.zip ./*.tar.gz + do + # Make sure that we don't try to calculate a checksum for a glob pattern + # that matched no files. + if [ ! -f "$archive" ] + then + continue + fi + + calculate_checksums "$archive" >> ./checksums.txt + done ) log "writing versions"