Skip to content

Commit

Permalink
action: Clean up the logic to handle go-mod-directory
Browse files Browse the repository at this point in the history
- Partially revert commit cc1a61d [^1] since Cilium updated the Go
  version to 1.24 in main branch [^2].
- Change the default go-mod-directory to the top-level directory to
  match the current code structure in cilium/cilium where go.mod file
  is only in the top-level directory.
- Set setup-go cache-dependency-path parameter to '**/go.sum' so that
  caching works regardless of how go-mod-directory parameter is set.

[^1]: #2871
[^2]: cilium/cilium#37852

Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
  • Loading branch information
michi-covalent committed Feb 28, 2025
1 parent cf35690 commit 5f37277
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ inputs:
default: '*/cilium-cli'
go-mod-directory:
description: >
Override the directory that contains go.mod when building the Cilium CLI
Specify the directory that contains go.mod when building the Cilium CLI
from the source. By default, This action assumes that go.mod is in the
directory specified in the local-path parameter. Set this parameter to '.'
if go.mod is in the top-level directory.
top-level directory.
required: true
default: '.'
binary-dir:
description: 'Directory to store Cilium CLI executable'
required: true
Expand Down Expand Up @@ -46,22 +47,15 @@ runs:
run: |
CLI_PATH=$(find . -iwholename '${{ inputs.local-path }}' -type d -not -path './.git/*' -not -path './vendor/*' | sort | tail -n 1)
echo path="${CLI_PATH}" >> $GITHUB_OUTPUT
if [[ -z "${{ inputs.go-mod-directory }}" ]]; then
echo go-mod-path="${CLI_PATH}/go.mod" >> $GITHUB_OUTPUT
echo go-sum-path="${CLI_PATH}/go.sum" >> $GITHUB_OUTPUT
else
echo go-mod-path="${{ inputs.go-mod-directory }}/go.mod" >> $GITHUB_OUTPUT
echo go-sum-path="${{ inputs.go-mod-directory }}/go.sum" >> $GITHUB_OUTPUT
fi
echo go-mod-path="${{ inputs.go-mod-directory }}/go.mod" >> $GITHUB_OUTPUT
- name: Setup Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
if: ${{ steps.build-cli.outputs.path != '' }}
with:
# renovate: datasource=golang-version depName=go
go-version: 1.24.0
go-version-file: '${{ steps.build-cli.outputs.go-mod-path }}'
cache: true
cache-dependency-path: '${{ steps.build-cli.outputs.go-sum-path }}'
cache-dependency-path: '**/go.sum'

- name: Build Cilium CLI from source
if: ${{ steps.build-cli.outputs.path != '' }}
Expand Down

0 comments on commit 5f37277

Please sign in to comment.