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 <E.Burkov@AdGuard.COM>
Date:   Mon Aug 15 18:42:42 2022 +0300

    Merge branch 'master' into imp-bamboo-specs

commit e37c0a2bb52fab98e133332e8f54d500d0f96b06
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Aug 15 18:30:33 2022 +0300

    scripts: replace find with loop

commit 826a02f6a11000cce4b3205229d6bbb050c8dd73
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Mon Aug 15 18:00:41 2022 +0300

    all: ...again

commit 54aebf5d4aeba35e3dc320436236759f4d1ccdad
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Mon Aug 15 17:59:24 2022 +0300

    all: fix spec yaml

commit 87b92b30504f2427c40303265354afba4855e0bb
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Mon Aug 15 17:48:19 2022 +0300

    all: separate front- and back-end builds
This commit is contained in:
Eugene Burkov 2022-08-15 18:46:19 +03:00
parent f58265ec98
commit fd1c841810
3 changed files with 74 additions and 12 deletions

View File

@ -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

View File

@ -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.

View File

@ -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"