Skip to content

Commit

Permalink
[actions] in .github/workflows/manual*, clean all caches, then cache …
Browse files Browse the repository at this point in the history
…and retrieve ccachedir in the github CI
  • Loading branch information
valassi committed Nov 1, 2023
1 parent 2b0ed34 commit ccb4f09
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 5 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/manual.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ function setup_ccache {
export CCACHE_DIR=${topdir}/CCACHE_DIR
}

#----------------------------------------------------------------------------------------------------------------------------------

function tput_ini() {
# Install and configure ccache
mkdir ${topdir}/BIN
Expand All @@ -88,14 +90,25 @@ function tput_ini() {
echo "tar -xvf ccache-4.8.3-linux-x86_64.tar.xz"
tar -xvf ccache-4.8.3-linux-x86_64.tar.xz
ln -sf ccache-4.8.3-linux-x86_64/ccache .
mkdir ${topdir}/CCACHE_DIR
# Set up ccache environment
setup_ccache
# Create the CCACHE_DIR directory if it was not retrieved from the cache
echo
if [ -d ${CCACHE_DIR} ]; then
echo "Directory CCACHE_DIR=${CCACHE_DIR} already exists (retrieved from cache)"
else
echo "Directory CCACHE_DIR=${CCACHE_DIR} does not exist: create it"
mkdir ${CCACHE_DIR}
fi
# Dump ccache status before the builds
echo
echo "ccache --version | head -1"
ccache --version | head -1
echo
echo "CCACHE_DIR=${CCACHE_DIR}"
echo "du -sm ${CCACHE_DIR}"
du -sm ${CCACHE_DIR}
echo
echo "ccache -s (before the builds)"
ccache -s
}
Expand Down Expand Up @@ -126,6 +139,10 @@ function tput_fin() {
setup_ccache
# Dump ccache status after the builds
echo
echo "CCACHE_DIR=${CCACHE_DIR}"
echo "du -sm ${CCACHE_DIR}"
du -sm ${CCACHE_DIR}
echo
echo "ccache -s (after the builds)"
ccache -s
}
Expand Down
78 changes: 74 additions & 4 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

name: Manual test suite

#----------------------------------------------------------------------------------------------------------------------------------

on:

push:
paths:
- '.github/workflows/manual.*'

workflow_dispatch:
#inputs:
# name:
Expand All @@ -17,25 +21,91 @@ on:
# required: true
# type: string

#----------------------------------------------------------------------------------------------------------------------------------

jobs:

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
cleanup:
runs-on: ubuntu-latest
permissions:
actions: write # this is required to delete caches
contents: read
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
echo "Fetching list of cache key"
cacheKeys=$(gh actions-cache list -R $REPO | cut -f 1 )
set +e # do not fail while deleting cache keys
echo "Deleting caches..."
for cacheKey in $cacheKeys; do gh actions-cache delete $cacheKey -R $REPO --confirm; done
echo "Deleting caches... done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

manualtestsuite:
runs-on: ubuntu-latest

steps:
# See https://github.com/actions/checkout
# (NB actions/checkout@v2 is deprecated)
# (NB actions/checkout@v4 need "Allow owner and select non-owner" and "Allow actions created by github")
- uses: actions/checkout@v4
- # See https://github.com/actions/checkout
# (NB actions/checkout@v2 is deprecated)
# (NB actions/checkout@v4 need "Allow owner and select non-owner" and "Allow actions created by github")
uses: actions/checkout@v4
with:
submodules: 'true'

- name: welcome
run: .github/workflows/manual.sh welcome

- name: codegen
run: .github/workflows/manual.sh codegen

- # See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy
name: list_cached
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
echo "List cache keys (start)"
gh actions-cache list -R $REPO | cut -f 1
echo "List cache keys (end)"
env:
GH_TOKEN: ${{ github.token }}

- # See https://github.com/actions/cache
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
name: restore_cached_ccachedir
id: cache-ccachedir-restore
uses: actions/cache/restore@v3
with:
path: CCACHE_DIR
key: ccachedir-${{ runner.os }}-${{ github.run_id }}
restore-keys:
ccachedir-${{ runner.os }}

- name: tput_ini
run: .github/workflows/manual.sh tput_ini

- name: tput_run
run: .github/workflows/manual.sh tput_run

- name: tput_fin
run: .github/workflows/manual.sh tput_fin

- # See https://github.com/actions/cache
name: update_cached_ccachedir
id: cache-ccachedir-update
uses: actions/cache/save@v3
with:
path: CCACHE_DIR
key: ccachedir-${{ runner.os }}-${{ github.run_id }}

#- name: Send greeting
# run: echo "Hello ${{ inputs.name }}"

#----------------------------------------------------------------------------------------------------------------------------------

0 comments on commit ccb4f09

Please sign in to comment.