summaryrefslogtreecommitdiffstats
path: root/screwdriver.yaml
blob: 1bf5804e0f6705062e6aceb63ef788426cc4600c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
---
cache:
   job:
       build-vespa: [/main_job_cache]

jobs:
  build-vespa:
    requires: [~pr, ~commit]
    image: vespaengine/vespa-build-centos7:current
    annotations:
      screwdriver.cd/cpu: 7
      screwdriver.cd/ram: 16
      screwdriver.cd/disk: HIGH
      screwdriver.cd/timeout: 60

    environment:
      USER_SHELL_BIN: bash
      LOCAL_MVN_REPO: "/tmp/vespa/mvnrepo"
      VESPA_MAVEN_EXTRA_OPTS: "-Dmaven.repo.local=/tmp/vespa/mvnrepo -Dmaven.javadoc.skip=true -Dmaven.source.skip=true"
      CCACHE_TMP_DIR: "/tmp/ccache_tmp"
      CCACHE_DATA_DIR: "/tmp/vespa/ccache"
      MAIN_CACHE_FILE: "/main_job_cache/vespa.tar"

    steps:
      - inspect: |
          set -x
          env | grep -v TOKEN
          cat /proc/cpuinfo
          cat /proc/meminfo
          df -h
          uname -a
          rpm -qa | grep "vespa"
      - restore-cache: |
          (cd /tmp && if [[ -f $MAIN_CACHE_FILE ]]; then tar xf $MAIN_CACHE_FILE; fi)

          mkdir -p $CCACHE_DATA_DIR
          mkdir -p $CCACHE_TMP_DIR

          export CCACHE_DIR=$CCACHE_DATA_DIR

          rm -f $CCACHE_DIR/ccache.conf
          ccache -M 20G
          ccache -o log_file=$SD_ARTIFACTS_DIR/ccache_log.txt
          ccache -o temporary_dir=$CCACHE_TMP_DIR
          ccache -p
          ccache -z

      - compile: |
          screwdriver/build-vespa.sh

      - save-cache: |
          if [[ -z "$SD_PULL_REQUEST" ]]; then
            # Remove what we have produced
            rm -rf $LOCAL_MVN_REPO/com/yahoo
            rm -rf $LOCAL_MVN_REPO/ai/vespa

            # Tar toghether the /tmp/vespa folder containing ccache and cleaned mvn repo
            mkdir -p $(dirname $MAIN_CACHE_FILE)
            (cd /tmp && tar cf $MAIN_CACHE_FILE vespa)

            # Wipe the cache if we exceed 2GB to avoid pulling and pusing too large files
            if (( $(stat --format='%s' $MAIN_CACHE_FILE) > $(( 2*1000*1000*1000 )) )); then
              tar cf $MAIN_CACHE_FILE --files-from=/dev/null;
              echo "Cleaning cache file. $MAIN_CACHE_FILE is now $(stat --format='%s' $MAIN_CACHE_FILE) bytes."
            fi
          fi

      - inspect-after: |
          du -sh /tmp/vespa/*
          ls -la /main_job_cache || true
          df -h