Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to v2 #12

Merged
merged 1 commit into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 37 additions & 39 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
name: build and test

on:
pull_request:
push:
branches:
- main
- ST-*
pull_request:
- main
tags-ignore:
- '**'

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
id: go

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

- name: Get dependencies
run: go mod download

- name: Run tests
run: go test -race -count=1 -coverprofile=coverage.txt -covermode=atomic ./...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

- name: Build app
id: build_go_app
run: |
go build -v .
echo ::set-output name=exit_code::$?

- name: Notify Slack on success
if: steps.build_go_app.outputs.exit_code == 0
id: slack_notification
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
notification_title: 'Build succeeded'
message_format: 'Statoo build succeeded. <{repo_url}|{repo}@{branch}> on <{commit_url}|{commit_sha}>'
footer: 'repo: <{repo_url}|{repo}>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
- name: Checkout code
uses: actions/checkout@v3

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

- name: Run tests
run: go test -race -count=1 -coverprofile=coverage.txt -covermode=atomic ./...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

- name: Build app
id: build_go_app
run: |
go build -v .
echo ::set-output name=exit_code::$?

- name: Notify Slack on success
if: steps.build_go_app.outputs.exit_code == 0
id: slack_notification
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
notification_title: 'Build succeeded'
message_format: 'Statoo build succeeded. <{repo_url}|{repo}@{branch}> on <{commit_url}|{commit_sha}>'
footer: 'repo: <{repo_url}|{repo}>'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
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, 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
Loading