Skip to content

Commit

Permalink
Merge pull request #6 from bcressey/more-cache-fixes
Browse files Browse the repository at this point in the history
try to improve caching behavior
  • Loading branch information
bcressey authored Jun 19, 2024
2 parents c98aea0 + 9d3d3bd commit aa1d20d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 41 deletions.
29 changes: 7 additions & 22 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
name: "Node setup"
description: "Performs setup for caching and other common needs."
inputs:
perform-cache-cleanup:
description: "Whether to perform cache cleanup"
required: false
default: false
type: boolean
runs:
using: "composite"
steps:
- run: |
echo "OS_ARCH=`uname -m`" >> $GITHUB_ENV
sudo apt -y install build-essential openssl libssl-dev pkg-config liblz4-tool
shell: bash
- uses: actions/cache@v4
# Cache `cargo-make`, `cargo-cache`
- uses: actions/cache/restore@v4
# Restore most recent cache if available.
with:
path: |
~/.cargo
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}
- uses: actions/cache@v4
# Cache Rust dependencies
with:
path: |
.cargo
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}-${{ hashFiles('sources/Cargo.lock') }}
- uses: actions/cache@v4
# Cache Go dependencies
with:
path: |
.gomodcache
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}-${{ hashFiles('sources/**/go.sum') }}
build/external-kits
build/rpms
build/state
target
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}
- run: cargo install cargo-make
shell: bash
- if: ${{ inputs.perform-cache-cleanup }}
run: cargo install --no-default-features --features ci-autoclean cargo-cache
shell: bash
46 changes: 27 additions & 19 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
# This workflow caches crate dependencies, build tools, and external kits.
# This workflow caches external dependencies, build tools, and the most recent artifacts.
# The cache is only usable by workflows started from pull requests against the develop branch.
name: CacheDepsAndTools
name: CacheLatest
on:
push:
branches: [develop]
paths:
- '.github/**'
- 'sources/Cargo.lock'
- 'sources/**/go.sum'
- 'Twoliter.toml'
- 'Twoliter.lock'
- 'Makefile'
jobs:
cache:
if: github.repository == 'bottlerocket-os/bottlerocket-core-kit'
runs-on:
group: bottlerocket
labels: bottlerocket_ubuntu-latest_8-core
continue-on-error: true
labels: bottlerocket_ubuntu-latest_32-core
steps:
- uses: actions/checkout@v4
- name: Preflight step to set up the runner
uses: ./.github/actions/setup-node
with:
perform-cache-cleanup: true
# Install dependencies for twoliter and cargo-make.
- run: |
echo "OS_ARCH=`uname -m`" >> $GITHUB_ENV
sudo apt -y install build-essential openssl libssl-dev pkg-config liblz4-tool
shell: bash
# Install cargo-make.
- run: cargo install cargo-make
shell: bash
# This installs twoliter.
- run: make prep
# This fetches any external kit dependencies.
- run: make fetch
# This cleans the existing project local caches.
- run: make twoliter purge-cache
# This fetches Rust crate and Go module dependencies.
- run: make twoliter fetch
# This cleans the cargo cache in ~/.cargo
- run: cargo-cache
# This builds the current packages and kits.
- run: make ARCH=x86_64
- run: make ARCH=aarch64
# This caches the reusable artifacts for future CI runs.
- uses: actions/cache/save@v4
# Save Rust dependencies
with:
path: |
~/.cargo
.cargo
.gomodcache
build/external-kits
build/rpms
build/state
target
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ KIT ?= bottlerocket-core-kit
ARCH ?= $(shell uname -m)
VENDOR ?= bottlerocket

export GO_MODULES = ecs-gpu-init host-ctr

all: build

prep:
Expand Down

0 comments on commit aa1d20d

Please sign in to comment.