Skip to content

Commit

Permalink
upgrade to v2
Browse files Browse the repository at this point in the history
    - improve rake tasks
    - upgrade docker dependencies
    - upgrade go version
    - upgrade github actions
  • Loading branch information
vigo committed Aug 27, 2023
1 parent bfdc26e commit b670745
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 20 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.19
uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version-file: "go.mod"
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Get dependencies
run: go mod download
uses: actions/checkout@v3

- name: Run tests
run: go test -race -count=1 -coverprofile=coverage.txt -covermode=atomic ./...
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM golang:1.19-alpine AS builder
FROM golang:1.21-alpine AS builder
WORKDIR /go/src/github.com/vigo/statoo
COPY . .
RUN apk add --no-cache git=2.36.3-r0 \
ca-certificates=20220614-r0 \
RUN apk add --no-cache git=2.40.1-r0 \
ca-certificates=20230506-r0 \
&& CGO_ENABLED=0 \
GOOS=linux \
go build -ldflags="-X 'github.com/vigo/statoo/app/version.CommitHash=$(git rev-parse HEAD)'" -a -installsuffix cgo -o statoo .
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ you can make the same kind of request and get a kind-of same response since
You can install from the source;

```bash
go install github.com/vigo/statoo@latest
go install github.com/vigo/statoo/v2@latest # or
```

or, you can install from `brew`:
Expand Down Expand Up @@ -211,7 +211,9 @@ statoo -commithash
$ rake -T
rake default # show avaliable tasks (default task)
rake docker:build # Build image (locally)
rake docker:lint # lint Dockerfile
rake docker:run[param] # Run image (locally)
rake release[revision] # release new version major,minor,patch, default: patch
rake test:run[verbose] # run tests, generate coverage
rake test:show_coverage # show coverage after running tests
Expand All @@ -230,6 +232,14 @@ docker run vigo/statoo -h
docker run vigo/statoo -json -find "Meetup organization" https://vigo.io
```
to run docker locally via rake task:
```bash
rake docker:build
rake docker:run["-h"]
rake docker:run["https://ugur.ozyilmazel.com"]
```
---
## Contributor(s)
Expand Down
24 changes: 24 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,34 @@ end

# docker
# -----------------------------------------------------------------------------
DOCKER_IMAGE_TAG = 'statoo:latest'
namespace :docker do
desc "lint Dockerfile"
task :lint do
system "hadolint Dockerfile"
end

desc "Run image (locally)"
task :run, [:param] do |_, args|
cmd_args = [args.param] + args.extras
system %{
docker run #{DOCKER_IMAGE_TAG} #{cmd_args.join(' ')}
}
exit $?.exitstatus
end

desc "Build image (locally)"
task :build do
git_commit_hash = `git rev-parse HEAD`.chomp
goos =`go env GOOS`.chomp
goarch =`go env GOARCH`.chomp
build_commit_hash = "#{git_commit_hash}-#{goos}-#{goarch}"

system %{
docker build --build-arg="BUILD_INFORMATION=#{build_commit_hash}" \
-t #{DOCKER_IMAGE_TAG} .
}
exit $?.exitstatus
end
end
# -----------------------------------------------------------------------------
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"strings"
"time"

"github.com/vigo/statoo/app/flags"
"github.com/vigo/statoo/app/version"
"github.com/vigo/statoo/v2/app/flags"
"github.com/vigo/statoo/v2/app/version"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"strings"
"testing"

"github.com/vigo/statoo/app"
"github.com/vigo/statoo/app/flags"
"github.com/vigo/statoo/app/version"
"github.com/vigo/statoo/v2/app"
"github.com/vigo/statoo/v2/app/flags"
"github.com/vigo/statoo/v2/app/version"
)

type gzipResponseWriter struct {
Expand Down
2 changes: 1 addition & 1 deletion app/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"flag"
"testing"

"github.com/vigo/statoo/app/flags"
"github.com/vigo/statoo/v2/app/flags"
)

func TestCustomRequestHeadersFlag(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/vigo/statoo
module github.com/vigo/statoo/v2

go 1.19
go 1.21
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/vigo/statoo/app"
"github.com/vigo/statoo/v2/app"
)

func main() {
Expand Down

0 comments on commit b670745

Please sign in to comment.