ci(docs-infra): move AIO preview deployment to CircleCI
Now instead of pushing the AIO build artifacts to the preview server from inside a Travis job, the artifacts are built and hosted on the CircleCI infrastructure. The preview server will then pull these down after being triggered by a CircleCI build webhook.
This commit is contained in:
parent
8347bb0d2d
commit
364459c576
|
@ -148,6 +148,22 @@ jobs:
|
|||
- run: bazel run @yarn//:yarn
|
||||
- run: bazel query --output=label //... | xargs bazel test --define=compile=local --build_tag_filters=ivy-local --test_tag_filters=-manual,ivy-local
|
||||
|
||||
aio_preview:
|
||||
<<: *job_defaults
|
||||
environment:
|
||||
AIO_SNAPSHOT_ARTIFACT_PATH: &aio_preview_artifact_path 'aio/tmp/snapshot.tgz'
|
||||
steps:
|
||||
- checkout:
|
||||
<<: *post_checkout
|
||||
- restore_cache:
|
||||
key: *cache_key
|
||||
- run: ./aio/scripts/build-artifacts.sh $AIO_SNAPSHOT_ARTIFACT_PATH
|
||||
- store_artifacts:
|
||||
path: *aio_preview_artifact_path
|
||||
# The `destination` needs to be kept in synch with the value of
|
||||
# `AIO_ARTIFACT_PATH` in `aio/aio-builds-setup/Dockerfile`
|
||||
destination: aio/dist/aio-snapshot.tgz
|
||||
|
||||
# This job exists only for backwards-compatibility with old scripts and tests
|
||||
# that rely on the pre-Bazel dist/packages-dist layout.
|
||||
# It duplicates some work with the job above: we build the bazel packages
|
||||
|
@ -245,6 +261,7 @@ workflows:
|
|||
- test_ivy_jit
|
||||
- test_ivy_aot
|
||||
- build-packages-dist
|
||||
- aio_preview
|
||||
- integration_test:
|
||||
requires:
|
||||
- build-packages-dist
|
||||
|
@ -273,3 +290,6 @@ workflows:
|
|||
branches:
|
||||
only:
|
||||
- master
|
||||
notify:
|
||||
webhooks:
|
||||
- url: https://35.224.48.224/circle-build
|
|
@ -13,6 +13,10 @@ EXPOSE 80 443
|
|||
|
||||
|
||||
# Build-time args and env vars
|
||||
# The AIO_ARTIFACT_PATH path needs to be kept in synch with the value of
|
||||
# `aio_preview->steps->store_artifacts->destination` property in `.circleci/config.yml`
|
||||
ARG AIO_ARTIFACT_PATH=aio/dist/aio-snapshot.tgz
|
||||
ARG TEST_AIO_ARTIFACT_PATH=$AIO_ARTIFACT_PATH
|
||||
ARG AIO_BUILDS_DIR=/var/www/aio-builds
|
||||
ARG TEST_AIO_BUILDS_DIR=/tmp/aio-builds
|
||||
ARG AIO_DOMAIN_NAME=ngbuilds.io
|
||||
|
|
|
@ -66,23 +66,16 @@ server {
|
|||
return 200 '';
|
||||
}
|
||||
|
||||
# Upload builds
|
||||
location "~^/create-build/(?<pr>[1-9][0-9]*)/(?<sha>[0-9a-f]{40})/?$" {
|
||||
# Notify about CircleCI builds
|
||||
location "~^/circle-build/?$" {
|
||||
if ($request_method != "POST") {
|
||||
add_header Allow "POST";
|
||||
return 405;
|
||||
}
|
||||
|
||||
client_body_temp_path /tmp/aio-create-builds;
|
||||
client_body_buffer_size 128K;
|
||||
client_max_body_size {{$AIO_UPLOAD_MAX_SIZE}};
|
||||
client_body_in_file_only on;
|
||||
|
||||
proxy_pass_request_headers on;
|
||||
proxy_set_header X-FILE $request_body_file;
|
||||
proxy_set_body off;
|
||||
proxy_redirect off;
|
||||
proxy_method GET;
|
||||
proxy_method POST;
|
||||
proxy_pass http://{{$AIO_UPLOAD_HOSTNAME}}:{{$AIO_UPLOAD_PORT}}$request_uri;
|
||||
|
||||
resolver 127.0.0.1;
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
"example-use-local": "node tools/ng-packages-installer overwrite ./tools/examples/shared --debug",
|
||||
"example-use-npm": "node tools/ng-packages-installer restore ./tools/examples/shared",
|
||||
"example-check-local": "node tools/ng-packages-installer check ./tools/examples/shared",
|
||||
"deploy-preview": "scripts/deploy-preview.sh",
|
||||
"deploy-production": "scripts/deploy-to-firebase.sh",
|
||||
"check-env": "yarn ~~check-env",
|
||||
"postcheck-env": "yarn aio-check-local",
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
source "`dirname $0`/../../scripts/ci/env.sh" print
|
||||
|
||||
readonly INPUT_DIR=dist/
|
||||
readonly OUTPUT_FILE=$PROJECT_ROOT/$1
|
||||
(
|
||||
cd $PROJECT_ROOT/aio
|
||||
|
||||
# Build and store the app
|
||||
yarn build
|
||||
mkdir -p "`dirname $OUTPUT_FILE`"
|
||||
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
|
||||
)
|
|
@ -1,58 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# WARNING: NGBUILDS_IO_KEY should NOT be printed.
|
||||
set +x -eu -o pipefail
|
||||
exec 3>&1
|
||||
|
||||
|
||||
readonly INPUT_DIR=dist/
|
||||
readonly OUTPUT_FILE=/tmp/snapshot.tar.gz
|
||||
readonly AIO_BUILDS_DOMAIN=ngbuilds.io
|
||||
readonly UPLOAD_URL=https://$AIO_BUILDS_DOMAIN/create-build/$TRAVIS_PULL_REQUEST/$TRAVIS_PULL_REQUEST_SHA
|
||||
|
||||
readonly SHORT_SHA=$(echo $TRAVIS_PULL_REQUEST_SHA | cut -c1-7)
|
||||
readonly DEPLOYED_URL=https://pr$TRAVIS_PULL_REQUEST-$SHORT_SHA.$AIO_BUILDS_DOMAIN
|
||||
|
||||
readonly skipBuild=$([[ "$1" == "--skip-build" ]] && echo "true" || echo "");
|
||||
readonly relevantChangedFilesCount=$(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -P "^(?:aio|packages)/(?!.*[._]spec\.[jt]s$)" | wc -l)
|
||||
|
||||
(
|
||||
cd "`dirname $0`/.."
|
||||
|
||||
# Do not deploy unless this PR has touched relevant files: `aio/` or `packages/` (except for spec files)
|
||||
if [[ $relevantChangedFilesCount -eq 0 ]]; then
|
||||
echo "Skipping deploy because this PR did not touch any relevant files."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Build the app
|
||||
if [[ "$skipBuild" != "true" ]]; then
|
||||
yarn build
|
||||
fi
|
||||
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
|
||||
|
||||
# Deploy to staging
|
||||
readonly output=$(
|
||||
curl --include --location --request POST --silent --write-out "\nHTTP_CODE: %{http_code}\n" \
|
||||
--header "Authorization: Token $NGBUILDS_IO_KEY" --data-binary "@$OUTPUT_FILE" "$UPLOAD_URL" \
|
||||
| sed 's/\r\n/\n/' \
|
||||
| tee /dev/fd/3
|
||||
)
|
||||
readonly isHidden=$([[ `echo $output | grep 'non-public'` ]] && echo "true" || echo "")
|
||||
readonly httpCode=$(echo "$output" | tail -1 | sed 's/HTTP_CODE: //')
|
||||
|
||||
# Exit with an error if the request failed.
|
||||
# (Ignore 409 failures, which mean trying to re-deploy for the same PR/SHA.)
|
||||
if [[ $httpCode -lt 200 ]] || ([[ $httpCode -ge 400 ]] && [[ $httpCode -ne 409 ]]); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run PWA-score tests (unless the deployment is not public yet;
|
||||
# i.e. it could not be automatically verified).
|
||||
if [[ $httpCode -ne 202 ]] && [[ "$isHidden" != "true" ]]; then
|
||||
yarn test-pwa-score "$DEPLOYED_URL" "$MIN_PWA_SCORE"
|
||||
fi
|
||||
|
||||
# Check the bundle sizes.
|
||||
yarn payload-size
|
||||
)
|
|
@ -25,16 +25,6 @@ if [[ ${CI_MODE:-} == "aio" ]]; then
|
|||
(
|
||||
cd "`dirname $0`/../../aio"
|
||||
yarn build
|
||||
|
||||
# If this is a PR for angular/angular@master or angular/angular@<stable-branch>, deploy a
|
||||
# snapshot for previewing early (if preconditions are met) regardless of the test outcome.
|
||||
if [[ ${TRAVIS_REPO_SLUG} == "angular/angular" ]] &&
|
||||
([[ $TRAVIS_BRANCH == "master" ]] || [[ $TRAVIS_BRANCH == $STABLE_BRANCH ]]) &&
|
||||
[[ $TRAVIS_PULL_REQUEST != "false" ]]; then
|
||||
travisFoldStart "deploy.aio.pr-preview"
|
||||
yarn deploy-preview --skip-build
|
||||
travisFoldEnd "deploy.aio.pr-preview"
|
||||
fi
|
||||
)
|
||||
travisFoldEnd "build.aio"
|
||||
exit 0;
|
||||
|
|
Loading…
Reference in New Issue