Skip to content

Commit c74aabd

Browse files
committed
ci: fix workflows, remove redundant steps
1 parent d25b9fd commit c74aabd

8 files changed

Lines changed: 92 additions & 294 deletions

File tree

.github/workflows/test.yml

Lines changed: 5 additions & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Build and Test"
1+
name: "Run Tests"
22

33
on:
44
push:
@@ -10,46 +10,13 @@ on:
1010
workflow_dispatch:
1111

1212
concurrency:
13-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.ref }}
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1414
cancel-in-progress: true
1515

1616
jobs:
17-
build:
18-
name: Build ${{ matrix.os }}
19-
strategy:
20-
fail-fast: false
21-
matrix:
22-
os: [ ubuntu, windows, macos ]
23-
runs-on: ${{ matrix.os }}-latest
24-
steps:
25-
- name: Checkout code
26-
uses: actions/checkout@v5
27-
with:
28-
ref: ${{ github.event.pull_request.head.sha }}
29-
30-
- name: Setup Go with cache
31-
uses: jfrog/.github/actions/install-go-with-cache@main
32-
33-
- name: Install dependencies
34-
run: make deps
35-
36-
- name: Build binary
37-
run: make build
38-
39-
- name: Upload build artifacts
40-
uses: actions/upload-artifact@v4
41-
with:
42-
name: jfrog-evidence-${{ matrix.os }}
43-
path: build/jfrog-evidence*
44-
retention-days: 7
45-
46-
test:
47-
name: Test ${{ matrix.os }}
48-
strategy:
49-
fail-fast: false
50-
matrix:
51-
os: [ ubuntu, windows, macos ]
52-
runs-on: ${{ matrix.os }}-latest
17+
unit-tests:
18+
name: Unit Tests
19+
runs-on: ubuntu-latest
5320
steps:
5421
- name: Checkout code
5522
uses: actions/checkout@v5
@@ -64,196 +31,3 @@ jobs:
6431

6532
- name: Run unit tests
6633
run: make test-unit
67-
68-
test-coverage:
69-
name: Test Coverage Report
70-
runs-on: ubuntu-latest
71-
steps:
72-
- name: Checkout code
73-
uses: actions/checkout@v5
74-
with:
75-
ref: ${{ github.event.pull_request.head.sha }}
76-
77-
- name: Setup Go with cache
78-
uses: jfrog/.github/actions/install-go-with-cache@main
79-
80-
- name: Install dependencies
81-
run: make deps
82-
83-
- name: Run tests with coverage
84-
run: make test
85-
86-
- name: Generate coverage report
87-
run: make coverage
88-
89-
- name: Upload coverage report
90-
uses: actions/upload-artifact@v4
91-
with:
92-
name: coverage-report
93-
path: |
94-
coverage/coverage.out
95-
coverage/coverage.html
96-
retention-days: 30
97-
98-
- name: Display coverage summary
99-
run: |
100-
echo "### Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
101-
echo "" >> $GITHUB_STEP_SUMMARY
102-
echo "```" >> $GITHUB_STEP_SUMMARY
103-
go tool cover -func=coverage/coverage.out | tail -n 1 >> $GITHUB_STEP_SUMMARY
104-
echo "```" >> $GITHUB_STEP_SUMMARY
105-
echo "" >> $GITHUB_STEP_SUMMARY
106-
echo "📊 Full coverage report available in artifacts" >> $GITHUB_STEP_SUMMARY
107-
108-
- name: Check coverage threshold
109-
run: |
110-
COVERAGE=$(go tool cover -func=coverage/coverage.out | grep total | awk '{print $3}' | sed 's/%//')
111-
echo "Total coverage: ${COVERAGE}%"
112-
THRESHOLD=70
113-
if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then
114-
echo "⚠️ Coverage ${COVERAGE}% is below threshold ${THRESHOLD}%"
115-
echo "::warning::Code coverage ${COVERAGE}% is below the recommended threshold of ${THRESHOLD}%"
116-
else
117-
echo "✅ Coverage ${COVERAGE}% meets threshold ${THRESHOLD}%"
118-
fi
119-
120-
integration-test:
121-
name: Integration Tests
122-
runs-on: ubuntu-latest
123-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
124-
steps:
125-
- name: Checkout code
126-
uses: actions/checkout@v5
127-
128-
- name: Setup Go with cache
129-
uses: jfrog/.github/actions/install-go-with-cache@main
130-
131-
- name: Install dependencies
132-
run: make deps
133-
134-
- name: Run integration tests
135-
run: make test-integration
136-
continue-on-error: true
137-
env:
138-
INTEGRATION_TEST: true
139-
140-
benchmark:
141-
name: Benchmarks
142-
runs-on: ubuntu-latest
143-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
144-
steps:
145-
- name: Checkout code
146-
uses: actions/checkout@v5
147-
148-
- name: Setup Go with cache
149-
uses: jfrog/.github/actions/install-go-with-cache@main
150-
151-
- name: Install dependencies
152-
run: make deps
153-
154-
- name: Run benchmarks
155-
run: make benchmark
156-
157-
- name: Upload benchmark results
158-
uses: actions/upload-artifact@v4
159-
with:
160-
name: benchmark-results
161-
path: benchmark-results.txt
162-
retention-days: 30
163-
if: always()
164-
165-
multi-platform-build:
166-
name: Multi-Platform Build
167-
runs-on: ubuntu-latest
168-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
169-
steps:
170-
- name: Checkout code
171-
uses: actions/checkout@v5
172-
173-
- name: Setup Go with cache
174-
uses: jfrog/.github/actions/install-go-with-cache@main
175-
176-
- name: Install dependencies
177-
run: make deps
178-
179-
- name: Build for all platforms
180-
run: make build-all
181-
182-
- name: Upload multi-platform artifacts
183-
uses: actions/upload-artifact@v4
184-
with:
185-
name: jfrog-evidence-all-platforms
186-
path: build/
187-
retention-days: 30
188-
189-
code-quality:
190-
name: Code Quality Check
191-
runs-on: ubuntu-latest
192-
steps:
193-
- name: Checkout code
194-
uses: actions/checkout@v5
195-
with:
196-
ref: ${{ github.event.pull_request.head.sha }}
197-
198-
- name: Setup Go with cache
199-
uses: jfrog/.github/actions/install-go-with-cache@main
200-
201-
- name: Install dependencies
202-
run: make deps
203-
204-
- name: Install tools
205-
run: make install-tools
206-
207-
- name: Format check
208-
run: |
209-
make fmt
210-
if [ -n "$(git status --porcelain)" ]; then
211-
echo "::error::Code is not properly formatted. Please run 'make fmt'"
212-
git diff
213-
exit 1
214-
fi
215-
216-
- name: Run vet
217-
run: make vet
218-
219-
- name: Run linter
220-
run: make lint
221-
continue-on-error: true
222-
223-
summary:
224-
name: Test Summary
225-
needs: [build, test, test-coverage, code-quality]
226-
runs-on: ubuntu-latest
227-
if: always()
228-
steps:
229-
- name: Summary
230-
run: |
231-
echo "## Workflow Summary" >> $GITHUB_STEP_SUMMARY
232-
echo "" >> $GITHUB_STEP_SUMMARY
233-
234-
if [[ "${{ needs.build.result }}" == "success" ]]; then
235-
echo "✅ **Build:** Passed" >> $GITHUB_STEP_SUMMARY
236-
else
237-
echo "❌ **Build:** Failed" >> $GITHUB_STEP_SUMMARY
238-
fi
239-
240-
if [[ "${{ needs.test.result }}" == "success" ]]; then
241-
echo "✅ **Tests:** Passed" >> $GITHUB_STEP_SUMMARY
242-
else
243-
echo "❌ **Tests:** Failed" >> $GITHUB_STEP_SUMMARY
244-
fi
245-
246-
if [[ "${{ needs.test-coverage.result }}" == "success" ]]; then
247-
echo "✅ **Coverage:** Generated" >> $GITHUB_STEP_SUMMARY
248-
else
249-
echo "❌ **Coverage:** Failed" >> $GITHUB_STEP_SUMMARY
250-
fi
251-
252-
if [[ "${{ needs.code-quality.result }}" == "success" ]]; then
253-
echo "✅ **Code Quality:** Passed" >> $GITHUB_STEP_SUMMARY
254-
else
255-
echo "⚠️ **Code Quality:** Issues found" >> $GITHUB_STEP_SUMMARY
256-
fi
257-
258-
echo "" >> $GITHUB_STEP_SUMMARY
259-
echo "📦 Artifacts available for download in the workflow run" >> $GITHUB_STEP_SUMMARY

Makefile

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -105,47 +105,6 @@ coverage: test ## Generate test coverage report
105105
$(GOCMD) tool cover -html=$(COVERAGE_DIR)/coverage.out -o $(COVERAGE_DIR)/coverage.html
106106
@echo "$(GREEN)Coverage report generated: $(COVERAGE_DIR)/coverage.html$(NC)"
107107

108-
coverage-view: coverage ## View coverage report in browser
109-
@echo "$(GREEN)Opening coverage report...$(NC)"
110-
open $(COVERAGE_DIR)/coverage.html 2>/dev/null || xdg-open $(COVERAGE_DIR)/coverage.html 2>/dev/null || echo "Please open $(COVERAGE_DIR)/coverage.html manually"
111-
112-
benchmark: ## Run benchmarks
113-
@echo "$(GREEN)Running benchmarks...$(NC)"
114-
$(GOTEST) -bench=. -benchmem ./$(EVIDENCE_DIR)/...
115-
116-
##@ Mocking
117-
118-
# This target is generic and automatically finds all files with //go:generate mockgen annotations
119-
# No need to update this when adding new mocks - just add the annotation to your interface
120-
mocks: install-mockgen ## Generate all mocks
121-
@echo "$(GREEN)Generating mocks...$(NC)"
122-
@mkdir -p $(MOCK_DIR)
123-
@echo "$(YELLOW)Finding and generating all mocks from go:generate annotations...$(NC)"
124-
@export PROJECT_DIR=$(shell pwd) && \
125-
find $(EVIDENCE_DIR) -name "*.go" -type f -exec grep -l "//go:generate.*mockgen" {} \; | while read file; do \
126-
echo "$(YELLOW)Processing $$file...$(NC)"; \
127-
cd $(shell pwd) && go generate $$file; \
128-
done
129-
@echo "$(GREEN)Mock generation complete$(NC)"
130-
131-
mocks-specific: install-mockgen ## Generate mocks for specific interfaces (fallback for manual generation)
132-
@echo "$(GREEN)Generating specific mocks manually...$(NC)"
133-
@mkdir -p $(MOCK_DIR)
134-
@# Find all interfaces in the codebase and generate mocks
135-
@for file in $$(find $(EVIDENCE_DIR) -name "*.go" -type f); do \
136-
if grep -q "^type.*interface" $$file 2>/dev/null; then \
137-
interfaces=$$(grep "^type.*interface" $$file | awk '{print $$2}'); \
138-
if [ ! -z "$$interfaces" ]; then \
139-
echo "$(YELLOW)Generating mocks for $$file...$(NC)"; \
140-
$(MOCKGEN) -source=$$file -destination=$(MOCK_DIR)/mock_$$(basename $$file) -package=mocks 2>/dev/null || true; \
141-
fi; \
142-
fi; \
143-
done
144-
@echo "$(GREEN)Specific mock generation complete$(NC)"
145-
146-
clean-mocks: ## Remove generated mocks
147-
@echo "$(YELLOW)Cleaning mocks...$(NC)"
148-
rm -rf $(MOCK_DIR)
149108

150109
##@ Code Quality
151110

@@ -222,16 +181,6 @@ clean-all: clean clean-mocks ## Clean everything including mocks and vendor
222181
rm -rf vendor/
223182
@echo "$(GREEN)Full clean complete$(NC)"
224183

225-
##@ Docker
226-
227-
docker-build: ## Build Docker image
228-
@echo "$(GREEN)Building Docker image...$(NC)"
229-
docker build -t $(BINARY_NAME):$(VERSION) -t $(BINARY_NAME):latest .
230-
@echo "$(GREEN)Docker build complete$(NC)"
231-
232-
docker-run: ## Run Docker container
233-
@echo "$(GREEN)Running Docker container...$(NC)"
234-
docker run --rm -it $(BINARY_NAME):latest
235184

236185
##@ Git Hooks
237186

@@ -266,16 +215,5 @@ fixme: ## Show FIXME items in code
266215
@echo "$(YELLOW)FIXME items in code:$(NC)"
267216
@grep -r "FIXME" $(EVIDENCE_DIR) --include="*.go" || echo "No FIXME items found"
268217

269-
stats: ## Show code statistics
270-
@echo "$(GREEN)Code Statistics:$(NC)"
271-
@echo "Lines of Go code:"
272-
@find $(EVIDENCE_DIR) -name "*.go" -not -path "*/vendor/*" -not -path "*/mocks/*" | xargs wc -l | tail -1
273-
@echo ""
274-
@echo "Number of Go files:"
275-
@find $(EVIDENCE_DIR) -name "*.go" -not -path "*/vendor/*" -not -path "*/mocks/*" | wc -l
276-
@echo ""
277-
@echo "Number of test files:"
278-
@find $(EVIDENCE_DIR) -name "*_test.go" -not -path "*/vendor/*" | wc -l
279-
280218
# Default target
281219
.DEFAULT_GOAL := help
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package create
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestGetDescription(t *testing.T) {
10+
description := GetDescription()
11+
assert.NotEmpty(t, description)
12+
assert.Contains(t, description, "evidence")
13+
}
14+
15+
func TestGetArguments(t *testing.T) {
16+
args := GetArguments()
17+
assert.NotNil(t, args)
18+
assert.Empty(t, args) // Currently returns empty slice
19+
}

evidence/cli/docs/get/help_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package get
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestGetDescription(t *testing.T) {
10+
description := GetDescription()
11+
assert.NotEmpty(t, description)
12+
assert.Contains(t, description, "evidence")
13+
}
14+
15+
func TestGetArguments(t *testing.T) {
16+
args := GetArguments()
17+
assert.NotNil(t, args)
18+
assert.Empty(t, args) // Currently returns empty slice
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package verify
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestGetDescription(t *testing.T) {
10+
description := GetDescription()
11+
assert.NotEmpty(t, description)
12+
assert.Contains(t, description, "evidence")
13+
}
14+
15+
func TestGetArguments(t *testing.T) {
16+
args := GetArguments()
17+
assert.NotNil(t, args)
18+
assert.Empty(t, args) // Currently returns empty slice
19+
}

0 commit comments

Comments
 (0)