Skip to content

Commit

Permalink
inprogress
Browse files Browse the repository at this point in the history
  • Loading branch information
grg-haas committed Jan 10, 2024
1 parent 260046b commit 6047cb9
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 14 deletions.
130 changes: 116 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ jobs:
- platform: hifive_unmatched
bits: 32

# Output cache keys that were used so we can consolidate them later. Note
# that this is a matrix job, and job outputs for these are not well supported
# at all in Github Actions (https://github.com/orgs/community/discussions/26639).
# Essentially, the last job to set these output variables will win, which is
# not always great. In our case, though, this is actually fine since we don't
# necessarily need "precise" matching here -- any job's output should be good
# enough to serve as a future key into the cache.
outputs:
buildroot-dl-key: ${{ steps.restore-buildroot-dl.outputs.cache-primary-key }}
ccache-key: ${{ steps.restore-ccache.outputs.cache-primary-key }}
ymdh: ${{ steps.cache-keys.outputs.YMDH }}

steps:

###########
Expand Down Expand Up @@ -52,26 +64,33 @@ jobs:
# much always be using the max Github Action cache limit (10GB), but this is okay
# since we really only care about keeping the latest cache anyways.
- name: Restore buildroot packages
uses: actions/cache@v3
id: restore-buildroot-dl
uses: actions/cache/restore@v3
with:
path: buildroot/dl
key: buildroot-dl-${{ matrix.platform }}${{ matrix.bits }}-${{ steps.cache-keys.outputs.YMDH }}
path: dl.tar
key: buildroot-dl-${{ steps.cache-keys.outputs.YMDH }}
restore-keys: |
buildroot-dl-${{ matrix.platform }}${{ matrix.bits }}-${{ steps.cache-keys.outputs.YMD }}
buildroot-dl-${{ matrix.platform }}${{ matrix.bits }}-${{ steps.cache-keys.outputs.YM }}
buildroot-dl-${{ matrix.platform }}${{ matrix.bits }}-${{ steps.cache-keys.outputs.Y }}
buildroot-dl-${{ matrix.platform }}${{ matrix.bits }}-
buildroot-dl-${{ steps.cache-keys.outputs.YMD }}
buildroot-dl-${{ steps.cache-keys.outputs.YM }}
buildroot-dl-${{ steps.cache-keys.outputs.Y }}
buildroot-dl-
- name: Restore ccache
uses: actions/cache@v3
id: restore-ccache
uses: actions/cache/restore@v3
with:
path: buildroot-ccache
key: ccache-${{ matrix.platform }}${{ matrix.bits }}-${{ steps.cache-keys.outputs.YMDH }}
path: ccache.tar.xz
key: ccache-${{ steps.cache-keys.outputs.YMDH }}
restore-keys: |
ccache-${{ matrix.platform }}${{ matrix.bits }}-${{ steps.cache-keys.outputs.YMD }}
ccache-${{ matrix.platform }}${{ matrix.bits }}-${{ steps.cache-keys.outputs.YM }}
ccache-${{ matrix.platform }}${{ matrix.bits }}-${{ steps.cache-keys.outputs.Y }}
ccache-${{ matrix.platform }}${{ matrix.bits }}-
ccache-${{ steps.cache-keys.outputs.YMD }}
ccache-${{ steps.cache-keys.outputs.YM }}
ccache-${{ steps.cache-keys.outputs.Y }}
ccache-
- name: Decompress caches
run: |
if [[ -f dl.tar ]] ; then tar -xf dl.tar -C buildroot ; fi
if [[ -f ccache.tar.xz ]]; then tar -xf ccache.tar.xz -C ~ ; fi
##############
## Keystone ##
Expand Down Expand Up @@ -107,12 +126,95 @@ jobs:
tar -cf - $COMPRESSDIRS | xz -9 -T0 > build.tar.xz
- name: Compress cache directories
run: |
tar -C buildroot --exclude='**/git' -cf dl.tar dl/
tar -C ~ -cf - .buildroot-ccache | xz -9 -T0 > ccache.tar.xz
- name: Upload build directory
uses: actions/upload-artifact@v4
with:
name: keystone-${{ matrix.platform }}${{ matrix.bits }}-builddir
path: build.tar.xz
retention-days: 1
compression-level: 0

- name: Upload buildroot download directory
uses: actions/upload-artifact@v4
with:
name: keystone-${{ matrix.platform }}${{ matrix.bits }}-buildroot-dl
path: dl.tar
retention-days: 1
compression-level: 0

- name: Upload ccache directory
uses: actions/upload-artifact@v4
with:
name: keystone-${{ matrix.platform }}${{ matrix.bits }}-ccache
path: ccache.tar.xz
retention-days: 1
compression-level: 0

###############
## Utilities ##
###############

# Combine cache directories to save space
combine-caches:
runs-on: ubuntu-latest
needs: build
steps:
- name: Install dependencies
run: |
sudo apt-get -y update && sudo apt-get -y install ccache
# First, fetch the caches themselves
- name: Prepare output directories
run: |
mkdir -p buildroot/dl/ ~/.buildroot-ccache/
- name: Fetch buildroot caches
uses: actions/download-artifact@v4
with:
pattern: keystone-*-buildroot-dl

- name: Fetch ccache caches
uses: actions/download-artifact@v4
with:
pattern: keystone-*-ccache

# Then, combine the caches
- name: Merge caches
run: |
for d in keystone-*-buildroot-dl; do
tar --skip-old-files -xf "$d/dl.tar" -C buildroot
done
RESULTDIR="~/.buildroot-ccache"
for d in keystone-*-ccache; do
TMPDIR=$(mktemp -d)
tar -xf "$d/ccache.tar.xz" -C "$TMPDIR"
( cd "$TMPDIR/.buildroot-ccache" ; cp -a --parents ? "$RESULTDIR" )
rm -rf "$TMPDIR"
done
ccache -d "$RESULTDIR" -c
- name: Recompress caches
run: |
tar -C buildroot --exclude='**/git' -cf dl.tar dl/
tar -C ~ -cf - .buildroot-ccache | xz -9 -T0 > ccache.tar.xz
- name: Save buildroot download cache
uses: actions/cache/save@v3
with:
path: dl.tar
key: ${{ needs.build.outputs.buildroot-dl-key }}

- name: Save ccache
uses: actions/cache/save@v3
with:
path: ccache.tar.xz
key: ${{ needs.build.outputs.ccache-key }}

###########
## Tests ##
Expand Down
1 change: 1 addition & 0 deletions mkutils/plat/generic/run.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ call:
$(call log,info,Calling command in QEMU)
ssh -i $(BUILDROOT_BUILDDIR)/target/root/.ssh/id-rsa \
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-o ConnectTimeout=5 \
-p $(QEMU_PORT) root@localhost $(KEYSTONE_COMMAND) 2>&1 | \
grep -v "Warning: Permanently added" | tee -a $(CALL_LOGFILE)

Expand Down

0 comments on commit 6047cb9

Please sign in to comment.