This is an automated email from the ASF dual-hosted git repository. sjanc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 6afeb81c21c32a629c54626d5edfae0207f9b1a0 Author: Szymon Janc <[email protected]> AuthorDate: Tue Oct 13 01:41:34 2026 +0200 ci: Cache external repositories between runs Each build job downloaded all external repositories with newt upgrade which takes around 4 minutes for full project. Add composite action for setting up newt project which restores repositories from cache before upgrade, so only changes since cache was created are fetched. Upgrade is still done twice to get dependencies added by tested commit. Single cache is shared by all projects as newt skips repositories not used by project. Cache is saved only from master branch by bootloader job, which uses project with all repositories, and only when external repositories versions changed. Caches from default branch are also available to pull requests. Assisted-by: Claude:claude-opus-5-5 --- .github/actions/newt-project/action.yml | 96 +++++++++++++++++++++++++++++ .github/workflows/build_all_apps.yml | 17 ++--- .github/workflows/build_blinky.yml | 15 ++--- .github/workflows/build_bootloader.yml | 16 ++--- .github/workflows/build_bootloader_main.yml | 12 ++-- .github/workflows/build_cc_target.yml | 15 ++--- .github/workflows/build_mtest_apps.yml | 18 +++--- .github/workflows/build_targets.yml | 17 ++--- .github/workflows/newt_test_all.yml | 15 ++--- 9 files changed, 136 insertions(+), 85 deletions(-) diff --git a/.github/actions/newt-project/action.yml b/.github/actions/newt-project/action.yml new file mode 100644 index 000000000..2be139cd6 --- /dev/null +++ b/.github/actions/newt-project/action.yml @@ -0,0 +1,96 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: Set up newt project +description: > + Create newt project for testing current commit. External repositories + are restored from cache and then upgraded by newt, so only changes + since cache was created are downloaded. Single cache is shared by all + projects since newt skips repositories not used by project. Cache + should be saved only by job using project with all repositories and + only from master branch, since only caches from default branch are + available to pull requests. + +inputs: + project: + description: Project file to use (relative to repository root) + required: true + path: + description: Directory to create project in + required: false + default: build + save-cache: + description: Save repositories to cache (master branch only) + required: false + default: 'false' + +runs: + using: composite + steps: + - name: Create project + id: project + shell: bash + run: | + newt new "${{ inputs.path }}" + cp -f "${{ inputs.project }}" "${{ inputs.path }}/project.yml" + echo "cache-prefix=newt-repos-${{ runner.os }}-" >> "$GITHUB_OUTPUT" + + - name: Restore repositories from cache + id: restore + uses: actions/cache/restore@v6 + with: + path: ${{ inputs.path }}/repos + key: ${{ steps.project.outputs.cache-prefix }}${{ github.sha }} + restore-keys: ${{ steps.project.outputs.cache-prefix }} + + # First upgrade uses master version of apache-mynewt-core to get all + # repositories, then core is switched to tested commit and upgraded + # again to download dependencies added by tested commit. + - name: Upgrade repositories + shell: bash + working-directory: ${{ inputs.path }} + run: | + newt upgrade --shallow=1 + git -C repos/apache-mynewt-core fetch origin "$GITHUB_SHA" + sed -i "s/0.0.0/$GITHUB_SHA-commit/g" project.yml + newt upgrade --shallow=1 + + # Cache key is based on external repositories versions only, so new + # cache is created only when dependencies change and not on every + # commit to apache-mynewt-core. + - name: Compute repositories cache key + id: key + shell: bash + working-directory: ${{ inputs.path }} + run: | + hash=$(for d in repos/*/; do + [ "$d" = "repos/apache-mynewt-core/" ] && continue + echo "$d $(git -C "$d" rev-parse HEAD)" + done | git hash-object --stdin | cut -c1-16) + echo "key=${{ steps.project.outputs.cache-prefix }}$hash" >> "$GITHUB_OUTPUT" + + - name: Save repositories to cache + if: >- + inputs.save-cache == 'true' && github.ref == 'refs/heads/master' && + github.event_name != 'pull_request' && + steps.restore.outputs.cache-matched-key != steps.key.outputs.key + uses: actions/cache/save@v6 + with: + path: ${{ inputs.path }}/repos + key: ${{ steps.key.outputs.key }} diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/build_all_apps.yml index 17effa383..124d37f6f 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.yml @@ -48,18 +48,13 @@ jobs: sudo apt-get install -y gcc-multilib - name: Install newt uses: ./.github/actions/newt-install - - name: Setup project + - name: Set up project + uses: ./.github/actions/newt-project + with: + project: .github/project_build_all_apps.yml + - name: Remove project targets shell: bash - run: | - newt new build - cp -f .github/project_build_all_apps.yml build/project.yml - cd build - newt upgrade --shallow=1 - git -C repos/apache-mynewt-core fetch origin $GITHUB_SHA - sed -i "s/0.0.0/$GITHUB_SHA-commit/g" project.yml - newt upgrade --shallow=1 - rm -rf targets - cd .. + run: rm -rf build/targets - name: Build applications shell: bash run: | diff --git a/.github/workflows/build_blinky.yml b/.github/workflows/build_blinky.yml index 55fbe52e2..69d4fca8a 100644 --- a/.github/workflows/build_blinky.yml +++ b/.github/workflows/build_blinky.yml @@ -57,17 +57,10 @@ jobs: echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH - name: Install newt uses: ./.github/actions/newt-install - - name: Setup Blinky project - shell: bash - run: | - newt new build - cp -f .github/project.yml build/project.yml - cd build - newt upgrade --shallow=1 - git -C repos/apache-mynewt-core fetch origin $GITHUB_SHA - sed -i "s/0.0.0/$GITHUB_SHA-commit/g" project.yml - newt upgrade --shallow=1 - cd .. + - name: Set up project + uses: ./.github/actions/newt-project + with: + project: .github/project.yml - name: Build Blinky shell: bash run: | diff --git a/.github/workflows/build_bootloader.yml b/.github/workflows/build_bootloader.yml index ffe328081..369152f54 100644 --- a/.github/workflows/build_bootloader.yml +++ b/.github/workflows/build_bootloader.yml @@ -47,17 +47,11 @@ jobs: sudo apt-get install -y gcc-multilib - name: Install newt uses: ./.github/actions/newt-install - - name: Setup project - shell: bash - run: | - newt new build - cp -f .github/project.yml build/project.yml - cd build - newt upgrade --shallow=1 - git -C repos/apache-mynewt-core fetch origin $GITHUB_SHA - sed -i "s/0.0.0/$GITHUB_SHA-commit/g" project.yml - newt upgrade --shallow=1 - cd .. + - name: Set up project + uses: ./.github/actions/newt-project + with: + project: .github/project.yml + save-cache: true - name: Build bootloader shell: bash run: | diff --git a/.github/workflows/build_bootloader_main.yml b/.github/workflows/build_bootloader_main.yml index 6a54bcf07..a2c377f57 100644 --- a/.github/workflows/build_bootloader_main.yml +++ b/.github/workflows/build_bootloader_main.yml @@ -44,14 +44,10 @@ jobs: sudo apt-get install -y gcc-multilib - name: Install newt uses: ./.github/actions/newt-install - - name: Setup project - shell: bash - run: | - newt new build - cp -f .github/project.yml build/project.yml - cd build - newt upgrade --shallow=1 - cd .. + - name: Set up project + uses: ./.github/actions/newt-project + with: + project: .github/project.yml - name: Build bootloader (main branch) shell: bash run: | diff --git a/.github/workflows/build_cc_target.yml b/.github/workflows/build_cc_target.yml index 9dce138ab..9cbd8dafc 100644 --- a/.github/workflows/build_cc_target.yml +++ b/.github/workflows/build_cc_target.yml @@ -47,17 +47,10 @@ jobs: release: ${{ matrix.gcc }} - name: Install newt uses: ./.github/actions/newt-install - - name: Setup project - shell: bash - run: | - newt new build - cp -f .github/project_build_cc_target.yml build/project.yml - cd build - newt upgrade --shallow=1 - git -C repos/apache-mynewt-core fetch origin $GITHUB_SHA - sed -i "s/0.0.0/$GITHUB_SHA-commit/g" project.yml - newt upgrade --shallow=1 - cd .. + - name: Set up project + uses: ./.github/actions/newt-project + with: + project: .github/project_build_cc_target.yml - name: Build targets shell: bash run: | diff --git a/.github/workflows/build_mtest_apps.yml b/.github/workflows/build_mtest_apps.yml index 353db3b53..014ab231d 100644 --- a/.github/workflows/build_mtest_apps.yml +++ b/.github/workflows/build_mtest_apps.yml @@ -48,18 +48,14 @@ jobs: sudo apt-get install -y gcc-multilib - name: Install newt uses: ./.github/actions/newt-install - - name: Setup project + - name: Set up project + uses: ./.github/actions/newt-project + with: + project: .github/project_build_mtest_apps.yml + path: build_mtest + - name: Remove project targets shell: bash - run: | - newt new build_mtest - cp -f .github/project_build_mtest_apps.yml build_mtest/project.yml - cd build_mtest - newt upgrade --shallow=1 - git -C repos/apache-mynewt-core fetch origin $GITHUB_SHA - sed -i "s/0.0.0/$GITHUB_SHA-commit/g" project.yml - newt upgrade --shallow=1 - rm -rf targets - cd .. + run: rm -rf build_mtest/targets - name: Build mtest apps shell: bash run: | diff --git a/.github/workflows/build_targets.yml b/.github/workflows/build_targets.yml index 4a94e457f..f84f25f65 100644 --- a/.github/workflows/build_targets.yml +++ b/.github/workflows/build_targets.yml @@ -52,18 +52,13 @@ jobs: echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH - name: Install newt uses: ./.github/actions/newt-install - - name: Setup project + - name: Set up project + uses: ./.github/actions/newt-project + with: + project: .github/project.yml + - name: Remove project targets shell: bash - run: | - newt new build - cp -f .github/project.yml build/project.yml - cd build - newt upgrade --shallow=1 - git -C repos/apache-mynewt-core fetch origin $GITHUB_SHA - sed -i "s/0.0.0/$GITHUB_SHA-commit/g" project.yml - newt upgrade --shallow=1 - rm -rf targets - cd .. + run: rm -rf build/targets - name: Build targets shell: bash run: | diff --git a/.github/workflows/newt_test_all.yml b/.github/workflows/newt_test_all.yml index ea586211a..5cec7bc85 100644 --- a/.github/workflows/newt_test_all.yml +++ b/.github/workflows/newt_test_all.yml @@ -44,17 +44,10 @@ jobs: sudo apt-get install -y gcc-multilib - name: Install newt uses: ./.github/actions/newt-install - - name: Setup project - shell: bash - run: | - newt new build - cp -f .github/project_newt_test_all.yml build/project.yml - cd build - newt upgrade --shallow=1 - git -C repos/apache-mynewt-core fetch origin $GITHUB_SHA - sed -i "s/0.0.0/$GITHUB_SHA-commit/g" project.yml - newt upgrade --shallow=1 - cd .. + - name: Set up project + uses: ./.github/actions/newt-project + with: + project: .github/project_newt_test_all.yml - name: Switch to main mcuboot # This is temporary until next mcuboot release is available shell: bash
