Skip to content

Commit

Permalink
collect historical download data
Browse files Browse the repository at this point in the history
  • Loading branch information
garyverhaegen-da committed Jul 4, 2019
1 parent a5fdc51 commit 2bbc5a4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
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 > $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
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

0 comments on commit 2bbc5a4

Please sign in to comment.