From 2d0a2d47a259fb9a98265fa31a7e780cc88d8885 Mon Sep 17 00:00:00 2001 From: Oskar Weser Date: Fri, 10 Apr 2026 16:43:03 +0200 Subject: [PATCH 1/4] small but crucial fixes to ecbuild --- cmake/ecbuild_target_fortran_module_directory.cmake | 4 ++-- cmake/project-config.cmake.in | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmake/ecbuild_target_fortran_module_directory.cmake b/cmake/ecbuild_target_fortran_module_directory.cmake index d83986ad..726b2343 100644 --- a/cmake/ecbuild_target_fortran_module_directory.cmake +++ b/cmake/ecbuild_target_fortran_module_directory.cmake @@ -6,7 +6,7 @@ # granted to it by virtue of its status as an intergovernmental organisation # nor does it submit to any jurisdiction. -macro( ecbuild_target_fortran_module_directory ) +function( ecbuild_target_fortran_module_directory ) set( options NO_MODULE_DIRECTORY ) set( single_value_args TARGET MODULE_DIRECTORY INSTALL_MODULE_DIRECTORY ) set( multi_value_args "" ) @@ -35,4 +35,4 @@ macro( ecbuild_target_fortran_module_directory ) endif() endif() -endmacro() +endfunction() diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in index b41db6e9..229135c7 100644 --- a/cmake/project-config.cmake.in +++ b/cmake/project-config.cmake.in @@ -41,7 +41,12 @@ if(EXISTS ${@PROJECT_NAME@_CMAKE_DIR}/@CONF_IMPORT_FILE@) endif() ### insert definitions for IMPORTED targets -if(NOT @PROJECT_NAME@_BINARY_DIR) +# Guard: for install-tree exports (@PROJECT_NAME@_IS_BUILD_DIR_EXPORT=OFF) we must +# always load the targets file. For build-tree exports the targets are already +# defined by the build system, so we only skip when we are genuinely inside that +# build (i.e. the variable was set by ecbuild's own project() hook, not by an +# unrelated project that happens to share the same name). +if(NOT (@PROJECT_NAME@_IS_BUILD_DIR_EXPORT AND @PROJECT_NAME@_BINARY_DIR)) find_file(@PROJECT_NAME@_TARGETS_FILE NAMES @PROJECT_NAME@-targets.cmake HINTS @PACKAGE_TARGETS_DIRS@ From b192f8a70db7d3ff7ef7187e663de011b64713b2 Mon Sep 17 00:00:00 2001 From: Oskar Weser Date: Mon, 13 Apr 2026 12:47:48 +0200 Subject: [PATCH 2/4] ci: extract shared infrastructure into composite actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each dependency now exposes a use- composite action in its own repo. Consumers call that action — they do not see or repeat caching logic. New composite actions: - ecbuild/.github/actions/use-ecbuild: installs ecbuild from its own repo checkout, cache-keyed on action SHA. Replaces all inline ecbuild blocks (4+ occurrences). - downstream-ci/actions/check-artifact: wraps check_artifact.py via github.action_path (no extra checkout needed). - downstream-ci/actions/download-artifact-from-store: gh api download + unzip + extract. - fortran/.github/actions/use-fortmath: 3-strategy acquire (artifact store -> local cache -> build from source); uploads artifact to the calling run. - cxx/.github/actions/use-cxxmath: same pattern; calls use-fortmath internally for the build-from-source path. Updated workflows: - fortran/build.yml: inline ecbuild block replaced by use-ecbuild. - fortran/ci.yml: ECBUILD_REF env removed; test job uses use-ecbuild. - cxx/ci.yml: build-fortmath workflow_call job replaced by thin get-fortmath job calling use-fortmath; all inline ecbuild blocks replaced by use-ecbuild. Deleted: - fortran/.github/workflows/use-cache-or-build.yml - cxx/.github/workflows/use-cache-or-build.yml Composite actions have no workflow-nesting limit, so this scales to arbitrary dependency trees without hitting GitHub Actions' 4-level cap. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/actions/use-ecbuild/action.yml | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/actions/use-ecbuild/action.yml diff --git a/.github/actions/use-ecbuild/action.yml b/.github/actions/use-ecbuild/action.yml new file mode 100644 index 00000000..38d66f32 --- /dev/null +++ b/.github/actions/use-ecbuild/action.yml @@ -0,0 +1,44 @@ +name: Use ecbuild +description: > + Installs ecbuild from the version of this repository referenced in the + action call (uses: ecmwf/ecbuild/.github/actions/use-ecbuild@). + The ecbuild source tree is this action's own repository checkout, so the + installed version always matches the referenced ref. + + Uses a local cache keyed on the action SHA and OS to avoid rebuilding on + repeated runs. + +inputs: + os: + description: 'OS label (used as part of the cache key)' + required: false + default: ubuntu-latest + +outputs: + install-path: + description: 'Absolute path where ecbuild was installed' + value: ${{ steps.set-paths.outputs.install-path }} + +runs: + using: composite + steps: + - name: Set install path + id: set-paths + shell: bash + run: echo "install-path=$GITHUB_WORKSPACE/install/ecbuild" >> "$GITHUB_OUTPUT" + + - name: Cache ecbuild + id: cache + uses: actions/cache@v4 + with: + path: ${{ steps.set-paths.outputs.install-path }} + key: ecbuild-${{ github.action_sha }}-${{ inputs.os }} + + - name: Build and install ecbuild + if: steps.cache.outputs.cache-hit != 'true' + shell: bash + run: | + cmake -S "${{ github.action_path }}/../../.." \ + -B "$GITHUB_WORKSPACE/ecbuild-build" \ + -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/ecbuild" + cmake --install "$GITHUB_WORKSPACE/ecbuild-build" From d7f4c08beffc950eb643a4b7e07d52daa22f7eaa Mon Sep 17 00:00:00 2001 From: Oskar Weser Date: Mon, 13 Apr 2026 12:50:40 +0200 Subject: [PATCH 3/4] ci(use-ecbuild): clone fresh source instead of using action_path The ecbuild repo has a symlink loop in tests/bundle_subproj/mybundle/ecbuild that creates an infinitely long path when GitHub Actions extracts the repo tarball. Building from github.action_path triggered this extraction. Fix: clone a fresh shallow copy at github.action_ref and build from there. Also add -DENABLE_TESTS=OFF to cmake to skip the bundle test setup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/actions/use-ecbuild/action.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/actions/use-ecbuild/action.yml b/.github/actions/use-ecbuild/action.yml index 38d66f32..d3433cd2 100644 --- a/.github/actions/use-ecbuild/action.yml +++ b/.github/actions/use-ecbuild/action.yml @@ -2,8 +2,8 @@ name: Use ecbuild description: > Installs ecbuild from the version of this repository referenced in the action call (uses: ecmwf/ecbuild/.github/actions/use-ecbuild@). - The ecbuild source tree is this action's own repository checkout, so the - installed version always matches the referenced ref. + Clones a fresh copy at github.action_ref to avoid the symlink loop in + tests/bundle_subproj/mybundle/ecbuild that breaks tarball extraction. Uses a local cache keyed on the action SHA and OS to avoid rebuilding on repeated runs. @@ -34,11 +34,21 @@ runs: path: ${{ steps.set-paths.outputs.install-path }} key: ecbuild-${{ github.action_sha }}-${{ inputs.os }} + - name: Clone ecbuild source + if: steps.cache.outputs.cache-hit != 'true' + shell: bash + run: | + git clone --depth 1 \ + --branch "${{ github.action_ref }}" \ + https://github.com/ecmwf/ecbuild.git \ + "$RUNNER_TEMP/_ecbuild-src" + - name: Build and install ecbuild if: steps.cache.outputs.cache-hit != 'true' shell: bash run: | - cmake -S "${{ github.action_path }}/../../.." \ - -B "$GITHUB_WORKSPACE/ecbuild-build" \ - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/ecbuild" - cmake --install "$GITHUB_WORKSPACE/ecbuild-build" + cmake -S "$RUNNER_TEMP/_ecbuild-src" \ + -B "$RUNNER_TEMP/_ecbuild-build" \ + -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/ecbuild" \ + -DENABLE_TESTS=OFF + cmake --install "$RUNNER_TEMP/_ecbuild-build" From b3b7e245daddd4af5da53c709df74c81c9f6ed4a Mon Sep 17 00:00:00 2001 From: Oskar Weser Date: Mon, 13 Apr 2026 13:23:27 +0200 Subject: [PATCH 4/4] ci(use-ecbuild): move action to downstream-ci repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ecbuild repo has a symlink loop in tests/bundle_subproj/mybundle/ecbuild that causes GitHub Actions to fail during tarball extraction — this happens before any action code runs, so it cannot be worked around inside the action. Fix: move use-ecbuild to downstream-ci/actions/use-ecbuild (no symlinks). The action clones ecbuild fresh at the given ecbuild-ref input. Update all callers from: ecmwf/ecbuild/.github/actions/use-ecbuild@fix_interface_exports to: ecmwf-enterprise-sandbox/downstream-ci/actions/use-ecbuild@main Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/actions/use-ecbuild/action.yml | 54 -------------------------- 1 file changed, 54 deletions(-) delete mode 100644 .github/actions/use-ecbuild/action.yml diff --git a/.github/actions/use-ecbuild/action.yml b/.github/actions/use-ecbuild/action.yml deleted file mode 100644 index d3433cd2..00000000 --- a/.github/actions/use-ecbuild/action.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Use ecbuild -description: > - Installs ecbuild from the version of this repository referenced in the - action call (uses: ecmwf/ecbuild/.github/actions/use-ecbuild@). - Clones a fresh copy at github.action_ref to avoid the symlink loop in - tests/bundle_subproj/mybundle/ecbuild that breaks tarball extraction. - - Uses a local cache keyed on the action SHA and OS to avoid rebuilding on - repeated runs. - -inputs: - os: - description: 'OS label (used as part of the cache key)' - required: false - default: ubuntu-latest - -outputs: - install-path: - description: 'Absolute path where ecbuild was installed' - value: ${{ steps.set-paths.outputs.install-path }} - -runs: - using: composite - steps: - - name: Set install path - id: set-paths - shell: bash - run: echo "install-path=$GITHUB_WORKSPACE/install/ecbuild" >> "$GITHUB_OUTPUT" - - - name: Cache ecbuild - id: cache - uses: actions/cache@v4 - with: - path: ${{ steps.set-paths.outputs.install-path }} - key: ecbuild-${{ github.action_sha }}-${{ inputs.os }} - - - name: Clone ecbuild source - if: steps.cache.outputs.cache-hit != 'true' - shell: bash - run: | - git clone --depth 1 \ - --branch "${{ github.action_ref }}" \ - https://github.com/ecmwf/ecbuild.git \ - "$RUNNER_TEMP/_ecbuild-src" - - - name: Build and install ecbuild - if: steps.cache.outputs.cache-hit != 'true' - shell: bash - run: | - cmake -S "$RUNNER_TEMP/_ecbuild-src" \ - -B "$RUNNER_TEMP/_ecbuild-build" \ - -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install/ecbuild" \ - -DENABLE_TESTS=OFF - cmake --install "$RUNNER_TEMP/_ecbuild-build"