Skip to content

Commit

Permalink
fix: Remove existing tar file when cache always is set to true (#60)
Browse files Browse the repository at this point in the history
Co-authored-by: James Ebentier <jebentier@invoca.com>
  • Loading branch information
gencer and jebentier committed May 18, 2023
1 parent 5bea241 commit 4a89b30
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ steps:
- label: ':sparkles: Lint'
plugins:
- plugin-linter#v2.0.0:
id: gencer/cache
id: nienbo/cache
- label: ':shell: Shellcheck'
plugins:
- shellcheck#v1.1.2:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.4.14

+ Remove existing tar file when cache **always** is set to `true`. See #59 by @ingcsmoreno

# v2.4.13

+ Add `save-cache` property to s3 cache. @ingcsmoreno
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ MIT License

Copyright (c) 2019 Daniel Thorpe
Copyright (c) 2020-2022 Gencer W. Genç
Copyright (c) 2023 Nienbo Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
62 changes: 45 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cache Buildkite Plugin [![Version badge](https://img.shields.io/badge/cache-v2.4.13-blue?style=flat-square)](https://buildkite.com/plugins) [![CI](https://github.com/nienbo/cache-buildkite-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/nienbo/cache-buildkite-plugin/actions/workflows/ci.yml) <!-- omit in toc -->
# Cache Buildkite Plugin [![Version badge](https://img.shields.io/badge/cache-v2.4.14-blue?style=flat-square)](https://buildkite.com/plugins) [![CI](https://github.com/nienbo/cache-buildkite-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/nienbo/cache-buildkite-plugin/actions/workflows/ci.yml) <!-- omit in toc -->

### Tarball, Rsync & S3 Cache Kit for Buildkite. Supports Linux, macOS and Windows* <!-- omit in toc -->

Expand Down Expand Up @@ -46,6 +46,7 @@ Plus, In addition to tarball & rsync, we also do not re-create another tarball f
- [Sharing caches between pipelines](#sharing-caches-between-pipelines)
- [Keep the cache file between jobs/builds](#keep-the-cache-file-between-jobsbuilds)
- [Auto deletion old caches](#auto-deletion-old-caches)
- [Always upload Cache](#always-upload-cache)
- [Globs on paths](#globs-on-paths)
- [Roadmap](#roadmap)

Expand Down Expand Up @@ -82,7 +83,7 @@ S3 backend uses **AWS CLI** v**1** or v**2** to copy and download from/to S3 buc
```yml
steps:
- plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand Down Expand Up @@ -112,7 +113,7 @@ Use `endpoint` and `region` fields to pass host and region parameters to be able
```yml
steps:
- plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand Down Expand Up @@ -148,7 +149,7 @@ Enabling this interoperability in Google Cloud Storage will generate the respect
```yml
steps:
- plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand Down Expand Up @@ -203,7 +204,7 @@ You can also use rsync to store your files using the `rsync` backend. Files will
```yml
steps:
- plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: rsync
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand All @@ -228,7 +229,7 @@ You can also use tarballs to store your files using the `tarball` backend. Files
```yml
steps:
- plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: tarball
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand Down Expand Up @@ -273,7 +274,7 @@ Along with lock files, you can calculate directory that contains multiple files
```yml
steps:
- plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: node # or node-16
backend: tarball # Optional. Default `backend` is already set to `tarball`
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum './app/javascript' }}" # Calculate whole 'app/javascript' recursively
Expand All @@ -299,7 +300,7 @@ You can skip caching on Pull Requests (Merge Requests) by simply adding `pr: fal
```yml
steps:
- plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand Down Expand Up @@ -355,8 +356,8 @@ ruby-cache: &ruby-cache
- 'bundler/vendor'

all-plugins: &all-plugins
- nienbo/cache#v2.4.13: *node-cache
- nienbo/cache#v2.4.13: *ruby-cache
- nienbo/cache#v2.4.14: *node-cache
- nienbo/cache#v2.4.14: *ruby-cache
- docker#v3.7.0: ~ # Use your config here

steps:
Expand All @@ -381,7 +382,7 @@ steps:
key: jest
command: yarn test --runInBand
plugins:
- nienbo/cache#v2.4.13: # Define cache *before* docker plugins.
- nienbo/cache#v2.4.14: # Define cache *before* docker plugins.
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand All @@ -406,7 +407,7 @@ steps:
key: jest
command: yarn test --runInBand
plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand Down Expand Up @@ -437,7 +438,7 @@ steps:
key: jest
command: yarn test --runInBand
plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand All @@ -463,7 +464,7 @@ steps:
key: jest
command: yarn test --runInBand
plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand All @@ -488,7 +489,7 @@ steps:
key: jest
command: yarn test --runInBand
plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand All @@ -513,7 +514,7 @@ steps:
key: jest
command: yarn test --runInBand
plugins:
- nienbo/cache#v2.4.13:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
Expand All @@ -534,6 +535,33 @@ For tarballs, To keep caches and delete them in _for example_ 7 days, use `max:

For S3, As long as you use Lifcecycle policy (AWS and Scaleway supports this feature) you will only have caches for number of days you specify in your Lifecycle policy terms. This will allows you to invalidate old caches and save some storage costs.

## Always upload Cache

There are some cases where you want to process the cache no matter of what. In this scenario, use `always` option and set it to `true` (Defaults to `false`):

See #46 and #59 for details.

```yaml
steps:
- name: ':jest: Run tests'
key: jest
command: yarn test --runInBand
plugins:
- nienbo/cache#v2.4.14:
id: ruby # or ruby-3.0
backend: s3
key: "v1-cache-{{ id }}-{{ runner.os }}-{{ checksum 'Gemfile.lock' }}"
restore-keys:
- 'v1-cache-{{ id }}-{{ runner.os }}-'
- 'v1-cache-{{ id }}-'
compress: 2 # fast compression.
always: true # Optional. Always process the cache and upload. Defaults to `false`
s3:
bucket: s3-bucket
paths:
- bundle/vendor
```
## Globs on paths
You can use glob pattern in paths (to be cached) after `v2.1.x`
Expand All @@ -544,4 +572,4 @@ You can use glob pattern in paths (to be cached) after `v2.1.x`
+ BitPaket Easy Storage support.
+ Azure Blob Storage support.

Copyright (C) 2023 Gencer W. Genç.
Copyright © 2023 Nienbo Corporation. All rights reserved.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.13
2.4.14
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
- '.:/plugin:ro'
lint:
image: buildkite/plugin-linter
command: ['--id', 'gencer/cache']
command: ['--id', 'nienbo/cache']
volumes:
- '.:/plugin:ro'
shellcheck:
Expand Down

0 comments on commit 4a89b30

Please sign in to comment.