Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nwtgck committed Jan 15, 2022
2 parents 126728e + 756d4ca commit 7c02ada
Show file tree
Hide file tree
Showing 14 changed files with 742 additions and 121 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
timezone: Asia/Tokyo
open-pull-requests-limit: 99
reviewers: [ nwtgck ]
assignees: [ nwtgck ]
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
timezone: Asia/Tokyo
open-pull-requests-limit: 99
reviewers: [ nwtgck ]
assignees: [ nwtgck ]
62 changes: 61 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,66 @@ jobs:
with:
go-version: 1.16
- name: Build
run: CGO_ENABLED=0 go build -o piping-server
run: CGO_ENABLED=0 go build -o go-piping-server main/main.go
- name: Test
run: go test -v ./...

linux_operational_test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Build
run: CGO_ENABLED=0 go build -o go-piping-server main/main.go
- name: Operational test
run: |
set -xeu
# Create certificates
mkdir ssl_certs && cd ssl_certs && openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -sha256 -nodes --subj '/CN=localhost/' && cd -
# Run a server
./go-piping-server --http-port=8181 --enable-https --https-port=8443 --crt-path=./ssl_certs/server.crt --key-path=./ssl_certs/server.key &> ./piping-server.log &
# Get server PID
server_pid=$!
sleep 3
# Transfer data over HTTP
echo "hello, world" | curl -T - localhost:8181/mypath &
diff <(echo "hello, world") <(curl localhost:8181/mypath)
# Make a large random file
dd if=/dev/urandom iflag=count_bytes count=500M bs=1M of=/tmp/500M.dat
# Transfer large data over HTTP
cat /tmp/500M.dat | curl -T - localhost:8181/mypath &
diff <(cat /tmp/500M.dat) <(curl localhost:8181/mypath)
rm /tmp/500M.dat
# Transfer data over HTTPS
echo "hello, world with HTTPS" | curl -kT - https://localhost:8443/mypath2 &
diff <(echo "hello, world with HTTPS") <(curl -k https://localhost:8443/mypath2)
# Make a large random file
dd if=/dev/urandom iflag=count_bytes count=500M bs=1M of=/tmp/500M.dat
# Transfer large data over HTTPS
cat /tmp/500M.dat | curl -kT - https://localhost:8443/mypath2 &
diff <(cat /tmp/500M.dat) <(curl -k https://localhost:8443/mypath2)
rm /tmp/500M.dat
# HTTP/2 support
(echo hello | curl -ksST- https://localhost:8443/mypath3 -o /dev/null -w '%{http_version}:%{http_code}\n' > /tmp/http2_post.txt) &
diff <(echo '2:200') <(curl -ksS https://localhost:8443/mypath3 -o /dev/null -w '%{http_version}:%{http_code}\n')
diff <(echo '2:200') /tmp/http2_post.txt
# Transfer data using multipart
# Make a large random file
dd if=/dev/urandom iflag=count_bytes count=500M bs=1M of=/tmp/500M.dat
# Transfer large data over HTTP
curl -F myfile=@/tmp/500M.dat localhost:8181/mypath3 &
diff <(cat /tmp/500M.dat) <(curl localhost:8181/mypath3)
rm /tmp/500M.dat
# Stop the server
kill $server_pid
# Print server's log
cat ./piping-server.log
50 changes: 34 additions & 16 deletions .github/workflows/docker-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,43 @@ on:
- 'v*'
release:
types: [published]
schedule:
- cron: '*/30 * * * *'

jobs:
build_and_push:
runs-on: ubuntu-18.04
steps:
- run: echo ${{github.ref_name}}
- uses: actions/checkout@v2
- run: git fetch --unshallow
- name: Build & Push latest version
run: |
set -eu
DOCKER_REPO=nwtgck/go-piping-server
LATEST_TAG=$(ruby -e 'puts `git tag`.each_line.map{|t| begin {raw_tag: t, gver: Gem::Version::new(t.sub(/^v/, ""))}; rescue; nil end}.compact.max_by{|v| v[:gver]}[:raw_tag]')
echo "Latest tag: $LATEST_TAG"
git reset --hard $LATEST_TAG
git status
docker build -t ${DOCKER_REPO}:${LATEST_TAG} .
docker tag ${DOCKER_REPO}:${LATEST_TAG} ${DOCKER_REPO}:latest
echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u nwtgck --password-stdin
docker push ${DOCKER_REPO}:${LATEST_TAG}
docker push ${DOCKER_REPO}:latest
- name: Create Docker image names
id: create-docker-image-names
uses: actions/github-script@v5
with:
script: |
const dockerImageNames = [];
if (context.payload.ref === 'refs/heads/master') {
dockerImageNames.push('nwtgck/go-piping-server:latest');
}
const matched = context.payload.ref.match(/^refs\/tags\/(.*)$/);
if (matched !== null) {
dockerImageNames.push(`nwtgck/go-piping-server:${matched[1]}`);
}
console.log('dockerImageNames:', dockerImageNames);
const shouldPush = dockerImageNames.length !== 0;
core.setOutput('docker-push', shouldPush + "");
core.setOutput('docker-image-names', shouldPush ? dockerImageNames.join(",") : "dummy_image_name_not_to_push");
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: nwtgck
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: ${{ steps.create-docker-image-names.outputs.docker-push }}
tags: ${{ steps.create-docker-image-names.outputs.docker-image-names }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: v0.159.0
version: v1.0.0
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [Unreleased]

## [0.4.0] - 2022-01-15
### Added
* Support HEAD method for the reserved paths
* Add "Top page" link to /noscript page
* Log Piping Server version
* (Docker) Support linux/arm/v6, linux/arm/v7 and linux/arm64 Docker images

### Changed
* Update dependencies
* Add Go runtime version to --version output and version log

## [0.3.0] - 2021-11-20
### Added
* Make server logging better
Expand Down Expand Up @@ -32,6 +43,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
### Added
* Initial release

[Unreleased]: https://github.com/nwtgck/go-piping-server/compare/v0.3.0...HEAD
[Unreleased]: https://github.com/nwtgck/go-piping-server/compare/v0.4.0...HEAD
[0.4.0]: https://github.com/nwtgck/go-piping-server/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/nwtgck/go-piping-server/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/nwtgck/go-piping-server/compare/v0.1.0...v0.2.0
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
FROM golang:1.16
# NOTE: base platform is always linux/amd64 because go can cross-build
FROM --platform=linux/amd64 golang:1.16

ARG TARGETPLATFORM

COPY . /app
WORKDIR /app
RUN CGO_ENABLED=0 go build -o piping-server main/main.go
RUN case $TARGETPLATFORM in\
linux/amd64) GOARCH="amd64";;\
linux/arm/v6) GOARCH="arm"; GOARM=6;;\
linux/arm/v7) GOARCH="arm"; GOARM=7;;\
linux/arm64) GOARCH="arm64";;\
*) exit 1;;\
esac &&\
GOOS=linux CGO_ENABLED=0 go build -o piping-server main/main.go

FROM scratch
LABEL maintainer="Ryo Ota <nwtgck@nwtgck.org>"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

## Install for Ubuntu
```bash
wget https://github.com/nwtgck/go-piping-server/releases/download/v0.2.0/go-piping-server-0.2.0-linux-amd64.deb
sudo dpkg -i go-piping-server-0.2.0-linux-amd64.deb
wget https://github.com/nwtgck/go-piping-server/releases/download/v0.3.0/go-piping-server-0.3.0-linux-amd64.deb
sudo dpkg -i go-piping-server-0.3.0-linux-amd64.deb
```

## Install for macOS
Expand All @@ -13,7 +13,7 @@ brew install nwtgck/go-piping-server/go-piping-server
```

## Install for Windows
[Download](https://github.com/nwtgck/go-piping-server/releases/download/v0.2.0/go-piping-server-0.2.0-windows-amd64.zip)
[Download](https://github.com/nwtgck/go-piping-server/releases/download/v0.3.0/go-piping-server-0.3.0-windows-amd64.zip)

Get more executables in the [releases](https://github.com/nwtgck/go-piping-server/releases).

Expand Down
8 changes: 5 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"log"
"net/http"
"os"
"runtime"
)

var showsVersion bool
Expand Down Expand Up @@ -40,18 +41,19 @@ var RootCmd = &cobra.Command{
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if showsVersion {
fmt.Println(version.Version)
fmt.Printf("%s (%s)\n", version.Version, runtime.Version())
return nil
}
logger := log.New(os.Stderr, "", log.LstdFlags|log.Lmicroseconds)
logger.Printf("Piping Server %s (%s)", version.Version, runtime.Version())
pipingServer := piping_server.NewServer(logger)
errCh := make(chan error)
if enableHttps || enableHttp3 {
if keyPath == "" {
return errors.New("key-path should be specified")
return errors.New("--key-path should be specified")
}
if crtPath == "" {
return errors.New("crt-path should be specified")
return errors.New("--crt-path should be specified")
}
go func() {
logger.Printf("Listening HTTPS on %d...\n", httpsPort)
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/nwtgck/go-piping-server
go 1.16

require (
github.com/lucas-clemente/quic-go v0.20.1
github.com/spf13/cobra v1.1.3
golang.org/x/net v0.0.0-20200707034311-ab3426394381
github.com/lucas-clemente/quic-go v0.24.0
github.com/spf13/cobra v1.3.0
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d
gotest.tools/v3 v3.0.3
)
Loading

0 comments on commit 7c02ada

Please sign in to comment.