Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collect historical download data #2003

Merged
merged 1 commit into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions azure-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,24 @@ jobs:
fi
env:
MARKETPLACE_TOKEN: $(VSCODE_MARKETPLACE_TOKEN)

- job: download_stats
timeoutInMinutes: 10
pool:
name: "linux-pool"
steps:
- checkout: self
- bash: |
set -euo pipefail

eval "$(dev-env/bin/dade-assist)"

STATS=$(mktemp)
curl https://api.github.com/repos/digital-asset/daml/releases -s | gzip -9 > $STATS

GCS_KEY=$(mktemp)
echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > $GCS_KEY
gcloud auth activate-service-account --key-file=$GCS_KEY
BOTO_CONFIG=/dev/null gsutil cp $STATS gs://daml-data/downloads/$(date -u +%Y%m%d_%H%M%SZ).json.gz
env:
GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)
34 changes: 34 additions & 0 deletions infra/data_bucket.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

resource "google_storage_bucket" "data" {
project = "${local.project}"
name = "daml-data"
labels = "${local.labels}"

# SLA is enough for a cache and is cheaper than MULTI_REGIONAL
# see https://cloud.google.com/storage/docs/storage-classes
storage_class = "REGIONAL"

# Use a normal region since the storage_class is regional
location = "${local.region}"
}

resource "google_storage_bucket_acl" "data" {
bucket = "${google_storage_bucket.data.name}"

role_entity = [
"OWNER:project-owners-${data.google_project.current.number}",
"OWNER:project-editors-${data.google_project.current.number}",
"READER:project-viewers-${data.google_project.current.number}",
]
}

// allow rw access for CI writer (see writer.tf)
resource "google_storage_bucket_iam_member" "data" {
bucket = "${google_storage_bucket.data.name}"

# https://cloud.google.com/storage/docs/access-control/iam-roles
role = "roles/storage.objectAdmin"
member = "serviceAccount:${google_service_account.writer.email}"
}
4 changes: 4 additions & 0 deletions infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ provider "google-beta" {
region = "us-east4"
}

data "google_project" "current" {
project_id = "${local.project}"
}

locals {
labels = {
cost-allocation = "daml-language"
Expand Down