Skip to content

Commit

Permalink
[wip] overwrite GHA caches
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Aug 29, 2024
1 parent a5fbf9d commit 3bc12eb
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 22 deletions.
37 changes: 32 additions & 5 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ on:
branches:
- main

schedule:
# At minute 0 past every 6th hour. (see https://crontab.guru)
# this job is to keep the ccache cache warm
- cron: '0 */6 * * *'

concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ci-build-test-cpp-linux-${{ github.event.number || github.sha }}
cancel-in-progress: true

permissions:
contents: read
# required to delete cache
# https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-github-actions-caches-for-a-repository-using-a-cache-key
actions: write

jobs:
build_and_ctest:
name: Build and Test (linux, ASSERTIONS)
Expand All @@ -24,6 +35,7 @@ jobs:
fail-fast: true
env:
CACHE_DIR: ${{ github.workspace }}/.container-cache
CACHE_KEY: linux-build-test-cpp-asserts-manylinux-v2-${{ github.event.number || github.ref_name }}
steps:
- name: Set unified TZ
uses: szenius/[email protected]
Expand All @@ -42,11 +54,16 @@ jobs:
with:
submodules: recursive

- name: Install static libs
- name: Install deps
run: |
dnf install -y almalinux-release-devel
yum remove -y openssl-devel zlib-devel || true
yum install -y protobuf-devel protobuf-compiler
dnf install -y almalinux-release-devel
type -p yum-config-manager >/dev/null || yum -y install yum-utils
yum-config-manager -y --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
yum install -y protobuf-devel protobuf-compiler gh
- name: Sync source deps
run: |
python ./sync_deps.py
Expand All @@ -59,7 +76,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CACHE_DIR }}
key: linux-build-test-cpp-asserts-manylinux-v2-${{ github.sha }}
key: ${{ env.CACHE_KEY }}
restore-keys: linux-build-test-cpp-

- name: Build packages
Expand All @@ -82,12 +99,22 @@ jobs:
path: iree-dist-linux.tar
if-no-files-found: warn

- name: Overwrite cache
if: ${{ !cancelled() }}
continue-on-error: true
env:
# required to run gh with privileges
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ env.CACHE_KEY }} --confirm -R ${{ github.repository }}
- name: Save cache
uses: actions/cache/save@v3
if: ${{ !cancelled() }}
with:
path: ${{ env.CACHE_DIR }}
key: linux-build-test-cpp-asserts-manylinux-v2-${{ github.sha }}
key: ${{ env.CACHE_KEY }}

test_linux:
name: E2E Test linux
Expand Down
26 changes: 19 additions & 7 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ on:
branches:
- main

schedule:
- cron: '0 */6 * * *'

concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ci-build-test-cpp-macos-${{ github.event.number || github.sha }}
cancel-in-progress: true

permissions:
contents: read
actions: write

jobs:
build_and_ctest:
name: Build and Test (${{ matrix.runs-on }}, ASSERTIONS)
Expand All @@ -26,6 +30,7 @@ jobs:
runs-on: [macos-12, macos-14]
env:
CACHE_DIR: ${{ github.workspace }}/.container-cache
CACHE_KEY: ${{ matrix.runs-on }}-build-test-cpp-asserts-v1-${{ github.event.number || github.ref_name }}
steps:
- name: Set unified TZ
uses: szenius/[email protected]
Expand Down Expand Up @@ -60,9 +65,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CACHE_DIR }}
# without datetime stamps you'll get collisions for the cache warming runs
# ("Failed to save: Unable to reserve cache with key ..., another job may be creating this cache.")
key: ${{ matrix.runs-on }}-build-test-cpp-asserts-v1-${{ github.sha }}-${{ github.event.repository.updated_at }}
key: ${{ env.CACHE_KEY }}
restore-keys: ${{ matrix.runs-on }}-build-test-cpp-

- name: Build packages
Expand All @@ -85,9 +88,18 @@ jobs:
path: iree-dist-${{ matrix.runs-on }}.tar
if-no-files-found: warn

- name: Overwrite cache
if: ${{ !cancelled() }}
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ env.CACHE_KEY }} --confirm -R ${{ github.repository }}
- name: Save cache
uses: actions/cache/save@v3
if: ${{ !cancelled() }}
with:
path: ${{ env.CACHE_DIR }}
key: ${{ matrix.runs-on }}-build-test-cpp-asserts-v1-${{ github.sha }}-${{ github.event.repository.updated_at }}
key: ${{ env.CACHE_KEY }}
27 changes: 17 additions & 10 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ on:
- main

schedule:
# At minute 0 past every 12th hour. (see https://crontab.guru)
# this job is to keep the ccache cache warm
- cron: '0 */12 * * *'
- cron: '0 */6 * * *'

concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ci-build-test-cpp-windows-${{ github.event.number || github.sha }}
cancel-in-progress: true

Expand All @@ -26,6 +21,10 @@ defaults:
# force bash for windows
shell: bash

permissions:
contents: read
actions: write

jobs:
build_and_ctest:
name: Build and Test (windows, ASSERTIONS)
Expand All @@ -34,6 +33,7 @@ jobs:
fail-fast: true
env:
CACHE_DIR: ${{ github.workspace }}/.container-cache
CACHE_KEY: windows-build-test-cpp-asserts-v1-${{ github.event.number || github.ref_name }}
steps:
- name: Set unified TZ
uses: szenius/[email protected]
Expand Down Expand Up @@ -73,9 +73,7 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CACHE_DIR }}
# without datetime stamps you'll get collisions for the cache warming runs
# ("Failed to save: Unable to reserve cache with key ..., another job may be creating this cache.")
key: windows-build-test-cpp-asserts-v1-${{ github.sha }}-${{ github.event.repository.updated_at }}
key: ${{ env.CACHE_KEY }}
restore-keys: windows-build-test-cpp-

- name: Build packages
Expand All @@ -98,9 +96,18 @@ jobs:
path: iree-dist-windows.tar
if-no-files-found: warn

- name: Overwrite cache
if: ${{ !cancelled() }}
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ env.CACHE_KEY }} --confirm -R ${{ github.repository }}
- name: Save cache
uses: actions/cache/save@v3
if: ${{ !cancelled() }}
with:
path: ${{ env.CACHE_DIR }}
key: windows-build-test-cpp-asserts-v1-${{ github.sha }}-${{ github.event.repository.updated_at }}
key: ${{ env.CACHE_KEY }}

0 comments on commit 3bc12eb

Please sign in to comment.