Skip to content

Commit

Permalink
Avoid git warnings on shallow checkout (jaegertracing#5455)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
Many of GH workflows are logging warnings like this:
```
Run make install-test-tools
fatal: No names found, cannot describe anything.
fatal: No names found, cannot describe anything.
fatal: No names found, cannot describe anything.
fatal: No names found, cannot describe anything.
fatal: No names found, cannot describe anything.
```
This is because we typically do a shallow checkout of the repo without
tags.

## Description of the changes
- Check for shallow checkout and don't run `git describe`

## How was this change tested?
- CI `lint`: no warnings logged when calling `make`
```
$ make echo-version
GIT_CLOSEST_TAG=0.0.0
```

Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro authored May 16, 2024
1 parent acad244 commit 7df05d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci-lint-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
# See https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
permissions: # added using https://github.com/step-security/secure-workflows
contents: read

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -30,11 +30,14 @@ jobs:
with:
go-version: 1.22.x

- name: Print Jaeger version
run: make echo-version

- name: Install tools
run: make install-test-tools

- name: Lint
run: make lint

- name: Ensure PR is not on main branch
uses: ./.github/actions/block-pr-not-on-main
uses: ./.github/actions/block-pr-not-on-main
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ IMPORT_LOG=.import.log
COLORIZE ?= | $(SED) 's/PASS/✅ PASS/g' | $(SED) 's/FAIL/❌ FAIL/g' | $(SED) 's/SKIP/🔕 SKIP/g'

GIT_SHA=$(shell git rev-parse HEAD)
GIT_CLOSEST_TAG=$(shell git describe --abbrev=0 --tags)
GIT_SHALLOW_CLONE := $(shell git rev-parse --is-shallow-repository)
# Some of GitHub Actions workflows do a shallow checkout without tags. This avoids logging warnings from git.
GIT_CLOSEST_TAG=$(shell if [ "$(GIT_SHALLOW_CLONE)" = "false" ]; then git describe --abbrev=0 --tags; else echo 0.0.0; fi)
ifneq ($(GIT_CLOSEST_TAG),$(shell echo ${GIT_CLOSEST_TAG} | grep -E "$(semver_regex)"))
$(warning GIT_CLOSEST_TAG=$(GIT_CLOSEST_TAG) is not in the semver format $(semver_regex))
endif
Expand All @@ -91,9 +93,15 @@ include Makefile.Crossdock.mk
.PHONY: test-and-lint
test-and-lint: test fmt lint

.PHONY: echo-version
echo-version:
@echo "GIT_CLOSEST_TAG=$(GIT_CLOSEST_TAG)"

.PHONY: echo-all-pkgs
echo-all-pkgs:
@echo $(ALL_PKGS) | tr ' ' '\n' | sort

.PHONY: echo-all-srcs
echo-all-srcs:
@echo $(ALL_SRC) | tr ' ' '\n' | sort

Expand Down Expand Up @@ -474,10 +482,6 @@ generate-mocks: install-tools
$(MOCKERY) --all --dir ./storage/spanstore/ --output ./storage/spanstore/mocks
$(MOCKERY) --all --dir ./proto-gen/storage_v1/ --output ./proto-gen/storage_v1/mocks

.PHONY: echo-version
echo-version:
@echo $(GIT_CLOSEST_TAG)

.PHONY: certs
certs:
cd pkg/config/tlscfg/testdata && ./gen-certs.sh
Expand Down

0 comments on commit 7df05d9

Please sign in to comment.