Skip to content

Commit

Permalink
chore: bump sdk cache in upgrade script (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosentino11 authored Jun 27, 2024
1 parent e83ea89 commit b8c7a48
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 3 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
name: Plugin build

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: '*'

jobs:
build-native:
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-20.04, windows-2019 ] # windows-latest does not have visual studio 2017
otp: [ '24.0' ]

os: [ubuntu-20.04, windows-2019] # windows-latest does not have visual studio 2017
otp: ['24.0']
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -32,7 +29,6 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.8

#=========================================
# Test dependencies (ubuntu)
#=========================================
Expand All @@ -44,11 +40,9 @@ jobs:
sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse" && sudo apt update && sudo apt install -y clang-tidy-14
# Add llvm-14 binaries into the path early on
echo "/usr/lib/llvm-14/bin" >> $GITHUB_PATH
#=========================================
# Build script python dependencies
#=========================================

- name: Cache Pip
uses: actions/cache@v3
with:
Expand All @@ -58,40 +52,33 @@ jobs:
key: cache-pip-${{ matrix.os }}-${{ hashFiles('bin/requirements.txt') }}
restore-keys: |
cache-pip-${{ matrix.os }}-
- name: Install requirements
run: |
python3 -m pip install -r bin/requirements.txt
#=========================================
# Build AWS IoT Device SDK
#=========================================

- name: Restore SDK Cache
id: cache-sdk-restore
uses: actions/cache/restore@v3
with:
path: |
_build_sdk
key: cache-sdk-1-${{ matrix.os }}

- name: Build SDK
if: steps.cache-sdk-restore.outputs.cache-hit != 'true'
run: |
python3 -u -m bin --sdk-only
- name: Save SDK Cache
id: cache-sdk-save
uses: actions/cache/save@v3
with:
path: |
_build_sdk
key: ${{ steps.cache-sdk-restore.outputs.cache-primary-key }}

#=========================================
# Build EMQX
#=========================================

- name: Restore EMQX Cache
id: cache-emqx-restore
uses: actions/cache/restore@v3
Expand All @@ -100,29 +87,24 @@ jobs:
emqx
# TODO use commit as cache key
key: cache-emqx-5.1.1-${{ matrix.os }}

- name: Build EMQX
if: steps.cache-emqx-restore.outputs.cache-hit != 'true'
run: |
python3 -u -m bin --emqx-only
- name: Save EMQX Cache
id: cache-emqx-save
uses: actions/cache/save@v3
with:
path: |
emqx
key: ${{ steps.cache-emqx-restore.outputs.cache-primary-key }}

#=========================================
# Build Port Driver and Plugin
#=========================================

- name: Build
run: |
python3 -u -m bin --port-driver-only
python3 -u -m bin --quick
- name: Upload artifact
uses: actions/upload-artifact@v1.0.0
with:
Expand Down
24 changes: 21 additions & 3 deletions scripts/update-sdk-version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
set -e

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <commitish>"
Expand All @@ -17,9 +18,26 @@ cd aws-iot-device-sdk-cpp-v2
git fetch
git checkout ${HASH}
cd -
git add aws-iot-device-sdk-cpp-v2

# bump the cache key in github actions so we don't accidently use the cached previous version of the sdk
ACTIONS_BUILD_FILE=.github/workflows/build.yml
SDK_RESTORE_TASK_ID=cache-sdk-restore
OLD_CACHE_KEY=$(yq eval ".jobs.build-native.steps[] | select(.id == \"${SDK_RESTORE_TASK_ID}\").with.key" "${ACTIONS_BUILD_FILE}")
if [[ -z "${OLD_CACHE_KEY}" ]]; then
echo "SDK cache key not found in ${ACTIONS_BUILD_FILE}. Please update this script"
exit 1
fi
OLD_CACHE_VERSION=$(echo "${OLD_CACHE_KEY}" | awk -F'-' '{print $3}')
NEW_CACHE_VERSION=$((OLD_CACHE_VERSION + 1))
UPDATED_BUILD_FILE_CONTENTS=$(yq eval "
(.jobs.build-native.steps[] | select(.id == \"${SDK_RESTORE_TASK_ID}\").with.key) |=
sub(\"cache-sdk-${OLD_CACHE_VERSION}-\", \"cache-sdk-${NEW_CACHE_VERSION}-\")" \
"${ACTIONS_BUILD_FILE}")
echo "${UPDATED_BUILD_FILE_CONTENTS}" > ${ACTIONS_BUILD_FILE}
git add "${ACTIONS_BUILD_FILE}"

# commit the changes
git add aws-iot-device-sdk-cpp-v2
git commit -m "chore: update aws iot sdk to ${HASH}"
git commit -m "chore: update AWS IoT SDK to ${HASH}"

echo "Updated repo to ${HASH}, please verify then push your changes"
echo "Updated AWS IoT SDK to ${HASH}, please verify then push your changes"

0 comments on commit b8c7a48

Please sign in to comment.