angular-docs-cn/scripts/build-packages-dist.sh
Igor Minar 4237c34c78 test(ivy): mark failing test targets with fixme-ivy-jit and fixme-ivy-local tags (#26471)
We are close enough to blacklist a few test targets, rather than whitelist targets to run...

Because bazel rules can be composed of other rules that don't inherit tags automatically,
I had to explicitly mark all of our ts_library and ng_module targes with "ivy-local" and
"ivy-jit" tags so that we can create a query that excludes all fixme- tagged targets even
if those targets are composed of other targets that don't inherit this tag.

This is the updated overview of ivy related bazel tags:

- ivy-only: target that builds or runs only under ivy
- fixme-ivy-jit: target that doesn't yet build or run under ivy with --compile=jit
- fixme-ivy-local: target that doesn't yet build or run under ivy with --compile=local
- no-ivy-jit: target that is not intended to build or run under ivy with --compile=jit
- no-ivy-local: target that is not intended to build or run under ivy with --compile=local

PR Close #26471
2018-10-23 08:57:42 -07:00

76 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the dist/packages-dist directory in the same fashion as the legacy
# /build.sh script, by building the npm packages with Bazel and copying files.
# This is needed for scripts and tests which are not updated to the Bazel output
# layout (which always matches the input layout).
# Do not add new dependencies on this script, instead adapt scripts to use the
# new layout, and write new tests as Bazel targets.
set -u -e -o pipefail
cd "$(dirname "$0")"
# basedir is the workspace root
readonly basedir=$(pwd)/..
readonly bin=$(bazel info bazel-bin)
function buildTargetPackages() {
targets="$1"
destPath="$2"
compileMode="$3"
desc="$4"
echo "##################################"
echo "scripts/build-packages-dist.sh:"
echo " building @angular/* npm packages"
echo " mode: ${desc}"
echo "##################################"
echo "$targets" | xargs bazel build --define=compile=$compileMode
[ -d "${basedir}/${destPath}" ] || mkdir -p $basedir/${destPath}
dirs=`echo "$targets" | grep '//packages/[^/]*:npm_package' | sed -e 's/\/\/packages\/\(.*\):npm_package/\1/'`
for pkg in $dirs; do
# Skip any that don't have an "npm_package" target
srcDir="${bin}/packages/${pkg}/npm_package"
destDir="${basedir}/${destPath}/${pkg}"
if [ -d $srcDir ]; then
echo "# Copy artifacts to ${destDir}"
rm -rf $destDir
cp -R $srcDir $destDir
chmod -R u+w $destDir
fi
done
}
# Ideally these integration tests should run under bazel, and just list the npm
# packages in their deps[].
# Until then, we have to manually run bazel first to create the npm packages we
# want to test.
LEGACY_TARGETS=`bazel query --output=label 'kind(.*_package, //packages/...)'`
buildTargetPackages "$LEGACY_TARGETS" "dist/packages-dist" "legacy" "Production"
# We don't use the ivy build in the integration tests, only when publishing
# snapshots.
# This logic matches what we use in the .circleci/config.yml file to short-
# circuit execution of the publish-packages job.
[[ "${CIRCLE_PR_NUMBER-}" != ""
|| "${CIRCLE_PROJECT_USERNAME-}" != "angular"
|| "${CIRCLE_PROJECT_REPONAME-}" != "angular"
]] && exit 0
# TODO: do we actually need to query for jit and local targets? shouldn't this be all the packages that we publish to npm?
IVY_JIT_TARGETS=`bazel query --output=label 'attr("tags", "\[.*ivy-jit.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
IVY_LOCAL_TARGETS=`bazel query --output=label 'attr("tags", "\[.*ivy-local.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
# A clean is needed since build artifacts from previous build can break the following build
bazel clean
buildTargetPackages "$IVY_JIT_TARGETS" "dist/packages-dist-ivy-jit" "jit" "Ivy JIT"
# A clean is needed since build artifacts from previous build can break the following build
bazel clean
buildTargetPackages "$IVY_LOCAL_TARGETS" "dist/packages-dist-ivy-local" "local" "Ivy AOT"