Compare commits

...

3 Commits

Author SHA1 Message Date
evandrocoan
2af26e0e54
Merge 75e87520221a2cba393bcb57e7246cb99eeb576b into 36f1e144e1c8edb0a652766b484448563d8baf46 2025-01-13 02:52:38 +00:00
Tobbe Lundberg
36f1e144e1
docs: Make the "always save prime numbers" example more clear (#1525)
Some checks failed
Code scanning - action / CodeQL-Build (push) Has been cancelled
Licensed / Licensed (push) Has been cancelled
Tests / build (macOS-latest) (push) Has been cancelled
Tests / build (ubuntu-latest) (push) Has been cancelled
Tests / build (windows-latest) (push) Has been cancelled
Tests / test-save (macOS-latest) (push) Has been cancelled
Tests / test-save (ubuntu-latest) (push) Has been cancelled
Tests / test-save (windows-latest) (push) Has been cancelled
Tests / test-proxy-save (push) Has been cancelled
Tests / test-restore (macOS-latest) (push) Has been cancelled
Tests / test-restore (ubuntu-latest) (push) Has been cancelled
Tests / test-restore (windows-latest) (push) Has been cancelled
Tests / test-proxy-restore (push) Has been cancelled
2025-01-09 23:36:56 +00:00
evandrocoan
75e8752022 Multiple OS with a build matrix 2022-11-21 22:20:22 -03:00
2 changed files with 79 additions and 8 deletions

View File

@ -621,6 +621,75 @@ whenever possible:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
```
### Multiple OS with a build matrix
```yml
name: CI
on: [push, pull_request]
jobs:
tests:
name: Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
SEP: /
PIP_WHEELS_DIR: ~/.cache/pip
CARGO_INDEX_DIR: ~/.cargo/git
CARGO_REGISTRY_DIR: ~/.cargo/registry
- os: macos-latest
SEP: /
PIP_WHEELS_DIR: ~/Library/Caches/pip
CARGO_INDEX_DIR: ~/.cargo/git
CARGO_REGISTRY_DIR: ~/.cargo/registry
- os: windows-latest
SEP: \
PIP_WHEELS_DIR: ~\AppData\Local\pip\Cache
CARGO_INDEX_DIR: C:\Rust\.cargo\git
CARGO_REGISTRY_DIR: C:\Rust\.cargo\registry
# Keep running all matrices if something fail
fail-fast: false
steps:
- name: Cache pip wheels
uses: actions/cache@v1
with:
path: ${{ matrix.PIP_WHEELS_DIR }}
key: ${{ runner.os }}-pip-wheels-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/setup.py') }}-14-
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ${{ matrix.CARGO_INDEX_DIR }}
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-14-
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ${{ matrix.CARGO_REGISTRY_DIR }}
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-14-
- name: Cache cargo target
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.toml') }}-14-
- name: Run on Windows
if: matrix.os == 'windows-latest'
run: echo Windows
- name: Run on Linux
if: matrix.os == 'ubuntu-latest'
run: echo Linux
```
## Scala - SBT
```yaml

View File

@ -79,8 +79,10 @@ To avoid saving a cache that already exists, the `cache-hit` output from a resto
The `cache-primary-key` output from the restore step should also be used to ensure
the cache key does not change during the build if it's calculated based on file contents.
Here's an example where we imagine we're calculating a lot of prime numbers and want to cache them:
```yaml
name: Always Caching Primes
name: Always Caching Prime Numbers
on: push
@ -91,23 +93,23 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Restore cached Primes
id: cache-primes-restore
- name: Restore cached Prime Numbers
id: cache-prime-numbers-restore
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-primes
key: ${{ runner.os }}-prime-numbers
path: |
path/to/dependencies
some/other/dependencies
# Intermediate workflow steps
- name: Always Save Primes
id: cache-primes-save
if: always() && steps.cache-primes-restore.outputs.cache-hit != 'true'
- name: Always Save Prime Numbers
id: cache-prime-numbers-save
if: always() && steps.cache-prime-numbers-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-primes-restore.outputs.cache-primary-key }}
key: ${{ steps.cache-prime-numbers-restore.outputs.cache-primary-key }}
path: |
path/to/dependencies
some/other/dependencies