Skip to content

Use separate cache restore/save with unique keys per run #15

Use separate cache restore/save with unique keys per run

Use separate cache restore/save with unique keys per run #15

Workflow file for this run

name: Dev Release - RPi ARMv7 Thunder
on:
push:
tags:
- 'dev-*'
env:
TZ: Etc/UTC
DEBIAN_FRONTEND: noninteractive
FORCE_UNSAFE_CONFIGURE: 1
CONFIG_NAME: raspberrypi_armv7_thunder
CCACHE_LIMIT: 3.5G
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository (without submodules)
uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 0
- name: Set up SSH for private repos
run: |
mkdir -p ~/.ssh
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
echo "${{ secrets.GHA_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
cat <<EOT >> ~/.ssh/config
Host github.com
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
EOT
echo "βœ… SSH configured"
- name: Checkout submodules
run: |
echo "πŸ“¦ Checking out submodules..."
git submodule sync --recursive
git submodule update --init --recursive
echo "βœ… Submodules checked out"
# Try to restore downloads cache
- name: Restore downloads cache
id: cache-downloads-restore
uses: actions/cache/restore@v4
with:
path: build/download
key: downloads-${{ hashFiles('.gitmodules') }}
restore-keys: |
downloads-
# Try to restore ccache
- name: Restore ccache
id: cache-ccache-restore
uses: actions/cache/restore@v4
with:
path: build/ccache
key: ccache-armv7-${{ hashFiles('.gitmodules') }}
restore-keys: |
ccache-armv7-
- name: Cache status
run: |
echo "πŸ“Š Cache Restore Status:"
echo "Downloads cache hit: ${{ steps.cache-downloads-restore.outputs.cache-hit }}"
echo "Downloads cache key: ${{ steps.cache-downloads-restore.outputs.cache-matched-key || 'none' }}"
echo "ccache hit: ${{ steps.cache-ccache-restore.outputs.cache-hit }}"
echo "ccache key: ${{ steps.cache-ccache-restore.outputs.cache-matched-key || 'none' }}"
echo ""
echo "πŸ“ Checking directories:"
ls -lah build/ 2>/dev/null || echo "build/ doesn't exist"
du -sh build/download 2>/dev/null || echo "build/download doesn't exist"
du -sh build/ccache 2>/dev/null || echo "build/ccache doesn't exist"
- name: Install dependencies
run: |
sudo apt-get -qq update
sudo apt-get -qq --yes install apt-utils > /dev/null
sudo apt-get -qq --yes install \
subversion build-essential bison flex gettext libncurses5-dev texinfo \
autoconf automake libtool mercurial git-core gperf gawk expat curl cvs \
libexpat-dev bzr unzip bc python3-dev wget cpio rsync xxd libmpc-dev \
libgmp3-dev xz-utils file ccache > /dev/null
# Install multilib on x86_64
if [ "$(arch)" = "x86_64" ]; then
sudo apt-get -qq --yes install gcc-multilib g++-multilib > /dev/null
fi
echo "βœ… Dependencies installed"
- name: Get git reference
id: ref
run: |
REF=$(git rev-parse --short HEAD)
echo "ref=$REF" >> $GITHUB_OUTPUT
echo "πŸ“Œ Building reference: $REF"
echo "🏷️ Tag: ${{ github.ref_name }}"
- name: Download packages
run: |
export BR2_DL_DIR="${PWD}/build/download"
echo "πŸ“¦ Downloading packages for $CONFIG_NAME..."
# Initialize config
make -C buildroot \
BR2_EXTERNAL="../buildroot-external-metrological-open-source" \
O=../build/$CONFIG_NAME \
${CONFIG_NAME}_defconfig
make -C build/$CONFIG_NAME syncconfig
# Download all sources
echo "⏬ Running 'make source'..."
time make -C build/$CONFIG_NAME source
echo "βœ… Package download complete"
echo ""
echo "πŸ“Š Download cache size:"
du -sh build/download
echo "Files in download cache:"
find build/download -type f | wc -l
- name: Build ${{ env.CONFIG_NAME }}
run: |
export BR2_DL_DIR="${PWD}/build/download"
export BR2_CCACHE_DIR="${PWD}/build/ccache"
echo "πŸ”¨ Building $CONFIG_NAME..."
echo "⏰ Build started at $(date)"
# Add WPE WebKit parallel build optimization
echo 'BR2_PACKAGE_WPEWEBKIT_ML_PARALLEL_BUILD_JOBS="6"' >> ./build/$CONFIG_NAME/.config
# Compiler cache initial setup
echo 'BR2_CCACHE_INITIAL_SETUP="-M ${CCACHE_LIMIT} -z"' >> ./build/$CONFIG_NAME/.config
make -C build/$CONFIG_NAME syncconfig
# Build with timing
time make -C build/$CONFIG_NAME
echo "βœ… Build completed at $(date)"
echo ""
echo "πŸ“Š ccache size:"
du -sh build/ccache
- name: Show build artifacts
run: |
echo "πŸ“ Build artifacts:"
ls -lh ./build/$CONFIG_NAME/images/
- name: Show ccache statistics
run: |
echo "πŸ“Š ccache Statistics:"
./build/$CONFIG_NAME/host/usr/bin/ccache -s
- name: Final cache sizes
run: |
echo "πŸ“Š Final cache directory sizes before saving:"
echo ""
echo "Downloads cache:"
du -sh build/download
echo ""
echo "ccache:"
du -sh build/ccache
echo ""
echo "Total build directory:"
du -sh build/
# Save downloads cache (always, even if it existed)
- name: Save downloads cache
uses: actions/cache/save@v4
if: always()
with:
path: build/download
key: downloads-${{ hashFiles('.gitmodules') }}-${{ github.run_id }}
# Save ccache (always, even if it existed)
- name: Save ccache
uses: actions/cache/save@v4
if: always()
with:
path: build/ccache
key: ccache-armv7-${{ hashFiles('.gitmodules') }}-${{ github.run_id }}
- name: Compress image
run: |
echo "πŸ—œοΈ Compressing image at $(date)..."
xz --verbose --keep --compress --stdout \
./build/$CONFIG_NAME/images/sdcard.img > \
./${CONFIG_NAME}-${{ steps.ref.outputs.ref }}-sdcard.img.xz
# Show file size
echo ""
echo "πŸ“¦ Compressed image:"
ls -lh ${CONFIG_NAME}-${{ steps.ref.outputs.ref }}-sdcard.img.xz
# Calculate checksums
echo ""
echo "πŸ” Checksums:"
sha256sum ${CONFIG_NAME}-${{ steps.ref.outputs.ref }}-sdcard.img.xz | tee ${CONFIG_NAME}-${{ steps.ref.outputs.ref }}-sdcard.img.xz.sha256
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz
path: |
${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz
${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz.sha256
compression-level: 0 # Already compressed with xz
- name: Create pre-release
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz
${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz.sha256
prerelease: true
generate_release_notes: true
body: |
## πŸŽ‰ Dev Build - ${{ env.CONFIG_NAME }}
**Configuration:** `${{ env.CONFIG_NAME }}_defconfig`
**Reference:** `${{ steps.ref.outputs.ref }}`
**Tag:** `${{ github.ref_name }}`
**Build Date:** ${{ github.event.head_commit.timestamp }}
**Triggered by:** @${{ github.actor }}
### πŸ“¦ Artifacts
- `${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz` - Compressed SD card image
- `${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz.sha256` - SHA256 checksum
### πŸ”§ Platform
- **Target:** Raspberry Pi (ARMv7 32-bit)
- **Variant:** Thunder
### ⚑ Usage
```bash
# Download and verify
wget https://github.com/WebPlatformForEmbedded/lithosphere/releases/download/${{ github.ref_name }}/${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz
wget https://github.com/WebPlatformForEmbedded/lithosphere/releases/download/${{ github.ref_name }}/${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz.sha256
# Verify checksum
sha256sum -c ${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz.sha256
# Extract and flash
xz -d ${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img.xz
sudo dd if=${{ env.CONFIG_NAME }}-${{ steps.ref.outputs.ref }}-sdcard.img of=/dev/sdX bs=4M status=progress
sync
```
---
⚠️ **This is a development build for testing purposes.**
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build summary
run: |
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "βœ… BUILD SUCCESSFUL"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "πŸ“‹ Configuration: $CONFIG_NAME"
echo "🏷️ Tag: ${{ github.ref_name }}"
echo "πŸ“Œ Reference: ${{ steps.ref.outputs.ref }}"
echo "🎯 Platform: Raspberry Pi (ARMv7)"
echo ""
echo "πŸ“¦ Artifact: ${CONFIG_NAME}-${{ steps.ref.outputs.ref }}-sdcard.img.xz"
echo "πŸ”— Release: https://github.com/WebPlatformForEmbedded/lithosphere/releases/tag/${{ github.ref_name }}"
echo ""
echo "πŸ“Š Cache Status:"
echo "Downloads: ${{ steps.cache-downloads-restore.outputs.cache-hit == 'true' && 'βœ… HIT' || '❌ MISS' }}"
echo "ccache: ${{ steps.cache-ccache-restore.outputs.cache-hit == 'true' && 'βœ… HIT' || '❌ MISS' }}"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"