Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: improve caching #2329

Merged
merged 42 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0bba026
ci: fix docker cache mounts
shumkov Nov 13, 2024
ea76396
Merge branch 'refs/heads/v1.6-dev' into ci/fix-docker-cache-mounts
shumkov Nov 13, 2024
4124bc3
ci: switch more to gha
shumkov Nov 13, 2024
fad022e
Merge branch 'v1.6-dev' into ci/fix-docker-cache-mounts
shumkov Nov 13, 2024
83f6659
ci: fix artifact key
shumkov Nov 13, 2024
6a03bd3
ci: try using download artifact
shumkov Nov 14, 2024
98232ef
ci: use artifacts
shumkov Nov 14, 2024
bf3fb89
ci: remove unnecessary archive step
shumkov Nov 14, 2024
9c79aec
ci: rename artifact
shumkov Nov 14, 2024
a12d16d
ci: fix get modified files
shumkov Nov 14, 2024
30111be
ci: fix get modified files again
shumkov Nov 14, 2024
8aa56d9
ci: fix download certificates
shumkov Nov 14, 2024
5eab16c
docs: add comment
shumkov Nov 14, 2024
71bddba
ci: layer to registry, disable sccache
shumkov Nov 14, 2024
84852e4
ci: fix workflow
shumkov Nov 14, 2024
fe9f565
ci: fix librocksdb cache
shumkov Nov 14, 2024
c9dd655
ci: fix docker layer cache
shumkov Nov 14, 2024
a957dd0
ci: back to ECR
shumkov Nov 14, 2024
e338503
ci: fix js artifacts
shumkov Nov 14, 2024
b4f6d72
build: remove target cache to enable chief
shumkov Nov 14, 2024
b0795d0
build: fix build-js
shumkov Nov 14, 2024
860a04c
build: fix chief
shumkov Nov 14, 2024
55bb2ed
build: fix chief 2
shumkov Nov 14, 2024
c77aed5
build: pass target and features to chef
shumkov Nov 14, 2024
3b1cf97
build: trying to fix drive build
shumkov Nov 14, 2024
959016d
build: remove target
shumkov Nov 14, 2024
febf93e
build: remove target and s3 for layercache
shumkov Nov 14, 2024
2e34367
ci: enable sccache
shumkov Nov 14, 2024
3321e15
ci: remove target in the same layer
shumkov Nov 14, 2024
7cb68cc
ci: fix cache mounts and remove unnecessary steps
shumkov Nov 14, 2024
3b65eeb
ci: fix RUNNER_TEMP
shumkov Nov 14, 2024
163323c
ci: fix region and home
shumkov Nov 14, 2024
9cdea04
ci: fix cache from
shumkov Nov 14, 2024
732b2b4
chore: kick off CI
shumkov Nov 14, 2024
7aa6617
chore: add new lines
shumkov Nov 14, 2024
cdf633e
ci: fix dashmate e2e tests
shumkov Nov 15, 2024
7b7e5aa
ci: fix restore key
shumkov Nov 15, 2024
9869252
ci: remove commented code
shumkov Nov 15, 2024
72539f4
ci: cache to base manifest only on base branch push
shumkov Nov 18, 2024
cd35f65
ci: fix manifestNames is not defined
shumkov Nov 18, 2024
f078ec0
chore: fix security vulnerability
shumkov Nov 18, 2024
143f980
ci: we don't want to remove artifacts
shumkov Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 93 additions & 27 deletions .github/actions/docker/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ inputs:
description: User name to use when pushing images to Docker Hub
dockerhub_token:
description: Docker Hub token to use
cache_mounts:
description: Load cache mounts cache
default: |
cargo_registry_index
cargo_registry_cache
cargo_git
cargo_profile:
description: Cargo build profile, i.e release or dev
default: dev
Expand Down Expand Up @@ -69,12 +63,12 @@ runs:
[worker.oci]
gc = false

- name: Load Docker mount cache
uses: dcginfra/buildkit-cache-dance/inject@s5cmd
if: ${{ inputs.cache_mounts != '' }}
with:
bucket: ${{ inputs.bucket }}
mounts: ${{ inputs.cache_mounts }}
# - name: Load Docker mount cache
# uses: dcginfra/buildkit-cache-dance/inject@s5cmd
# if: ${{ inputs.cache_mounts != '' }}
# with:
# bucket: ${{ inputs.bucket }}
# mounts: ${{ inputs.cache_mounts }}
shumkov marked this conversation as resolved.
Show resolved Hide resolved

- name: Set Docker tags and labels from image tag
id: docker_meta
Expand All @@ -85,37 +79,109 @@ runs:
type=semver,pattern={{version}},value=${{inputs.image_version}},enable=${{ inputs.image_version != '' }}
type=sha,format=long,enable=${{ inputs.image_version == '' }}

- name: Configure docker layer cache
uses: ./.github/actions/s3-layer-cache-settings
id: layer_cache_settings
# - name: Configure docker layer cache
# uses: ./.github/actions/s3-layer-cache-settings
# id: layer_cache_settings
# with:
# name: ${{ inputs.image_name }}
# bucket: ${{ inputs.bucket }}

- name: Cargo cache for Docker
uses: actions/cache@v4
id: cargo-cache
with:
path: |
../cargo-cache-registry-index
../cargo-cache-registry-cache
../cargo-cache-git-db
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
- ${{ runner.os }}-cargo-
shumkov marked this conversation as resolved.
Show resolved Hide resolved

- name: Inject cargo cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"../cargo-cache-registry-index": {
"target": "/root/.cargo/registry/index",
"id": "cargo_registry_index"
},
"../cargo-cache-registry-cache": {
"target": "/root/.cargo/registry/cache",
"id": "cargo_registry_cache"
},
"../cargo-cache-git-db": {
"target": "/root/.cargo/git/db",
"id": "cargo_git"
}
}
skip-extraction: ${{ steps.cargo-cache.outputs.cache-hit }}

- name: Yarn unplugged cache for Docker
uses: actions/cache@v4
id: yarn-cache
with:
path: ../yarn-unplugged-cache
key: ${{ inputs.platform }}-yarn-unplugged-${{ hashFiles('yarn.lock') }}
restore-keys: |
- ${{ inputs.platform }}-yarn-unplugged-
shumkov marked this conversation as resolved.
Show resolved Hide resolved

- name: Set arch
id: arch
uses: actions/github-script@v6
with:
result-encoding: 'string'
script: return '${{ inputs.platform }}'.replace('linux/', '');

- name: Inject cargo cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"../yarn-unplugged-cache": {
"target": "/tmp/unplugged",
"id": "unplugged_${{ steps.arch.outputs.result }}"
}
}
skip-extraction: ${{ steps.yarn-cache.outputs.cache-hit }}

- name: Export actions cache vars
uses: actions/github-script@v7
with:
name: ${{ inputs.image_name }}
bucket: ${{ inputs.bucket }}
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Build and push Docker image ${{ inputs.image }}
id: docker_build
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
target: ${{ inputs.target }}
labels: ${{ steps.docker_meta.outputs.labels }}
push: ${{ inputs.push_tags }}
tags: ${{ inputs.push_tags == 'true' && steps.docker_meta.outputs.tags || '' }}
platforms: ${{ inputs.platform }}
build-args: |
CARGO_BUILD_PROFILE=${{ inputs.cargo_profile }}
RUSTC_WRAPPER=sccache
SCCACHE_BUCKET=${{ inputs.bucket }}
SCCACHE_REGION=${{ inputs.region }}
SCCACHE_S3_KEY_PREFIX=${{ runner.os }}/sccache
AWS_ACCESS_KEY_ID=${{ inputs.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY=${{ inputs.aws_secret_access_key }}
AWS_REGION=${{ inputs.region }}
cache-from: ${{ steps.layer_cache_settings.outputs.cache_from }}
cache-to: ${{ steps.layer_cache_settings.outputs.cache_to }}
SCCACHE_GHA_ENABLED=true
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
# SCCACHE_BUCKET=${{ inputs.bucket }}
# SCCACHE_REGION=${{ inputs.region }}
# SCCACHE_S3_KEY_PREFIX=${{ runner.os }}/sccache
# AWS_ACCESS_KEY_ID=${{ inputs.aws_access_key_id }}
# AWS_SECRET_ACCESS_KEY=${{ inputs.aws_secret_access_key }}
# AWS_REGION=${{ inputs.region }}
# cache-from: ${{ steps.layer_cache_settings.outputs.cache_from }}
# cache-to: ${{ steps.layer_cache_settings.outputs.cache_to }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=image,name=${{ inputs.image_org }}/${{ inputs.image_name }},push-by-digest=${{ inputs.push_tags != 'true' }},name-canonical=true,push=true

# TODO: This is doesn't work
# - name: Save Docker mount cache
# uses: dcginfra/buildkit-cache-dance/extract@s5cmd
# if: ${{ inputs.cache_mounts != '' }}
Expand Down
16 changes: 11 additions & 5 deletions .github/actions/librocksdb/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ runs:
using: composite
steps:
# Cache librocksdb using s3 bucket
- name: Restore cached librocksdb from S3
id: librocksdb-cache
uses: strophy/actions-cache@opendal-update
# - name: Restore cached librocksdb from S3
# id: librocksdb-cache
# uses: strophy/actions-cache@opendal-update
# with:
# bucket: ${{ inputs.bucket }}
# path: /opt/rocksdb
# key: librocksdb/${{ inputs.version }}/${{ runner.os }}/${{ runner.arch }}

- name: Restore cached librocksdb
uses: actions/cache@v4
with:
bucket: ${{ inputs.bucket }}
path: /opt/rocksdb
key: librocksdb/${{ inputs.version }}/${{ runner.os }}/${{ runner.arch }}
path: /opt/rocksdb
shumkov marked this conversation as resolved.
Show resolved Hide resolved

- if: ${{ steps.librocksdb-cache.outputs.cache-hit != 'true' || inputs.force == 'true' }}
shell: bash
Expand Down
41 changes: 29 additions & 12 deletions .github/actions/local-network/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ runs:
- name: Setup Node.JS
uses: ./.github/actions/nodejs

- name: Restore JS build artifacts
uses: strophy/actions-cache@opendal-update
- name: Download JS build artifacts
uses: actions/download-artifact@v4
with:
bucket: multi-runner-cache-x1xibo9c
root: actions-cache
path: build-js-artifacts-${{ github.sha }}.tar
key: build-js-artifacts/${{ github.sha }}
name: build-js-artifacts-${{ github.sha }}

- name: Unpack JS build artifacts archive
shell: bash
Expand All @@ -33,12 +30,22 @@ runs:
run: echo "HOME=$HOME" >> $GITHUB_ENV

# TODO: Use upload artifacts action instead
# - name: Restore local network data
# id: local-network-data
# uses: strophy/actions-cache/restore@opendal-update
# with:
# bucket: multi-runner-cache-x1xibo9c
# root: local-network-data
# path: |
# ${{ env.HOME }}/.dashmate
# **/.env
# dashmate_volumes_dump
# key: local-network-volumes/${{ steps.dashmate-fingerprint.outputs.sha }}

- name: Restore local network data
id: local-network-data
uses: strophy/actions-cache/restore@opendal-update
uses: actions/cache/restore@v4
with:
bucket: multi-runner-cache-x1xibo9c
root: local-network-data
path: |
${{ env.HOME }}/.dashmate
**/.env
Expand Down Expand Up @@ -71,11 +78,21 @@ runs:
shell: bash
if: steps.local-network-data.outputs.cache-hit != 'true'

# - name: Save local network data
# uses: strophy/actions-cache/save@opendal-update
# with:
# bucket: multi-runner-cache-x1xibo9c
# root: local-network-data
# path: |
# ${{ env.HOME }}/.dashmate
# **/.env
# dashmate_volumes_dump
# key: local-network-volumes/${{ steps.dashmate-fingerprint.outputs.sha }}
# if: steps.local-network-data.outputs.cache-hit != 'true'

- name: Save local network data
uses: strophy/actions-cache/save@opendal-update
uses: actions/cache/save@v4
with:
bucket: multi-runner-cache-x1xibo9c
root: local-network-data
path: |
${{ env.HOME }}/.dashmate
**/.env
Expand Down
17 changes: 13 additions & 4 deletions .github/actions/nodejs/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@ runs:
shell: bash
run: npm config set audit false

- name: Cache NPM build artifacts (S3 bucket cache)
uses: strophy/actions-cache@opendal-update
# - name: Cache NPM build artifacts (S3 bucket cache)
# uses: strophy/actions-cache@opendal-update
# with:
# bucket: multi-runner-cache-x1xibo9c
# root: actions-cache
# path: |
# .yarn/unplugged
# key: ${{ runner.os }}/yarn/unplugged/${{ runner.arch }}/${{ hashFiles('yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}/yarn/unplugged/${{ runner.arch }}/

shumkov marked this conversation as resolved.
Show resolved Hide resolved
- name: Cache NPM build artifacts
uses: actions/cache@v4
with:
bucket: multi-runner-cache-x1xibo9c
root: actions-cache
path: |
.yarn/unplugged
key: ${{ runner.os }}/yarn/unplugged/${{ runner.arch }}/${{ hashFiles('yarn.lock') }}
Expand Down
22 changes: 18 additions & 4 deletions .github/actions/rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,25 @@ runs:
shell: bash
run: echo "HOME=$HOME" >> $GITHUB_ENV

- name: Cache cargo registry (S3 bucket cache)
uses: strophy/actions-cache@opendal-update
# - name: Cache cargo registry (S3 bucket cache)
# uses: strophy/actions-cache@opendal-update
# if: inputs.cache == 'true'
# with:
# bucket: multi-runner-cache-x1xibo9c
# root: actions-cache
# path: |
# ${{ env.HOME }}/.cargo/registry/index
# ${{ env.HOME }}/.cargo/registry/cache
# ${{ env.HOME }}/.cargo/git
# key: ${{ runner.os }}/cargo/registry/${{ hashFiles('**/Cargo.lock') }}
# restore-keys: |
# ${{ runner.os }}/cargo/registry/${{ hashFiles('**/Cargo.lock') }}
# ${{ runner.os }}/cargo/registry/

- name: Cache cargo registry
uses: actions/cache@v4
if: inputs.cache == 'true'
with:
bucket: multi-runner-cache-x1xibo9c
root: actions-cache
path: |
${{ env.HOME }}/.cargo/registry/index
${{ env.HOME }}/.cargo/registry/cache
Expand All @@ -114,6 +127,7 @@ runs:
${{ runner.os }}/cargo/registry/${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}/cargo/registry/


# TODO: Move to AMI and build every day
- name: Install clang
id: deps-clang
Expand Down
Loading
Loading