Fix: Both unit test WFs install go conditionally
The original belief was that all repos using the basic unit test
workflow would have a go.mod file present, and that all repos with a
tag check would not. However, an exception has been found, and testing
shows that a conditional install is safe in all cases.
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
Change-Id: I2845815ef509dfe431b71284cd186d7a93a77369
diff --git a/.github/workflows/verify-unit-tests-tag.yaml b/.github/workflows/verify-unit-tests-tag.yaml
index c6f082d..969f4cc 100644
--- a/.github/workflows/verify-unit-tests-tag.yaml
+++ b/.github/workflows/verify-unit-tests-tag.yaml
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2026 The Linux Foundation
name: Gerrit Verify - Unit Tests and Tag Check
-# This workflow does not support Go builds
# yamllint disable-line rule:truthy
on:
@@ -114,6 +113,11 @@
python-version: "3.10"
- name: Install virtualenv
run: pip install virtualenv
+ - name: Install Go
+ if: ${{ hashFiles('go.mod') != '' }}
+ uses: actions/setup-go@v5
+ with:
+ go-version-file: go.mod
- name: Run unit tests
env:
DEST_GOPATH: ${{ inputs.DEST_GOPATH }}
diff --git a/.github/workflows/verify-unit-tests.yaml b/.github/workflows/verify-unit-tests.yaml
index 1bab794..f684295 100644
--- a/.github/workflows/verify-unit-tests.yaml
+++ b/.github/workflows/verify-unit-tests.yaml
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2026 The Linux Foundation
name: Gerrit Verify - Unit Tests
-# Requires a go.mod file to be present in the repo
# yamllint disable-line rule:truthy
on:
@@ -115,6 +114,7 @@
- name: Install virtualenv
run: pip install virtualenv
- name: Install Go
+ if: ${{ hashFiles('go.mod') != '' }}
uses: actions/setup-go@v5
with:
go-version-file: go.mod