daml/azure-cron.yml

116 lines
4.5 KiB
YAML
Raw Normal View History

2019-05-14 15:25:02 +03:00
# Azure Pipelines file, see https://aka.ms/yaml
schedules:
- cron: "0 * * * *"
displayName: hourly cron
branches:
include:
- master
always: true
2019-05-14 15:25:02 +03:00
jobs:
- job: latest_webide
timeoutInMinutes: 20
pool:
name: 'linux-pool'
steps:
- checkout: self
- bash: ci/check-update-build-webide.sh
displayName: 'Check for updated SDK and build webide with latest version'
env:
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
2019-05-14 15:25:02 +03:00
- job: docs
timeoutInMinutes: 50
2019-05-14 15:25:02 +03:00
pool:
name: 'linux-pool'
steps:
- checkout: self
- bash: ci/dev-env-install.sh
displayName: 'Build/Install the Developer Environment'
- bash: ci/configure-bazel.sh
displayName: 'Configure Bazel'
env:
IS_FORK: $(System.PullRequest.IsFork)
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
- bash: |
set -euo pipefail
CUR_SHA=$(git rev-parse HEAD)
robustly_download_nix_pkgs() {
# In recent commits, this is part of the dev-env-install script.
# However, we have to copy it here to apply it to older versions.
NIX_FAILED=0
for i in `seq 10`; do
NIX_FAILED=0
nix-build nix -A tools -A cached >$LOG 2>&1 || NIX_FAILED=1
if [[ $NIX_FAILED -ne 0 ]] && [[ $(tail -n 3 $LOG) == *"unexpected end-of-file"* ]]; then
echo " Restarting nix-build due to failed cache download"
continue
fi
break
done
if [[ $NIX_FAILED -ne 0 ]]; then
exit 1
fi
}
2019-05-14 15:25:02 +03:00
echo "Loading dev-env..."
eval "$(dev-env/bin/dade-assist)"
echo "Building docs listing"
DOCDIR=$(Build.StagingDirectory)/docs
mkdir -p $DOCDIR
LOG=$(Build.StagingDirectory)/log.txt
RELEASES=$(curl https://api.github.com/repos/digital-asset/daml/releases -s | jq -r '. | map(select(.prerelease == false)) | map(.tag_name)[]')
LATEST=$(echo $RELEASES | awk '{print $1}')
JSON_BODY=$(echo $RELEASES | sed -e 's/ /\n/g' | sed -e 's/v\(.*\)/"\1": "\1",'/g)
2019-05-14 15:25:02 +03:00
echo "Building latest docs: $LATEST"
git checkout $LATEST >$LOG 2>&1
robustly_download_nix_pkgs
2019-05-14 15:25:02 +03:00
bazel build //docs:docs >$LOG 2>&1
tar xzf bazel-genfiles/docs/html.tar.gz --strip-components=1 -C $DOCDIR >$LOG 2>&1
# We need to overwrite the versions.json compiled by the build
echo "{${JSON_BODY%,}}" | jq '.' > $DOCDIR/versions.json
mkdir -p $DOCDIR/${LATEST#v}
tar xzf bazel-genfiles/docs/html.tar.gz --strip-components=1 -C $DOCDIR/${LATEST#v} >$LOG 2>&1
for version in $(echo $RELEASES | sed -e 's/ /\n/g' | sed '1d'); do
echo "Building older docs: $version"
git checkout $version >$LOG 2>&1
robustly_download_nix_pkgs
2019-05-14 15:25:02 +03:00
bazel build //docs:docs >$LOG 2>&1
mkdir -p $DOCDIR/${version#v}
tar xzf bazel-genfiles/docs/html.tar.gz --strip-components=1 -C $DOCDIR/${version#v} >$LOG 2>&1
done
git checkout $CUR_SHA
echo "Pushing to S3 bucket..."
aws s3 sync $DOCDIR \
s3://docs-daml-com/ \
--delete \
--acl public-read \
--exclude '*.doctrees/*' \
--exclude '*.buildinfo'
echo "Refreshing CloudFront cache..."
aws cloudfront create-invalidation \
--distribution-id E1U753I56ERH55 \
--paths '/*'
2019-05-14 15:25:02 +03:00
echo "Done."
env:
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
2019-05-14 15:25:02 +03:00
- task: PublishPipelineArtifact@0
condition: always()
inputs:
targetPath: $(Build.StagingDirectory)/log.txt
artifactName: "Logs"
- bash: |
set -euo pipefail
MESSAGE=$(git log --pretty=format:%s -n1)
curl -XPOST \
-i \
-H 'Content-type: application/json' \
--data "{\"text\":\"<!here> *FAILED* Daily Docs: <https://dev.azure.com/digitalasset/daml/_build/results?buildId=$(Build.BuildId)|$MESSAGE>\n\"}" \
$(Slack.URL)
condition: and(failed(), eq(variables['Build.SourceBranchName'], 'master'))