@@ -37,47 +37,17 @@ jobs:
3737 go-version : ${{ matrix.go }}
3838 check-latest : true
3939
40- - name : Download dependencies with retry
41- run : |
42- set -e
43- echo "Downloading Go dependencies..."
44-
45- # Function to download with retry
46- download_with_retry() {
47- local attempt=1
48- local max_attempts=3
49-
50- while [ $attempt -le $max_attempts ]; do
51- echo "Attempt $attempt of $max_attempts"
52-
53- if go mod download; then
54- echo "Download successful on attempt $attempt"
55- return 0
56- else
57- echo "Download failed on attempt $attempt"
58- if [ $attempt -lt $max_attempts ]; then
59- echo "Cleaning cache and retrying..."
60- go clean -modcache
61- go clean -cache
62- sleep 2
63- fi
64- attempt=$((attempt + 1))
65- fi
66- done
67-
68- echo "All download attempts failed"
69- return 1
70- }
40+ - name : Install Task
41+ uses : go-task/setup-task@v1
7142
72- # Try download with retry logic
73- download_with_retry
43+ - name : Show build info
44+ run : task info
7445
75- echo "Verifying module dependencies..."
76- go mod verify
77- echo "Dependencies verified successfully"
46+ - name : Download dependencies
47+ run : task deps
7848
7949 - name : Build
80- run : go build -v ./...
50+ run : task build
8151
8252 - name : Run tests with enhanced reporting
8353 id : test
8959 echo "" >> $GITHUB_STEP_SUMMARY
9060
9161 echo "Running tests with coverage..."
92- go test -v -race -coverprofile= coverage.out ./... 2>&1 | tee test-output.log
62+ task test: coverage 2>&1 | tee test-output.log
9363
9464 # Extract test results for summary
9565 TEST_STATUS=$?
@@ -151,9 +121,8 @@ jobs:
151121 - name : Generate coverage report
152122 if : always()
153123 run : |
154- if [ -f coverage.out ]; then
155- go tool cover -html=coverage.out -o coverage.html
156- COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}')
124+ if [ -f coverage/coverage.out ]; then
125+ COVERAGE=$(go tool cover -func=coverage/coverage.out | grep total | awk '{print $3}')
157126
158127 echo "## 📊 Code Coverage (Go ${{ matrix.go }})" >> $GITHUB_STEP_SUMMARY
159128 echo "" >> $GITHUB_STEP_SUMMARY
@@ -171,7 +140,7 @@ jobs:
171140 temp_coverage=$(mktemp)
172141
173142 # Extract package-level coverage data
174- go tool cover -func=coverage.out | grep -v total | while read line; do
143+ go tool cover -func=coverage/coverage .out | grep -v total | while read line; do
175144 if [[ $line == *".go:"* ]]; then
176145 # Extract package path from file path (everything before the filename)
177146 filepath=$(echo "$line" | awk '{print $1}')
@@ -217,16 +186,16 @@ jobs:
217186 name : test-results-go-${{ matrix.go }}
218187 path : |
219188 test-output.log
220- coverage.out
221- coverage.html
189+ coverage/
222190 retention-days : 7
223191
224- - name : Run go vet
192+ - name : Run linters
225193 run : |
226194 echo "## 🔍 Static Analysis (Go ${{ matrix.go }})" >> $GITHUB_STEP_SUMMARY
227195 echo "" >> $GITHUB_STEP_SUMMARY
228196
229- VET_OUTPUT=$(go vet ./... 2>&1 || echo "")
197+ # Run go vet
198+ VET_OUTPUT=$(task lint:vet 2>&1 || echo "")
230199 VET_STATUS=$?
231200
232201 if [ $VET_STATUS -eq 0 ]; then
@@ -240,21 +209,22 @@ jobs:
240209 fi
241210 echo "" >> $GITHUB_STEP_SUMMARY
242211
243- exit $VET_STATUS
244-
245- - name : Run go fmt
246- run : |
247- FMT_OUTPUT=$(gofmt -s -l . 2>&1 || echo "")
212+ # Run go fmt check
213+ FMT_OUTPUT=$(task lint:fmt 2>&1 || echo "")
214+ FMT_STATUS=$?
248215
249- if [ -z "$FMT_OUTPUT" ]; then
216+ if [ $FMT_STATUS -eq 0 ]; then
250217 echo "✅ **go fmt:** All files properly formatted" >> $GITHUB_STEP_SUMMARY
251218 else
252219 echo "❌ **go fmt:** Files need formatting" >> $GITHUB_STEP_SUMMARY
253220 echo "" >> $GITHUB_STEP_SUMMARY
254221 echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
255222 echo "$FMT_OUTPUT" >> $GITHUB_STEP_SUMMARY
256223 echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
257- echo "" >> $GITHUB_STEP_SUMMARY
224+ fi
225+
226+ # Exit with error if any linter failed
227+ if [ $VET_STATUS -ne 0 ] || [ $FMT_STATUS -ne 0 ]; then
258228 exit 1
259229 fi
260230
@@ -276,6 +246,7 @@ jobs:
276246 - name : Upload coverage reports to Codecov
277247 uses : codecov/codecov-action@v5
278248 with :
249+ files : ./coverage/coverage.out
279250 flags : Go ${{ matrix.go }}
280251 slug : kjanat/articulate-parser
281252 token : ${{ secrets.CODECOV_TOKEN }}
@@ -297,40 +268,37 @@ jobs:
297268 - name : Checkout repository
298269 uses : actions/checkout@v5
299270
271+ - name : Set up Go
272+ uses : actions/setup-go@v6
273+ with :
274+ go-version-file : go.mod
275+ check-latest : true
276+
277+ - name : Install Task
278+ uses : go-task/setup-task@v1
279+
300280 - name : Set up Docker Buildx
301281 uses : docker/setup-buildx-action@v3
302282
303- - name : Capture build date
304- run : echo "BUILD_TIME=$(git log -1 --format=%cd --date=iso-strict)" >> $GITHUB_ENV
305-
306- - name : Build Docker image (test)
307- uses : docker/build-push-action@v6
308- with :
309- context : .
310- push : false
311- load : true
312- tags : test:latest
313- build-args : |
314- VERSION=test
315- BUILD_TIME=${{ env.BUILD_TIME }}
316- GIT_COMMIT=${{ github.sha }}
317- cache-from : type=gha
318- cache-to : type=gha,mode=max
283+ - name : Build Docker image using Task
284+ run : task docker:build
319285
320- - name : Test Docker image
286+ - name : Test Docker image using Task
321287 run : |
322288 echo "## 🧪 Docker Image Tests" >> $GITHUB_STEP_SUMMARY
323289 echo "" >> $GITHUB_STEP_SUMMARY
324290
325- # Test that the image runs and shows help
291+ # Run Task docker test
292+ task docker:test
293+
326294 echo "**Testing help command:**" >> $GITHUB_STEP_SUMMARY
327295 echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
328- docker run --rm test :latest --help >> $GITHUB_STEP_SUMMARY
296+ docker run --rm articulate-parser :latest --help >> $GITHUB_STEP_SUMMARY
329297 echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
330298 echo "" >> $GITHUB_STEP_SUMMARY
331299
332300 # Test image size
333- IMAGE_SIZE=$(docker image inspect test :latest --format='{{.Size}}' | numfmt --to=iec-i --suffix=B)
301+ IMAGE_SIZE=$(docker image inspect articulate-parser :latest --format='{{.Size}}' | numfmt --to=iec-i --suffix=B)
334302 echo "**Image size:** $IMAGE_SIZE" >> $GITHUB_STEP_SUMMARY
335303 echo "" >> $GITHUB_STEP_SUMMARY
336304
0 commit comments