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 88e10866229c68d46a20715b274426800a23b3fe Author: Szymon Janc <[email protected]> AuthorDate: Tue Oct 13 01:41:20 2026 +0200 ci: Cache newt binary between runs Each build job compiled newt from source with go install. Add composite action that builds newt from current master commit of apache/mynewt-newt and caches built binary keyed by that commit, so newt is rebuilt only when newt master changes. Newt is installed from exact commit which also avoids delays in module proxy picking up latest master. Cache is saved only from master branch, pull requests use cache saved by master. Assisted-by: Claude:claude-opus-5-5 --- .github/actions/newt-install/action.yml | 92 +++++++++++++++++++++++++++++ .github/workflows/build_all_apps.yml | 9 +-- .github/workflows/build_blinky.yml | 8 +-- .github/workflows/build_bootloader.yml | 8 +-- .github/workflows/build_bootloader_main.yml | 8 +-- .github/workflows/build_cc_target.yml | 9 +-- .github/workflows/build_mtest_apps.yml | 9 +-- .github/workflows/build_targets.yml | 8 +-- .github/workflows/newt_test_all.yml | 8 +-- 9 files changed, 100 insertions(+), 59 deletions(-) diff --git a/.github/actions/newt-install/action.yml b/.github/actions/newt-install/action.yml new file mode 100644 index 000000000..58e406799 --- /dev/null +++ b/.github/actions/newt-install/action.yml @@ -0,0 +1,92 @@ +# +# 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: Install newt +description: > + Install newt built from master branch of apache/mynewt-newt. Built + binary is cached per newt commit, so newt is rebuilt only when newt + master branch changes. + +runs: + using: composite + steps: + - name: Get newt master commit + id: newt + shell: bash + run: | + sha=$(git ls-remote https://github.com/apache/mynewt-newt.git refs/heads/master | cut -f1) + if [ -z "$sha" ]; then + echo "::error::Failed to get newt master commit" + exit 1 + fi + echo "newt master is at $sha" + echo "sha=$sha" >> "$GITHUB_OUTPUT" + + - name: Restore newt from cache + id: cache + uses: actions/cache/restore@v6 + with: + path: ${{ github.workspace }}/.newt-bin + key: newt-${{ runner.os }}-${{ runner.arch }}-${{ steps.newt.outputs.sha }} + + - name: Report newt cache status + shell: bash + env: + CACHE_HIT: ${{ steps.cache.outputs.cache-hit }} + CACHE_KEY: ${{ steps.cache.outputs.cache-primary-key }} + run: | + if [ "$CACHE_HIT" = "true" ]; then + echo "newt cache hit: using cached build ($CACHE_KEY)" + else + echo "newt cache miss: building newt from source ($CACHE_KEY)" + fi + + - name: Set up Go + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/setup-go@v7 + with: + go-version: 'stable' + cache: false + + - name: Build newt + if: steps.cache.outputs.cache-hit != 'true' + shell: bash + env: + GOBIN: ${{ github.workspace }}/.newt-bin + run: | + go version + go install mynewt.apache.org/newt/newt@${{ steps.newt.outputs.sha }} + + # Only master saves cache, so that it is shared with all pull + # requests instead of being duplicated in each pull request scope + - name: Save newt to cache + if: >- + steps.cache.outputs.cache-hit != 'true' && + github.ref == 'refs/heads/master' && + github.event_name != 'pull_request' + uses: actions/cache/save@v6 + with: + path: ${{ github.workspace }}/.newt-bin + key: ${{ steps.cache.outputs.cache-primary-key }} + + - name: Add newt to PATH + shell: bash + run: | + echo "${{ github.workspace }}/.newt-bin" >> "$GITHUB_PATH" + "${{ github.workspace }}/.newt-bin/newt" version diff --git a/.github/workflows/build_all_apps.yml b/.github/workflows/build_all_apps.yml index b848ffb63..17effa383 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.yml @@ -38,10 +38,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-go@v7 - with: - go-version: 'stable' - cache: false - uses: carlosperate/[email protected] with: release: '15.2.Rel1' @@ -51,10 +47,7 @@ jobs: sudo apt-get update sudo apt-get install -y gcc-multilib - name: Install newt - shell: bash - run: | - go version - go install mynewt.apache.org/newt/newt@latest + uses: ./.github/actions/newt-install - name: Setup project shell: bash run: | diff --git a/.github/workflows/build_blinky.yml b/.github/workflows/build_blinky.yml index 7abb80344..55fbe52e2 100644 --- a/.github/workflows/build_blinky.yml +++ b/.github/workflows/build_blinky.yml @@ -42,10 +42,6 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v7 - - uses: actions/setup-go@v7 - with: - go-version: 'stable' - cache: false - uses: carlosperate/[email protected] with: release: '15.2.Rel1' @@ -60,9 +56,7 @@ jobs: brew install gnu-sed echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH - name: Install newt - run: | - go version - go install mynewt.apache.org/newt/newt@latest + uses: ./.github/actions/newt-install - name: Setup Blinky project shell: bash run: | diff --git a/.github/workflows/build_bootloader.yml b/.github/workflows/build_bootloader.yml index 935b158fd..ffe328081 100644 --- a/.github/workflows/build_bootloader.yml +++ b/.github/workflows/build_bootloader.yml @@ -38,10 +38,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-go@v7 - with: - go-version: 'stable' - cache: false - uses: carlosperate/[email protected] with: release: '15.2.Rel1' @@ -50,9 +46,7 @@ jobs: sudo apt-get update sudo apt-get install -y gcc-multilib - name: Install newt - run: | - go version - go install mynewt.apache.org/newt/newt@latest + uses: ./.github/actions/newt-install - name: Setup project shell: bash run: | diff --git a/.github/workflows/build_bootloader_main.yml b/.github/workflows/build_bootloader_main.yml index 01e7275cb..6a54bcf07 100644 --- a/.github/workflows/build_bootloader_main.yml +++ b/.github/workflows/build_bootloader_main.yml @@ -35,10 +35,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-go@v7 - with: - go-version: 'stable' - cache: false - uses: carlosperate/[email protected] with: release: '15.2.Rel1' @@ -47,9 +43,7 @@ jobs: sudo apt-get update sudo apt-get install -y gcc-multilib - name: Install newt - run: | - go version - go install mynewt.apache.org/newt/newt@latest + uses: ./.github/actions/newt-install - name: Setup project shell: bash run: | diff --git a/.github/workflows/build_cc_target.yml b/.github/workflows/build_cc_target.yml index a85d0bb02..9dce138ab 100644 --- a/.github/workflows/build_cc_target.yml +++ b/.github/workflows/build_cc_target.yml @@ -42,18 +42,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-go@v7 - with: - go-version: 'stable' - cache: false - uses: carlosperate/[email protected] with: release: ${{ matrix.gcc }} - name: Install newt - shell: bash - run: | - go version - go install mynewt.apache.org/newt/newt@latest + uses: ./.github/actions/newt-install - name: Setup project shell: bash run: | diff --git a/.github/workflows/build_mtest_apps.yml b/.github/workflows/build_mtest_apps.yml index 550e857d2..353db3b53 100644 --- a/.github/workflows/build_mtest_apps.yml +++ b/.github/workflows/build_mtest_apps.yml @@ -38,10 +38,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-go@v7 - with: - go-version: stable - cache: false - uses: carlosperate/[email protected] with: release: 15.2.Rel1 @@ -51,10 +47,7 @@ jobs: sudo apt-get update sudo apt-get install -y gcc-multilib - name: Install newt - shell: bash - run: | - go version - go install mynewt.apache.org/newt/newt@latest + uses: ./.github/actions/newt-install - name: Setup project shell: bash run: | diff --git a/.github/workflows/build_targets.yml b/.github/workflows/build_targets.yml index 78887db1f..4a94e457f 100644 --- a/.github/workflows/build_targets.yml +++ b/.github/workflows/build_targets.yml @@ -42,10 +42,6 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v7 - - uses: actions/setup-go@v7 - with: - go-version: 'stable' - cache: false - uses: carlosperate/[email protected] with: release: '15.2.Rel1' @@ -55,9 +51,7 @@ jobs: brew install gnu-sed echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH - name: Install newt - run: | - go version - go install mynewt.apache.org/newt/newt@latest + uses: ./.github/actions/newt-install - name: Setup project shell: bash run: | diff --git a/.github/workflows/newt_test_all.yml b/.github/workflows/newt_test_all.yml index 80338a0a7..ea586211a 100644 --- a/.github/workflows/newt_test_all.yml +++ b/.github/workflows/newt_test_all.yml @@ -38,18 +38,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-go@v7 - with: - go-version: 'stable' - cache: false - name: Install Dependencies run: | sudo apt-get update sudo apt-get install -y gcc-multilib - name: Install newt - run: | - go version - go install mynewt.apache.org/newt/newt@latest + uses: ./.github/actions/newt-install - name: Setup project shell: bash run: |
