Skip to content

Commit

Permalink
Merge pull request #3 from tamada/setup_ci
Browse files Browse the repository at this point in the history
setup CI
  • Loading branch information
tamada committed May 30, 2021
2 parents 402ae29 + 66be65e commit 7aea71b
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
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'"
31 changes: 31 additions & 0 deletions Makefile
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 *~
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ make
### Icon

![nml](https://github.com/tamada/nml/blob/main/docs/static/images/nml.svg)

This image is obtained from [freesvg.org](https://freesvg.org/zz-bell-silver)
180 changes: 179 additions & 1 deletion docs/static/images/nml.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions go.mod
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
2 changes: 2 additions & 0 deletions go.sum
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=
35 changes: 35 additions & 0 deletions main.go
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)
}
10 changes: 10 additions & 0 deletions main_test.go
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)
}
}

0 comments on commit 7aea71b

Please sign in to comment.