You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: jekyll/_cci2/caching.md
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,12 @@ categories: [optimization]
7
7
order: 50
8
8
---
9
9
10
-
Caching is one of the most effective ways to make jobs faster on CircleCI by reusing the data from expensive fetch operations from previous jobs.
10
+
Caching is one of the most effective ways to make jobs faster on CircleCI by reusing the data from expensive fetch operations from previous jobs.
11
11
12
12
* TOC
13
13
{:toc}
14
14
15
-
After an initial job run, future instances of the job will run faster by not redoing work.
15
+
After an initial job run, future instances of the job will run faster by not redoing work.
16
16
17
17

18
18
@@ -36,9 +36,9 @@ Caching keys are simple to configure. The following example updates a cache if i
36
36
## Introduction
37
37
{:.no_toc}
38
38
39
-
Automatic dependency caching is not available in CircleCI 2.0, so it is important to plan and implement your caching strategy to get the best performance. Manual configuration in 2.0 enables more advanced strategies and finer control.
39
+
Automatic dependency caching is not available in CircleCI 2.0, so it is important to plan and implement your caching strategy to get the best performance. Manual configuration in 2.0 enables more advanced strategies and finer control.
40
40
41
-
This document describes the manual caching available, the costs and benefits of a chosen strategy, and tips for avoiding problems with caching. **Note:** The Docker images used for CircleCI 2.0 job runs are automatically cached on the server infrastructure where possible.
41
+
This document describes the manual caching available, the costs and benefits of a chosen strategy, and tips for avoiding problems with caching. **Note:** The Docker images used for CircleCI 2.0 job runs are automatically cached on the server infrastructure where possible.
42
42
43
43
For information about enabling a premium feature to reuse the unchanged layers of your Docker image, see the [Enabling Docker Layer Caching]({{ site.baseurl }}/2.0/docker-layer-caching/) document.
44
44
@@ -49,13 +49,13 @@ A cache stores a hierarchy of files under a key. Use the cache to store data tha
49
49
50
50
Caching is a balance between reliability (not using an out-of-date or inappropriate cache) and getting maximum performance (using a full cache for every build).
51
51
52
-
In general it is safer to preserve reliability than to risk a corrupted build or to build using stale dependencies very quickly. So, the ideal is to balance performance gains while maintaining high reliability.
52
+
In general it is safer to preserve reliability than to risk a corrupted build or to build using stale dependencies very quickly. So, the ideal is to balance performance gains while maintaining high reliability.
53
53
54
-
## Caching Libraries
54
+
## Caching Libraries
55
55
56
56
The dependencies that are most important to cache during a job are the libraries on which your project depends. For example, cache the libraries that are installed with `pip` in Python or `npm` for Node.js. The various language dependency managers, for example `npm` or `pip`, each have their own paths where dependencies are installed. See our Language guides and demo projects for the specifics for your stack: <https://circleci.com/docs/2.0/demo-apps/>.
57
57
58
-
Tools that are not explicitly required for your project are best stored on the Docker image. The Docker image(s) pre-built by CircleCI have tools preinstalled that are generic for building projects using the language the image is focused on. For example the `circleci/ruby:2.4.1` image has useful tools like git, openssh-client, and gzip preinstalled.
58
+
Tools that are not explicitly required for your project are best stored on the Docker image. The Docker image(s) pre-built by CircleCI have tools preinstalled that are generic for building projects using the language the image is focused on. For example the `circleci/ruby:2.4.1` image has useful tools like git, openssh-client, and gzip preinstalled.
59
59
60
60
## Source Caching
61
61
@@ -70,9 +70,9 @@ As in CircleCI 1.0, it is possible and oftentimes beneficial to cache your git r
70
70
- source-v1-{{ .Branch }}-{{ .Revision }}
71
71
- source-v1-{{ .Branch }}-
72
72
- source-v1-
73
-
73
+
74
74
- checkout
75
-
75
+
76
76
- save_cache:
77
77
key: source-v1-{{ .Branch }}-{{ .Revision }}
78
78
paths:
@@ -97,13 +97,13 @@ Even with the narrowest `restore_cache` option ({% raw %}`source-v1-{{ .Branch }
97
97
98
98
That said, it's worth comparing build times with and without source caching; `git clone` is often faster than `restore_cache`.
99
99
100
-
**NOTE**: The built-in `checkout` command disables git's automatic garbage
100
+
**NOTE**: The built-in `checkout` command disables git's automatic garbage
101
101
collection. You might choose to manually run `git gc` in a `run` step prior to
102
102
running `save_cache` to reduce the size of the saved cache.
103
103
104
104
## Writing to the Cache in Workflows
105
105
106
-
Jobs in one workflow can share caches. Note that this makes it possibile to create race conditions in caching across different jobs in workflows.
106
+
Jobs in one workflow can share caches. Note that this makes it possible to create race conditions in caching across different jobs in workflows.
107
107
108
108
Cache is immutable on write: once a cache is written for a particular key like `node-cache-master`, it cannot be written to again. Consider a workflow of 3 jobs, where Job3 depends on Job1 and Job2: {Job1, Job2} -> Job3. They all read and write to the same cache key.
109
109
@@ -166,7 +166,7 @@ For example, you may want to clear the cache in the following scenarios by incre
166
166
167
167
## Basic Example of Dependency Caching
168
168
169
-
The extra control and power in CircleCI 2.0 manual dependency caching requires that you be explicit about what you cache and how you cache it. See the [save cache section](https://circleci.com/docs/2.0/configuration-reference/#save_cache) of the Configuring CircleCI document for additional examples.
169
+
The extra control and power in CircleCI 2.0 manual dependency caching requires that you be explicit about what you cache and how you cache it. See the [save cache section]({{ site.baseurl }}/2.0/configuration-reference/#save_cache) of the Configuring CircleCI document for additional examples.
170
170
171
171
To save a cache of a file or directory, add the `save_cache` step to a job in your `.circleci/config.yml` file:
172
172
@@ -182,7 +182,7 @@ To save a cache of a file or directory, add the `save_cache` step to a job in yo
182
182
The path for directories is relative to the `working_directory` of your job. You can specify an absolute path if you choose.
183
183
184
184
**Note:**
185
-
Unlike the special step [`persist_to_workspace`](https://circleci.com/docs/2.0/configuration-reference/#persist_to_workspace),
185
+
Unlike the special step [`persist_to_workspace`]({{ site.baseurl }}/2.0/configuration-reference/#persist_to_workspace),
186
186
neither `save_cache` nor `restore_cache` support globbing for the `paths` key.
Copy file name to clipboardExpand all lines: jekyll/_cci2/configuration-reference.md
+32-32Lines changed: 32 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -259,7 +259,7 @@ jobs:
259
259
aws_secret_access_key: $ECR_AWS_SECRET_ACCESS_KEY # or project UI envar reference
260
260
```
261
261
262
-
It is possible to reuse [declared commands]({{ site.baseurl }}/2.0/reusing-config/) in a job when using version 2.1. The following example invokes the `sayhello` command.
262
+
It is possible to reuse [declared commands]({{ site.baseurl }}/2.0/reusing-config/) in a job when using version 2.1. The following example invokes the `sayhello` command.
263
263
264
264
265
265
```
@@ -403,7 +403,7 @@ A job that was not executed due to configured rules will show up in the list of
403
403
404
404
**Note:** You must [open a support ticket](https://support.circleci.com/hc/en-us/requests/new) to have a CircleCI Sales representative contact you about enabling this feature on your account for an additional fee.
405
405
406
-
After this feature is added to your paid plan, it is possible to configure CPU and RAM resources for each job as described in the following table. If `resource_class` is not specified or an invalid class is specified, the default `resource_class: medium` will be used. The `resource_class` key is currently only available for use with the `docker` executor.
406
+
After this feature is added to your paid plan, it is possible to configure CPU and RAM resources for each job as described in the following table. If `resource_class` is not specified or an invalid class is specified, the default `resource_class: medium` will be used. The `resource_class` key is currently only available for use with the `docker` executor.
407
407
408
408
Class | vCPUs | RAM
409
409
------------|-----------|------
@@ -414,7 +414,7 @@ large | 4 | 8GB
414
414
xlarge | 8 | 16GB
415
415
{: class="table table-striped"}
416
416
417
-
Java, Erlang and any other languages that introspect the `/proc` directory for information about CPU count may require additional configuration to prevent them from slowing down when using the CircleCI 2.0 resource class feature. Programs with this issue may request 32 CPU cores and run slower than they would when requesting one core. Users of languages with this issue should pin their CPU count to their guaranteed CPU resources.
417
+
Java, Erlang and any other languages that introspect the `/proc` directory for information about CPU count may require additional configuration to prevent them from slowing down when using the CircleCI 2.0 resource class feature. Programs with this issue may request 32 CPU cores and run slower than they would when requesting one core. Users of languages with this issue should pin their CPU count to their guaranteed CPU resources.
418
418
419
419
#### **`steps`**
420
420
@@ -647,13 +647,13 @@ workflows:
647
647
jobs:
648
648
- job_with_optional_custom_checkout:
649
649
custom_checkout: \"any non-empty string is truthy\"
650
-
- job_with_optional_custom_checkout
650
+
- job_with_optional_custom_checkout
651
651
```
652
652
653
653
##### **`checkout`**
654
654
655
655
Special step used to check out source code to the configured `path` (defaults to the `working_directory`).
656
-
The reason this is a special step is because it is more of a helper function designed to make checking out code easy for you. If you require doing git over HTTPS you should not use this step as it configures git to checkout over ssh.
656
+
The reason this is a special step is because it is more of a helper function designed to make checking out code easy for you. If you require doing git over HTTPS you should not use this step as it configures git to checkout over ssh.
657
657
658
658
Key | Required | Type | Description
659
659
----|-----------|------|------------
@@ -720,7 +720,7 @@ Template | Description
720
720
{% raw %}`{{ .Revision }}`{% endraw %} | The VCS revision currently being built.
721
721
{% raw %}`{{ .CheckoutKey }}`{% endraw %} | The SSH key used to checkout the repo.
722
722
{% raw %}`{{ .Environment.variableName }}`{% endraw %} | The environment variable `variableName` (supports any environment variable [exported by CircleCI](https://circleci.com/docs/2.0/env-vars/#circleci-environment-variable-descriptions) or added to a specific [Context](https://circleci.com/docs/2.0/contexts)—not any arbitrary environment variable).
723
-
{% raw %}`{{ checksum "filename" }}`{% endraw %} | A base64 encoded SHA256 hash of the given filename's contents. This should be a file committed in your repo and may also be referenced as a path that is absolute or relative from the current working directory. Good candidates are dependency manifests, such as `package.json`, `pom.xml` or `project.clj`. It's important that this file does not change between `restore_cache` and `save_cache`, otherwise the cache will be saved under a cache key different than the one used at `restore_cache` time.
723
+
{% raw %}`{{ checksum "filename" }}`{% endraw %} | A base64 encoded SHA256 hash of the given filename's contents. This should be a file committed in your repo and may also be referenced as a path that is absolute or relative from the current working directory. Good candidates are dependency manifests, such as `package.json`, `pom.xml` or `project.clj`. It's important that this file does not change between `restore_cache` and `save_cache`, otherwise the cache will be saved under a cache key different than the one used at `restore_cache` time.
724
724
{% raw %}`{{ epoch }}`{% endraw %} | The current time in seconds since the unix epoch.
725
725
{% raw %}`{{ arch }}`{% endraw %} | The OS and CPU information. Useful when caching compiled binaries that depend on OS and CPU architecture, for example, `darwin amd64` versus `linux i386/32-bit`.
726
726
{: class="table table-striped"}
@@ -927,25 +927,25 @@ baz
927
927
- build/*
928
928
```
929
929
930
-
The `paths` list uses `Glob` from Go, and the pattern matches [filepath.Match](https://golang.org/pkg/path/filepath/#Match).
931
-
932
-
```
933
-
pattern:
934
-
{ term }
935
-
term:
936
-
'*' matches any sequence of non-Separator characters
937
-
'?' matches any single non-Separator character
938
-
'[' [ '^' ] { character-range }
939
-
']' character class (must be non-empty)
940
-
c matches character c (c != '*', '?', '\\', '[')
941
-
'\\' c matches character c
942
-
character-range:
943
-
c matches character c (c != '\\', '-', ']')
944
-
'\\' c matches character c
945
-
lo '-' hi matches character c for lo <= c <= hi
946
-
```
947
-
948
-
The Go documentation states that the pattern may describe hierarchical names such as `/usr/*/bin/ed` (assuming the Separator is '/'). **Note:** Everything must be relative to the work space root directory.
930
+
The `paths` list uses `Glob` from Go, and the pattern matches [filepath.Match](https://golang.org/pkg/path/filepath/#Match).
931
+
932
+
```
933
+
pattern:
934
+
{ term }
935
+
term:
936
+
'*' matches any sequence of non-Separator characters
937
+
'?' matches any single non-Separator character
938
+
'[' [ '^' ] { character-range }
939
+
']' character class (must be non-empty)
940
+
c matches character c (c != '*', '?', '\\', '[')
941
+
'\\' c matches character c
942
+
character-range:
943
+
c matches character c (c != '\\', '-', ']')
944
+
'\\' c matches character c
945
+
lo '-' hi matches character c for lo <= c <= hi
946
+
```
947
+
948
+
The Go documentation states that the pattern may describe hierarchical names such as `/usr/*/bin/ed` (assuming the Separator is '/'). **Note:** Everything must be relative to the work space root directory.
949
949
950
950
##### **`attach_workspace`**
951
951
@@ -1021,7 +1021,7 @@ version | Y | String | Should currently be `2`
1021
1021
A unique name for your workflow.
1022
1022
1023
1023
#### **`triggers`**
1024
-
Specifies which triggers will cause this workflow to be executed. Default behavior is to trigger the workflow when pushing to a branch.
1024
+
Specifies which triggers will cause this workflow to be executed. Default behavior is to trigger the workflow when pushing to a branch.
1025
1025
1026
1026
Key | Required | Type | Description
1027
1027
----|-----------|------|------------
@@ -1055,7 +1055,7 @@ cron | Y | String | See the [crontab man page](http://pubs.opengroup.org/onlinep
0 commit comments