Skip to content

Commit

Permalink
ci: utilize cache for SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
blocktrron committed Jul 28, 2024
1 parent 61bb034 commit e540f15
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
27 changes: 26 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,49 @@ jobs:
- name: Install dependencies
run: |
$GITHUB_WORKSPACE/contrib/install-deps.sh
- name: Determine Cache-Key
id: cache-key-sdk
run: >
echo "cache-key=$(bash $GITHUB_WORKSPACE/contrib/cache-key.sh
$GITHUB_WORKSPACE ${{ needs.build-meta.outputs.sdk-url }})" >> "$GITHUB_OUTPUT"
- name: Restore Cache
id: restore-cache-sdk
uses: actions/cache/restore@v4
with:
path: /tmp/openwrt-sdk
key: ${{ steps.cache-key-sdk.outputs.cache-key }}
- name: Download SDK
if: steps.restore-cache-sdk.outputs.cache-hit != 'true'
run: |
curl -o /tmp/openwrt-sdk.tar.xz ${{ needs.build-meta.outputs.sdk-url }}
- name: Extract SDK
if : steps.restore-cache-sdk.outputs.cache-hit != 'true'
run: |
tar -xf /tmp/openwrt-sdk.tar.xz -C /tmp
ls /tmp
mv /tmp/${{ needs.build-meta.outputs.sdk-name }} /tmp/openwrt-sdk
- name: Create feeds.conf
if: steps.restore-cache-sdk.outputs.cache-hit != 'true'
run: |
cp /tmp/openwrt-sdk/feeds.conf.default /tmp/openwrt-sdk/feeds.conf
echo "src-link oobfw $GITHUB_WORKSPACE/openwrt" >> /tmp/openwrt-sdk/feeds.conf
echo "src-link oobpkgs $GITHUB_WORKSPACE/packages" >> /tmp/openwrt-sdk/feeds.conf
- name: Init SDK
- name: Install SDK feeds
if: steps.restore-cache-sdk.outputs.cache-hit != 'true'
run: |
cd /tmp/openwrt-sdk
./scripts/feeds update -a
./scripts/feeds install -a
- name: Save cache
id: save-cache-sdk
if: steps.restore-cache-sdk.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: /tmp/openwrt-sdk
key: ${{ steps.cache-key-sdk.outputs.cache-key }}
- name: Create SDK configuration
run: |
cd /tmp/openwrt-sdk
echo "# CONFIG_SIGNED_PACKAGES is not set" > /tmp/openwrt-sdk/.config
echo CONFIG_FFDA_OOB_FIRMWARE_VERSION=\"${{ needs.build-meta.outputs.firmware-version }}\" >> /tmp/openwrt-sdk/.config
make defconfig
Expand Down
13 changes: 13 additions & 0 deletions contrib/cache-key-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

WORKSPACE_DIR="$1"
SDK_URL="$2"

if [ -z "$WORKSPACE_DIR" ] || [ -z "$SDK_URL" ]; then
echo "Usage: $0 <workspace_dir> <sdk_url>"
exit 1
fi

PACKAGES_SUBMODULE_REV="$(git -C "$WORKSPACE_DIR/packages" rev-parse HEAD)"
SDK_URL_HASH="$(echo "$SDK_URL" | sha256sum | cut -d ' ' -f 1)"
CACHE_KEY="sdk-$PACKAGES_SUBMODULE_REV-$SDK_URL_HASH"

0 comments on commit e540f15

Please sign in to comment.