Skip to content

Commit be5df7f

Browse files
committed
ci: Cache source files
This commit updates the CI workflow to cache the crosstool-ng and poky source files used for building the Zephyr SDK in the AWS S3, in order to speed up the builds as well as to improve the availability of the source files. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 2fc95f5 commit be5df7f

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,29 @@ jobs:
525525
name: version
526526
path: ${{ runner.temp }}
527527

528+
- name: Configure AWS Credentials
529+
uses: aws-actions/configure-aws-credentials@v1
530+
with:
531+
aws-access-key-id: ${{ secrets.AWS_CACHE_SDK_ACCESS_KEY_ID }}
532+
aws-secret-access-key: ${{ secrets.AWS_CACHE_SDK_SECRET_ACCESS_KEY }}
533+
aws-region: us-east-1
534+
535+
- name: Download cached source files
536+
continue-on-error: true
537+
run: |
538+
SRC_CACHE_BASE="s3://cache-sdk/crosstool-ng-sources"
539+
SRC_CACHE_DIR="${{ matrix.host.name }}/${{ matrix.target }}"
540+
SRC_CACHE_URI="${SRC_CACHE_BASE}/${SRC_CACHE_DIR}"
541+
542+
# Download cached source files
543+
mkdir -p ${WORKSPACE}/sources
544+
pushd ${WORKSPACE}/sources
545+
aws s3 sync ${SRC_CACHE_URI} .
546+
popd
547+
548+
# Export environment variables
549+
echo "SRC_CACHE_URI=${SRC_CACHE_URI}" >> $GITHUB_ENV
550+
528551
- name: Build toolchain
529552
run: |
530553
# Set output path
@@ -694,6 +717,13 @@ jobs:
694717
md5sum ${ARCHIVE_FILE} > md5.sum
695718
sha256sum ${ARCHIVE_FILE} > sha256.sum
696719
720+
- name: Sync downloaded source files to cache
721+
continue-on-error: true
722+
run: |
723+
pushd ${WORKSPACE}/sources
724+
aws s3 sync . ${SRC_CACHE_URI}
725+
popd
726+
697727
- name: Prepare toolchain build log
698728
if: always()
699729
run: |
@@ -761,10 +791,37 @@ jobs:
761791
submodules: recursive
762792
persist-credentials: false
763793

794+
- name: Configure AWS Credentials
795+
uses: aws-actions/configure-aws-credentials@v1
796+
with:
797+
aws-access-key-id: ${{ secrets.AWS_CACHE_SDK_ACCESS_KEY_ID }}
798+
aws-secret-access-key: ${{ secrets.AWS_CACHE_SDK_SECRET_ACCESS_KEY }}
799+
aws-region: us-east-1
800+
801+
- name: Download cached source files (Linux)
802+
if: startsWith(matrix.host.name, 'linux-')
803+
continue-on-error: true
804+
run: |
805+
SRC_CACHE_BASE="s3://cache-sdk/poky-sources"
806+
SRC_CACHE_DIR="${{ matrix.host.name }}"
807+
SRC_CACHE_URI="${SRC_CACHE_BASE}/${SRC_CACHE_DIR}"
808+
POKY_DOWNLOADS="${RUNNER_TEMP}/poky-downloads"
809+
810+
# Download cached source files
811+
mkdir -p ${POKY_DOWNLOADS}
812+
pushd ${POKY_DOWNLOADS}
813+
aws s3 sync ${SRC_CACHE_URI} .
814+
popd
815+
816+
# Export environment variables
817+
echo "SRC_CACHE_URI=${SRC_CACHE_URI}" >> $GITHUB_ENV
818+
echo "POKY_DOWNLOADS=${POKY_DOWNLOADS}" >> $GITHUB_ENV
819+
764820
- name: Build Linux host tools
765821
if: startsWith(matrix.host.name, 'linux-')
766822
run: |
767823
POKY_BASE=${GITHUB_WORKSPACE}/meta-zephyr-sdk
824+
export META_DOWNLOADS="${POKY_DOWNLOADS}"
768825
769826
# Check out Poky
770827
${POKY_BASE}/scripts/meta-zephyr-sdk-clone.sh
@@ -796,6 +853,16 @@ jobs:
796853
md5sum ${ARCHIVE_FILE} > md5.sum
797854
sha256sum ${ARCHIVE_FILE} > sha256.sum
798855
856+
- name: Sync downloaded source files to cache (Linux)
857+
if: startsWith(matrix.host.name, 'linux-')
858+
continue-on-error: true
859+
run: |
860+
pushd ${POKY_DOWNLOADS}
861+
rm -rf git2
862+
rm -rf svn
863+
aws s3 sync . ${SRC_CACHE_URI}
864+
popd
865+
799866
- name: Upload toolchain build artifact
800867
if: startsWith(matrix.host.name, 'linux-') # FIXME: Do for all
801868
uses: actions/upload-artifact@v2

0 commit comments

Comments
 (0)