-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathdeps_fetch.yml
71 lines (66 loc) · 2.07 KB
/
deps_fetch.yml
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
---
# deps_fetch stage
# Contains jobs which fetch go dependencies, in order
# to reuse them in further jobs that need them.
.retrieve_linux_go_deps:
- mkdir -p $GOPATH/pkg/mod && tar xzf modcache.tar.gz -C $GOPATH/pkg/mod
- rm -f modcache.tar.gz
.retrieve_linux_go_tools_deps:
- mkdir -p $GOPATH/pkg/mod && tar xzf modcache_tools.tar.gz -C $GOPATH/pkg/mod
- rm -f modcache_tools.tar.gz
.cache_policy:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
POLICY: pull-push
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
variables:
POLICY: pull
go_deps:
stage: deps_fetch
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
tags: ["arch:amd64"]
needs: ["setup_agent_version"]
extends: .cache_policy
script:
# If the cache already contains the dependencies, don't redownload them
# but still provide the artifact that's expected for the other jobs to run
- if [ -f modcache.tar.gz ]; then exit 0; fi
- source /root/.bashrc
- inv -e deps --verbose
- cd $GOPATH/pkg/mod/ && tar czf $CI_PROJECT_DIR/modcache.tar.gz .
artifacts:
expire_in: 1 day
paths:
- $CI_PROJECT_DIR/modcache.tar.gz
cache:
- key:
files:
- ./**/go.mod
prefix: "go_deps"
paths:
- modcache.tar.gz
retry: 1
go_tools_deps:
stage: deps_fetch
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
tags: ["arch:amd64"]
needs: ["setup_agent_version"]
extends: .cache_policy
script:
- if [ -f modcache_tools.tar.gz ]; then exit 0; fi
- source /root/.bashrc
- inv -e download-tools
- cd $GOPATH/pkg/mod/ && tar czf $CI_PROJECT_DIR/modcache_tools.tar.gz .
artifacts:
expire_in: 1 day
paths:
- $CI_PROJECT_DIR/modcache_tools.tar.gz
cache:
- key:
files:
- ./**/go.mod
prefix: "go_tools_deps"
paths:
- modcache_tools.tar.gz
retry: 1