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-nimble.git
commit d3af3ba1defb1656c855c432a23e6747b5a8ac4b Author: Szymon Janc <[email protected]> AuthorDate: Wed Oct 14 00:53:42 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_cc_target.yml | 9 +--- .github/workflows/build_targets.yml | 9 +--- .github/workflows/newt_test_all.yml | 9 +--- .github/workflows/ports_syscfg_check.yml | 9 +--- 6 files changed, 97 insertions(+), 40 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 b4fbf365c..b15519fad 100644 --- a/.github/workflows/build_all_apps.yml +++ b/.github/workflows/build_all_apps.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' @@ -48,10 +44,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_cc_target.yml b/.github/workflows/build_cc_target.yml index 60e218fb6..2fd069355 100644 --- a/.github/workflows/build_cc_target.yml +++ b/.github/workflows/build_cc_target.yml @@ -39,18 +39,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_targets.yml b/.github/workflows/build_targets.yml index e75d34799..df595a03f 100644 --- a/.github/workflows/build_targets.yml +++ b/.github/workflows/build_targets.yml @@ -39,10 +39,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' @@ -53,10 +49,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/newt_test_all.yml b/.github/workflows/newt_test_all.yml index 289270279..03797238c 100644 --- a/.github/workflows/newt_test_all.yml +++ b/.github/workflows/newt_test_all.yml @@ -35,20 +35,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - uses: actions/setup-go@v7 - with: - go-version: 'stable' - cache: false - name: Install Dependencies shell: bash run: | 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/ports_syscfg_check.yml b/.github/workflows/ports_syscfg_check.yml index e49b33c58..01a4476de 100644 --- a/.github/workflows/ports_syscfg_check.yml +++ b/.github/workflows/ports_syscfg_check.yml @@ -36,10 +36,6 @@ jobs: if: github.event.repository.fork == false 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' @@ -49,10 +45,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: |
