Skip to content
This repository has been archived by the owner on Feb 3, 2022. It is now read-only.

Commit

Permalink
[#155]: feat(pre-release): 2.7.0-beta.1 pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
rustatian authored Dec 27, 2021
2 parents 277e09f + a195077 commit 17b89d7
Show file tree
Hide file tree
Showing 13 changed files with 265 additions and 149 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.4
go-version: 1.17.5

- name: Check out code
uses: actions/checkout@v2
Expand All @@ -48,12 +48,10 @@ jobs:
- name: Download dependencies
run: go mod download # `-x` means "verbose" mode

- uses: gacts/github-slug@v1
id: slug

- name: Generate builder values
id: values
run: |
echo "::set-output name=version::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`"
echo "::set-output name=timestamp::`date +%FT%T%z`"
echo "::set-output name=binary-name::rr`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`"
Expand All @@ -65,7 +63,7 @@ jobs:
CGO_ENABLED: 0
LDFLAGS: >-
-s
-X github.com/spiral/roadrunner-binary/v2/internal/meta.version=${{ steps.slug.outputs.version }}
-X github.com/spiral/roadrunner-binary/v2/internal/meta.version=${{ steps.values.outputs.version }}
-X github.com/spiral/roadrunner-binary/v2/internal/meta.buildTime=${{ steps.values.outputs.timestamp }}
run: |
go build -trimpath -ldflags "$LDFLAGS" -o "./${{ steps.values.outputs.binary-name }}" ./cmd/rr
Expand All @@ -74,7 +72,7 @@ jobs:
- name: Generate distributive directory name
id: dist-dir
run: >
echo "::set-output name=name::roadrunner-${{ steps.slug.outputs.version }}-$(
echo "::set-output name=name::roadrunner-${{ steps.values.outputs.version }}-$(
[ ${{ matrix.os }} != '' ] && echo '${{ matrix.os }}' || echo 'unknown'
)$(
[ ${{ matrix.compiler }} = 'musl-gcc' ] && echo '-musl'
Expand Down Expand Up @@ -128,9 +126,6 @@ jobs:
- name: Check out code
uses: actions/checkout@v2

- uses: gacts/github-slug@v1
id: slug

- name: Set up QEMU
uses: docker/setup-qemu-action@v1 # Action page: <https://github.com/docker/setup-qemu-action>

Expand All @@ -152,7 +147,9 @@ jobs:

- name: Generate builder values
id: values
run: echo "::set-output name=timestamp::`date +%FT%T%z`"
run: |
echo "::set-output name=version::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`"
echo "::set-output name=timestamp::`date +%FT%T%z`"
- name: Build image
uses: docker/build-push-action@v2 # Action page: <https://github.com/docker/build-push-action>
Expand All @@ -162,10 +159,10 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
build-args: |
APP_VERSION=${{ steps.slug.outputs.version }}
APP_VERSION=${{ steps.values.outputs.version }}
BUILD_TIME=${{ steps.values.outputs.timestamp }}
tags: |
spiralscout/roadrunner:latest
spiralscout/roadrunner:${{ steps.slug.outputs.version }}
spiralscout/roadrunner:${{ steps.values.outputs.version }}
ghcr.io/spiral/roadrunner:latest
ghcr.io/spiral/roadrunner:${{ steps.slug.outputs.version }}
ghcr.io/spiral/roadrunner:${{ steps.values.outputs.version }}
10 changes: 4 additions & 6 deletions .github/workflows/release_grpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.4
go-version: 1.17.5

- name: Check out code
uses: actions/checkout@v2
Expand All @@ -48,14 +48,12 @@ jobs:
run: sudo apt-get install -y musl-tools

- name: Download dependencies
run: go mod download # `-x` means "verbose" mode

- uses: gacts/github-slug@v1
id: slug
run: go mod download

- name: Generate builder values
id: values
run: |
echo "::set-output name=version::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`"
echo "::set-output name=timestamp::`date +%FT%T%z`"
echo "::set-output name=binary-name::protoc-gen-php-grpc`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`"
Expand All @@ -74,7 +72,7 @@ jobs:
- name: Generate distributive directory name
id: dist-dir
run: >
echo "::set-output name=name::protoc-gen-php-grpc-${{ steps.slug.outputs.version }}-$(
echo "::set-output name=name::roadrunner-${{ steps.values.outputs.version }}-$(
[ ${{ matrix.os }} != '' ] && echo '${{ matrix.os }}' || echo 'unknown'
)$(
[ ${{ matrix.compiler }} = 'musl-gcc' ] && echo '-musl'
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
version: v1.43 # without patch version
only-new-issues: false # show only new issues if it's a pull request
args: --timeout=10m
args: --build-tags=safe --timeout=10m

go-test:
name: Unit tests
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.4
go-version: 1.17.5

- name: Check out code
uses: actions/checkout@v2
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2 # action page: <https://github.com/actions/setup-go>
with:
go-version: 1.17.4
go-version: 1.17.5

- name: Check out code
uses: actions/checkout@v2
Expand All @@ -107,19 +107,19 @@ jobs:
- name: Install Go dependencies
run: go mod download && go mod verify

- uses: gacts/github-slug@v1
id: slug

- id: values
run: echo "::set-output name=timestamp::`date +%FT%T%z`"
- name: Generate version value
id: values # for PR this value will be `merge@__hash__`, SO: <https://stackoverflow.com/a/59780579/2252921>
run: |
echo "::set-output name=version::`echo ${GITHUB_REF##*/}`@`echo ${GITHUB_SHA} | cut -c1-8`"
echo "::set-output name=timestamp::`date +%FT%T%z`"
- name: Compile binary file
env:
GOOS: ${{ matrix.os }}
GOARCH: amd64
CGO_ENABLED: 0
LDFLAGS: -s
-X github.com/spiral/roadrunner-binary/v2/internal/meta.version=${{ steps.slug.outputs.version }}@${{ steps.slug.outputs.commit-hash-short }}
-X github.com/spiral/roadrunner-binary/v2/internal/meta.version=${{ steps.values.outputs.version }}
-X github.com/spiral/roadrunner-binary/v2/internal/meta.buildTime=${{ steps.values.outputs.timestamp }}
run: go build -trimpath -ldflags "$LDFLAGS" -o ./rr ./cmd/rr

Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ output:
format: colored-line-number # colored-line-number|line-number|json|tab|checkstyle|code-climate

linters-settings:
wsl:
allow-assign-and-anything: true
govet:
check-shadowing: true
golint:
Expand Down
50 changes: 38 additions & 12 deletions cmd/rr/command_test.go
Original file line number Diff line number Diff line change
@@ -1,41 +1,67 @@
package main

import (
"bytes"
"io"
"os"
"testing"

"github.com/kami-zh/go-capturer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_Main(t *testing.T) {
os.Args = []string{"", "--help"}
exitFn = func(code int) { assert.Equal(t, 0, code) }

output := capturer.CaptureStdout(main)
r, w, err := os.Pipe()
require.NoError(t, err)
os.Stdout = w

assert.Contains(t, output, "Usage:")
assert.Contains(t, output, "Available Commands:")
assert.Contains(t, output, "Flags:")
main()
_ = w.Close()
buf := new(bytes.Buffer)
_, err = io.Copy(buf, r)
require.NoError(t, err)

assert.Contains(t, buf.String(), "Usage:")
assert.Contains(t, buf.String(), "Available Commands:")
assert.Contains(t, buf.String(), "Flags:")
}

func Test_MainWithoutCommands(t *testing.T) {
os.Args = []string{""}
exitFn = func(code int) { assert.Equal(t, 0, code) }

output := capturer.CaptureStdout(main)
r, w, err := os.Pipe()
require.NoError(t, err)
os.Stdout = w

main()
_ = w.Close()
buf := new(bytes.Buffer)
_, err = io.Copy(buf, r)
require.NoError(t, err)

assert.Contains(t, output, "Usage:")
assert.Contains(t, output, "Available Commands:")
assert.Contains(t, output, "Flags:")
assert.Contains(t, buf.String(), "Usage:")
assert.Contains(t, buf.String(), "Available Commands:")
assert.Contains(t, buf.String(), "Flags:")
}

func Test_MainUnknownSubcommand(t *testing.T) {
os.Args = []string{"", "foobar"}
exitFn = func(code int) { assert.Equal(t, 1, code) }

output := capturer.CaptureStderr(main)
r, w, err := os.Pipe()
require.NoError(t, err)
os.Stderr = w

main()
_ = w.Close()
buf := new(bytes.Buffer)
_, err = io.Copy(buf, r)
require.NoError(t, err)

assert.Contains(t, output, "unknown command")
assert.Contains(t, output, "foobar")
assert.Contains(t, buf.String(), "unknown command")
assert.Contains(t, buf.String(), "foobar")
}
3 changes: 1 addition & 2 deletions cmd/rr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"os"
"path/filepath"

"github.com/spiral/roadrunner-binary/v2/internal/cli"

"github.com/fatih/color"
"github.com/spiral/roadrunner-binary/v2/internal/cli"
)

// exitFn is a function for application exiting.
Expand Down
Loading

0 comments on commit 17b89d7

Please sign in to comment.