Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kardolus
GitHub Repository: kardolus/chatgpt-cli
Path: blob/main/scripts/all-tests.sh
2649 views
1
#!/usr/bin/env bash
2
set -euo pipefail
3
4
log() {
5
printf "\n[%s] %s\n" "$(date +'%b %d %I:%M:%S %p')" "$*"
6
}
7
8
# Ensure dependencies are tidy and up to date
9
log "Tidying Go modules and checking for changes..."
10
go mod tidy
11
if ! git diff --exit-code go.mod go.sum; then
12
log "go.mod or go.sum has uncommitted changes after 'go mod tidy'."
13
exit 1
14
fi
15
16
# Ensure Go code is formatted properly
17
log "Checking code format with 'go fmt'..."
18
fmt_output=$(go fmt ./...)
19
if [ -n "$fmt_output" ]; then
20
log "The following files are not formatted properly:"
21
echo "$fmt_output"
22
log "Please run 'go fmt' to fix the formatting issues."
23
exit 1
24
fi
25
26
# Run golangci-lint to check for code issues
27
log "Running golangci-lint..."
28
if ! golangci-lint run; then
29
log "Linting issues detected."
30
exit 1
31
fi
32
33
# Search for TODOs in the codebase, excluding vendor and scripts directories.
34
log "Searching for TODOs..."
35
if ag TODO --ignore-dir vendor --ignore scripts --ignore-case | grep -v 'context\.TODO()' ; then
36
log "Error: Found TODOs in the codebase. Please address them before proceeding."
37
exit 1
38
fi
39
40
# Run tests in parallel for faster execution
41
log "Running unit tests..."
42
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
43
./scripts/unit.sh
44
45
log "Running integration tests..."
46
./scripts/integration.sh
47
48
log "Running contract tests..."
49
./scripts/contract.sh
50
51
log "All tests completed successfully."
52
53