Skip to content

Commit

Permalink
Merge pull request #1396 from gofr-dev/release/v1.31.0
Browse files Browse the repository at this point in the history
Release/v1.31.0
  • Loading branch information
aryanmehrotra authored Jan 20, 2025
2 parents a197221 + 4429d3e commit fc8616b
Show file tree
Hide file tree
Showing 127 changed files with 4,246 additions and 865 deletions.
71 changes: 57 additions & 14 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,22 @@ jobs:
run: |
go mod download
- name: Test
- name: Test and Count Warnings
run: |
export APP_ENV=test
go test gofr.dev/pkg/... -v -short -coverprofile package.cov -coverpkg=gofr.dev/pkg/...
warning_count=$(go test gofr.dev/pkg/... -v -short -coverprofile package.cov -coverpkg=gofr.dev/pkg/... | tee /dev/tty | grep -c "WARNING" || true)
grep -v '/mock_' package.cov > profile.cov
go tool cover -func profile.cov
codeCoverage=$(go tool cover -func profile.cov | awk '/total/ {print substr($3, 1, length($3)-1)}')
echo "Warnings found: $warning_count"
echo "warning_count=$warning_count" >> $GITHUB_ENV
echo "CODE_COVERAGE=$codeCoverage" >> $GITHUB_ENV
- name: Fail if too many warnings
run: |
if [ ${{ env.warning_count }} -gt 10 ]; then
echo "Too many warnings: ${{ env.warning_count }}"
exit 1
fi
- name: Upload Test Coverage
if: ${{ matrix.go-version == '1.22'}}
Expand Down Expand Up @@ -155,8 +165,10 @@ jobs:
# - name: Check if code-coverage is greater than threshold
# run: |
# codeCoverage=${{ env.CODE_COVERAGE }}
# codeCoverage=${codeCoverage%??}
# if [[ $codeCoverage -lt 92 ]]; then echo "code coverage cannot be less than 92%, currently its ${{ env.CODE_COVERAGE }}%" && exit 1; fi;
# if (( $(echo "$codeCoverage < 92" | bc -l) )); then
# echo "code coverage cannot be less than 92%, currently its $codeCoverage%"
# exit 1
# fi
Submodule-Unit-Testing:
name: Submodule Unit Testing (v${{ matrix.go-version }})🛠
runs-on: ubuntu-latest
Expand Down Expand Up @@ -192,11 +204,22 @@ jobs:
# Run tests for the submodule and generate coverage
export APP_ENV=test
go test ./... -v -short -coverprofile=${module_name}.cov -coverpkg=./...
warning_count=$(go test ./... -v -short -coverprofile=${module_name}.cov -coverpkg=./... | tee /dev/tty | grep -c "WARNING" || true)
total_warning_count=$((total_warning_count + warning_count))
# Return to the root directory
cd -
done
echo "Total warnings found: $total_warning_count"
echo "total_warning_count=$total_warning_count" >> $GITHUB_ENV
- name: Fail if too many warnings
run: |
if [ ${{ env.total_warning_count }} -gt 10 ]; then
echo "Too many warnings: ${{ env.total_warning_count }}"
exit 1
fi
- name: Upload Coverage Reports
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -236,26 +259,46 @@ jobs:
code_quality:
name: Code Quality🎖️
runs-on: ubuntu-latest
container: "golangci/golangci-lint:v1.62.0"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up Go environment
uses: actions/setup-go@v4
with:
go-version: '1.22'
cache: false

- name: Get dependencies
run: go get -v -t -d ./...
- name: Lint Root Module
run: |
echo "Linting root module..."
golangci-lint run --timeout 9m0s
go mod tidy
- name: Lint Root Module
uses: golangci/golangci-lint-action@v3
with:
version: v1.62
working-directory: .
args: >
--out-format=colored-line-number
--timeout=5m
- name: Lint Submodules
run: |
echo "Searching for submodules..."
total_errors=0 # Initialize error counter
for module in $(find pkg -name "go.mod" -exec dirname {} \;); do
echo "Linting submodule: $module"
# Change directory to the submodule and run golangci-lint
cd $module
go mod tidy
golangci-lint run --timeout 9m0s
cd -
done
golangci-lint run --timeout 9m0s || total_errors=$((total_errors + 1))
cd - # Return to the root directory
done
echo "Total submodule lint errors: $total_errors"
if [ $total_errors -gt 0 ]; then
echo "Linting failed for $total_errors submodule(s)."
exit 1 # Fail the job if there are linting errors in submodules
fi
linting_party:
name: Linting Party🥳
Expand Down
8 changes: 2 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ linters-settings:
min-complexity: 10
goimports:
local-prefixes: github.com/golangci/golangci-lint
golint:
min-confidence: 0
mnd:
checks:
- argument
Expand All @@ -50,8 +48,6 @@ linters-settings:
- (gofr.dev/pkg/gofr/Logger).Errorf
lll:
line-length: 140
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
Expand Down Expand Up @@ -98,14 +94,15 @@ linters:
enable:
- asciicheck
- bodyclose
- copyloopvar
- dogsled
- dupl
- err113
- errcheck
- errorlint
- exhaustive
- exportloopref
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
Expand All @@ -114,7 +111,6 @@ linters:
- gocyclo
- godot
- gofmt
- goimports
- goprintffuncname
- gosec
- gosimple
Expand Down
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Testing is a crucial aspect of software development, and adherence to these guid
- Prefix unit test functions with `Test`.
- Use clear and descriptive names.
```go
func TestFunctionName(t *testing.T) {
// Test logic
func TestFunctionName(t *testing.T) {
// Test logic
}
```

Expand Down Expand Up @@ -78,8 +78,9 @@ docker run --name kafka-1 -p 9092:9092 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_CFG_NODE_ID=1 \
-v kafka_data:/bitnami \
bitnami/kafka:3.4

bitnami/kafka:3.4
docker pull scylladb/scylla
docker run --name scylla -d -p 2025:9042 scylladb/scylla



Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ package main
import "gofr.dev/pkg/gofr"

func main() {
app := gofr.New()
app := gofr.New()

app.GET("/greet", func(ctx *gofr.Context) (interface{}, error) {
return "Hello World!", nil
})
app.GET("/greet", func(ctx *gofr.Context) (interface{}, error) {
return "Hello World!", nil
})

app.Run() // listens and serves on localhost:8000
app.Run() // listens and serves on localhost:8000
}
```

Expand Down Expand Up @@ -119,6 +119,18 @@ Help us make GoFr even better:

---

## 🔒 **Secure Cloning**
To securely clone the GoFr repository, you can use HTTPS or SSH:

### Cloning with HTTPS
```bash
git clone https://github.com/gofr-dev/gofr.git
```
### Cloning with SSH
```bash
git clone [email protected]:gofr-dev/gofr.git
```

### 🎁 **Get a GoFr T-Shirt & Stickers!**

If your PR is merged, or if you contribute by writing articles or promoting GoFr, we invite you to fill out [this form](https://forms.gle/R1Yz7ZzY3U5WWTgy5) to claim your GoFr merchandise as a token of our appreciation!
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced-guide/circuit-breaker/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func main() {

app.AddHTTPService("order", "https://order-func",
&service.CircuitBreakerConfig{
// Number of consecutive failed requests after which circuit breaker will be enabled
// Number of consecutive failed requests after which circuit breaker will be enabled
Threshold: 4,
// Time interval at which circuit breaker will hit the aliveness endpoint.
Interval: 1 * time.Second,
Interval: 1 * time.Second,
},
)

Expand Down
10 changes: 5 additions & 5 deletions docs/advanced-guide/custom-spans-in-tracing/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ and returns a trace.Span.

```go
func MyHandler(c context.Context) error {
span := c.Trace("my-custom-span")
defer span.Close()
// Do some work here
return nil
span := c.Trace("my-custom-span")
defer span.Close()

// Do some work here
return nil
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/advanced-guide/gofr-errors/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ automatically handle HTTP status code selection. These include:
#### Usage:
To use the predefined HTTP errors, users can simply call them using GoFr's http package:
```go
err := http.ErrorMissingParam{Param: []string{"id"}}
err := http.ErrorMissingParam{Param: []string{"id"}}
```

## Database Errors
Expand Down
Loading

0 comments on commit fc8616b

Please sign in to comment.