Skip to content

Commit f1ea081

Browse files
Improve CI workflow and Go version compatibility
1 parent 4332eca commit f1ea081

File tree

3 files changed

+86
-41
lines changed

3 files changed

+86
-41
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ jobs:
2828
go-version: 1.19
2929
cache: true # Enable cache now that we have a go.sum file
3030

31-
# Skip go mod download since we don't have external dependencies yet
32-
# If we add dependencies later, we can uncomment this
33-
# - name: Download dependencies
34-
# run: go mod download
31+
# We don't need go mod download since we don't have external dependencies
3532

3633
- name: Build
3734
run: go build -v ./cmd/stremax
@@ -47,7 +44,6 @@ jobs:
4744
name: Test
4845
runs-on: ubuntu-latest
4946
timeout-minutes: 10
50-
needs: build
5147

5248
steps:
5349
- name: Checkout code
@@ -146,7 +142,6 @@ jobs:
146142
name: Benchmarks
147143
runs-on: ubuntu-latest
148144
timeout-minutes: 5
149-
needs: test
150145

151146
steps:
152147
- name: Checkout code
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Go Compatibility
2+
3+
on:
4+
workflow_dispatch: # Allow manual triggering
5+
schedule:
6+
- cron: '0 0 * * 0' # Run weekly on Sundays at midnight UTC
7+
8+
jobs:
9+
test-compatibility:
10+
name: Test Go Compatibility
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
go-version: [1.16, 1.17, 1.18, 1.19, 1.20, 1.21]
15+
fail-fast: false # Continue with other tests even if one fails
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Go ${{ matrix.go-version }}
22+
uses: actions/setup-go@v3
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
cache: false # Disable cache for compatibility testing
26+
27+
- name: Display Go version
28+
run: go version
29+
30+
- name: Build
31+
run: go build -v ./cmd/stremax || echo "Build failed with Go ${{ matrix.go-version }}"
32+
33+
- name: Run tests
34+
run: go test ./... || echo "Tests failed with Go ${{ matrix.go-version }}"

run_tests.sh

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,52 @@ echo "=================================="
1313
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
1414
echo -e "${YELLOW}Using Go version: ${GO_VERSION}${NC}"
1515

16-
# Only run go mod download if we're using Go 1.11 or higher
17-
if [ "$(printf '%s\n' "1.11" "$GO_VERSION" | sort -V | head -n1)" = "1.11" ]; then
18-
echo -e "${YELLOW}Go modules supported. Checking dependencies...${NC}"
19-
# Skip go mod download since we don't have external dependencies yet
20-
# If we add dependencies later, we can uncomment this
21-
# go mod download
16+
# Function to compare versions
17+
version_gt() {
18+
test "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" != "$1"
19+
}
20+
21+
# Only run go mod commands if we're using Go 1.11 or higher
22+
if version_gt "$GO_VERSION" "1.10"; then
23+
echo -e "${YELLOW}Go modules supported (Go $GO_VERSION).${NC}"
24+
25+
# We don't need go mod download since we don't have external dependencies yet
26+
# If we add dependencies later, we can uncomment this
27+
# echo -e "${YELLOW}Downloading dependencies...${NC}"
28+
# go mod download
2229
else
23-
echo -e "${YELLOW}Go modules not supported in this version. Skipping dependency check.${NC}"
30+
echo -e "${YELLOW}Go modules not supported in this version (Go $GO_VERSION). Skipping module commands.${NC}"
2431
fi
2532

2633
# Format check
2734
echo -e "\n${YELLOW}Checking code formatting...${NC}"
2835
if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then
29-
echo -e "${RED}The following files need formatting:${NC}"
30-
gofmt -l .
31-
echo -e "${YELLOW}Running gofmt to fix formatting issues...${NC}"
32-
gofmt -w .
33-
echo -e "${GREEN}Formatting fixed.${NC}"
36+
echo -e "${RED}The following files need formatting:${NC}"
37+
gofmt -l .
38+
echo -e "${YELLOW}Running gofmt to fix formatting issues...${NC}"
39+
gofmt -w .
40+
echo -e "${GREEN}Formatting fixed.${NC}"
3441
else
35-
echo -e "${GREEN}All files are properly formatted.${NC}"
42+
echo -e "${GREEN}All files are properly formatted.${NC}"
3643
fi
3744

3845
# Lint check
3946
echo -e "\n${YELLOW}Running linter...${NC}"
4047
if command -v golint > /dev/null; then
41-
golint ./...
48+
golint ./...
4249
else
43-
echo -e "${RED}golint not installed. Installing...${NC}"
44-
go install golang.org/x/lint/golint@latest
45-
$(go env GOPATH)/bin/golint ./...
50+
echo -e "${RED}golint not installed. Installing...${NC}"
51+
if version_gt "$GO_VERSION" "1.16"; then
52+
go install golang.org/x/lint/golint@latest
53+
else
54+
go get -u golang.org/x/lint/golint
55+
fi
56+
57+
if command -v golint > /dev/null; then
58+
golint ./...
59+
else
60+
$(go env GOPATH)/bin/golint ./...
61+
fi
4662
fi
4763

4864
# Vet check
@@ -73,25 +89,25 @@ go build -v ./cmd/stremax
7389
# Run examples
7490
echo -e "\n${YELLOW}Running example programs...${NC}"
7591
if [ -f "./stremax" ]; then
76-
echo -e "${YELLOW}Running simple.sx${NC}"
77-
./stremax run -file ./examples/simple.sx
78-
79-
echo -e "\n${YELLOW}Running arithmetic.sx${NC}"
80-
./stremax run -file ./examples/arithmetic.sx
81-
82-
echo -e "\n${YELLOW}Running strings.sx${NC}"
83-
./stremax run -file ./examples/strings.sx
84-
85-
echo -e "\n${YELLOW}Running conditionals.sx${NC}"
86-
./stremax run -file ./examples/conditionals.sx
87-
88-
echo -e "\n${YELLOW}Running boolean.sx${NC}"
89-
./stremax run -file ./examples/boolean.sx
90-
91-
echo -e "\n${YELLOW}Running combined.sx${NC}"
92-
./stremax run -file ./examples/combined.sx
92+
echo -e "${YELLOW}Running simple.sx${NC}"
93+
./stremax run -file ./examples/simple.sx
94+
95+
echo -e "\n${YELLOW}Running arithmetic.sx${NC}"
96+
./stremax run -file ./examples/arithmetic.sx
97+
98+
echo -e "\n${YELLOW}Running strings.sx${NC}"
99+
./stremax run -file ./examples/strings.sx
100+
101+
echo -e "\n${YELLOW}Running conditionals.sx${NC}"
102+
./stremax run -file ./examples/conditionals.sx
103+
104+
echo -e "\n${YELLOW}Running boolean.sx${NC}"
105+
./stremax run -file ./examples/boolean.sx
106+
107+
echo -e "\n${YELLOW}Running combined.sx${NC}"
108+
./stremax run -file ./examples/combined.sx
93109
else
94-
echo -e "${RED}stremax binary not found. Build failed?${NC}"
110+
echo -e "${RED}stremax binary not found. Build failed?${NC}"
95111
fi
96112

97113
echo -e "\n${GREEN}All tests completed!${NC}"

0 commit comments

Comments
 (0)