-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tamada/setup_ci
setup CI
- Loading branch information
Showing
8 changed files
with
299 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: build | ||
on: | ||
push: | ||
branches: | ||
- "**" | ||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- macOS-latest | ||
- windows-latest | ||
steps: | ||
- name: setup go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
- name: checkout | ||
uses: actions/checkout@v1 | ||
- name: build | ||
run: make | ||
- name: Convert coverage to lcov | ||
uses: jandelgado/gcov2lcov-action@v1.0.0 | ||
with: | ||
infile: coverage.out | ||
outfile: coverage.lcov | ||
if: "matrix.os == 'ubuntu-latest'" | ||
- name: coveralls | ||
uses: coverallsapp/github-action@v1.0.1 | ||
with: | ||
github-token: ${{ secrets.github_token }} | ||
path-to-lcov: coverage.lcov | ||
if: "matrix.os == 'ubuntu-latest'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
GO := go | ||
NAME := nml | ||
VERSION := 1.0.0 | ||
DIST := $(NAME)-$(VERSION) | ||
|
||
all: test build | ||
|
||
setup: | ||
git submodule update --init | ||
|
||
test: setup | ||
$(GO) test -covermode=count -coverprofile=coverage.out $$(go list ./...) | ||
|
||
define __create_dist() | ||
mkdir -p dist/$(1)_$(2)/$(DIST) | ||
GOOS=$1 GOARCH=$2 go build -o dist/$(1)_$(2)/$(DIST)/$(NAME)$(3) main.go | ||
cp -r README.md LICENSE dist/$(1)_$(2)/$(DIST) | ||
tar cvfz dist/$(DIST)_$(1)_$(2).tar.gz -C dist/$(1)_$(2) $(DIST) | ||
endef | ||
|
||
dist: all | ||
@$(call __create_dist,darwin,amd64,) | ||
@$(call __create_dist,darwin,arm64,) | ||
@$(call __create_dist,windows,amd64,.exe) | ||
@$(call __create_dist,linux,amd64,) | ||
|
||
build: main.go | ||
go build -o $(NAME) -v main.go | ||
|
||
clean: | ||
@rm -f nml *~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/tamada/nml | ||
|
||
go 1.16 | ||
|
||
require github.com/spf13/pflag v1.0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= | ||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
func helpMessage(originalProgramName string) string { | ||
programName := filepath.Base(originalProgramName) | ||
return fmt.Sprintf(`%s [OPTIONS] <NUMBER> [-- <COMMANDS...>] | ||
%s means 'notify me, later!' | ||
OPTIONS | ||
-b, --background runs nml on background. Same as 'nml ... &'. | ||
-H, --with-header shows the header on notification. | ||
-u, --unit <UNIT> specifies the time unit. Default is min. | ||
Available units are: nsec, msec, sec, min, and hour. | ||
-h, --help prints this message. | ||
NUMBER | ||
specifies the number for timer. | ||
COMMANDS | ||
specifies the commands execute after timer. | ||
If no commands are specified, nml notifies by printing message | ||
"MESSAGE FROM NML ARRIVE!! (<NUMBER> <UNIT> left)" to STDOUT.`, programName, programName) | ||
} | ||
|
||
func goMain(args []string) int { | ||
fmt.Println(helpMessage(args[0])) | ||
return 0 | ||
} | ||
|
||
func main() { | ||
status := goMain(os.Args) | ||
os.Exit(status) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func Test_main(t *testing.T) { | ||
status := goMain([]string{"nml"}) | ||
if status != 0 { | ||
t.Errorf("status code wont 0, but got %d", status) | ||
} | ||
} |