Skip to content

Commit

Permalink
GitHub ci (#164)
Browse files Browse the repository at this point in the history
github actions ci instead of travis
  • Loading branch information
rekby committed Sep 4, 2021
1 parent a45cccd commit 1ca6d01
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 60 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/publish-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: publish
on:
release:
types:
- published
jobs:
publish:
runs-on: ubuntu-20.04
strategy:
matrix:
goVersion: ["1.10", "1.16"]
env:
GO_VERSION: ${{ matrix.goVersion }}
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.goVersion }}

- name: install dos2unix
run: sudo apt-get install dos2unix

- name: checkout
uses: actions/checkout@v2

- name: build release binaries
run: bash ./tests/build-release.sh

- name: make archives
run: bash ./tests/make-archives.sh

- name: ls
run: ls output/
- name: upload binaries to release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: output/*
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test
on: [push, pull_request]
jobs:
test-build:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.10"

- name: test-build
run: bash ./tests/build-test.sh

run-test:
needs: test-build
runs-on: ubuntu-20.04
strategy:
matrix:
goVersion: ["1.10", "1.16"]
env:
GO_VERSION: ${{ matrix.goVersion }}
steps:
- name: checkout
uses: actions/checkout@v2

- name: Test
run: bash ./tests/test.sh

- name: push coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
flag-name: Go-${{ matrix.go }}
parallel: true

# notifies that all test jobs are finished.
finish:
needs: run-test
runs-on: ubuntu-20.04
steps:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true
57 changes: 0 additions & 57 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/rekby/lets-proxy2

go 1.13
go 1.14

require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
Expand Down
38 changes: 38 additions & 0 deletions tests/build-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -eux

REALPATH=$(realpath "$0")
ROOT=$(dirname "$REALPATH")
ROOT=$(dirname "$ROOT")
TESTBUILD_DIR="$ROOT/test-build"
OUTPUT="$ROOT/output"

rm -rf "$TESTBUILD_DIR"

export PATH="$GOROOT/bin:$PATH"
(
# prevent modify project's go.mod
cd /tmp
go get github.com/mitchellh/gox
)
export GOPATH="$TESTBUILD_DIR"
DEST="$GOPATH/src/github.com/rekby/lets-proxy2"
mkdir -p "$TESTBUILD_DIR/src/github.com/rekby"
ln -Ts "$ROOT" "$DEST"
cd "$DEST"

go version
go env

if [ "$GO_VERSION" = "1.10" ]; then
OS_ARCH_BUILDS="linux/386 linux/amd64 linux/arm freebsd/386 freebsd/amd64 freebsd/arm windows/386 windows/amd64"
else
OS_ARCH_BUILDS="linux/386 linux/amd64 linux/arm freebsd/386 freebsd/amd64 freebsd/arm windows/386 windows/amd64 darwin/amd64"
fi

GITHUB_TAG="${GITHUB_REF/refs\/tags\//}"
BUILD_TIME=$(TZ=UTC date --rfc-3339=seconds)

export CGO_ENABLED=0
gox -osarch "$OS_ARCH_BUILDS" --ldflags "-X \"main.VERSION=$GITHUB_TAG+build-$GITHUB_RUN_ID, Build time $BUILD_TIME, commit $GITHUB_SHA, $GO_VERSION\"" --output="$OUTPUT/lets-proxy_{{.OS}}_{{.Arch}}" -verbose --rebuild ./cmd/
20 changes: 20 additions & 0 deletions tests/build-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -eux

REALPATH=$(realpath "$0")
ROOT=$(dirname "$REALPATH")
ROOT=$(dirname "$ROOT")
TESTBUILD_DIR="$ROOT/test-build"

rm -rf "$TESTBUILD_DIR"

export GOPATH="$TESTBUILD_DIR"
DEST="$GOPATH/src/github.com/rekby/lets-proxy2"
mkdir -p "$TESTBUILD_DIR/src/github.com/rekby"
ln -Ts "$ROOT" "$DEST"
cd "$DEST"

go version
go env
go build -v ./...
9 changes: 7 additions & 2 deletions tests/make_archives.sh → tests/make-archives.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ ls
cp ../README.md ./README.md
unix2dos -n README.md README.txt

SUFFIX=""
if [ "$GO_VERSION" == "1.10" ]; then
SUFFIX="-go1.10"
fi

for FILE in `ls`; do
expr match "$FILE" '^lets-proxy_' > /dev/null || continue
echo "$FILE"
if expr match "$FILE" '^lets-proxy_windows' > /dev/null; then
mv "$FILE" lets-proxy.exe
unix2dos -n config_default.toml_ config_default.toml
zip "${FILE%.exe}-go${GO_VERSION}.zip" lets-proxy.exe README.txt config_default.toml
zip "${FILE%.exe}$SUFFIX.zip" lets-proxy.exe README.txt config_default.toml
rm config_default.toml
rm lets-proxy.exe
else
mv "$FILE" lets-proxy
cp config_default.toml_ config_default.toml
tar -zcvf "${FILE%.exe}-go${GO_VERSION}.tar.gz" lets-proxy README.md config_default.toml
tar -zcvf "${FILE%.exe}$SUFFIX.tar.gz" lets-proxy README.md config_default.toml
rm config_default.toml
rm lets-proxy
fi
Expand Down
Loading

0 comments on commit 1ca6d01

Please sign in to comment.