Skip to content

Commit

Permalink
Merge pull request #89 from kanmu/fix_ci
Browse files Browse the repository at this point in the history
Fix CI
  • Loading branch information
winebarrel authored Nov 14, 2024
2 parents 341c892 + 92f5be5 commit dc5cfd5
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 61 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ updates:
directory: "/"
schedule:
interval: "weekly"
groups:
dependencies:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
dependencies:
patterns:
- "*"
17 changes: 17 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@ name: test
on:
pull_request:
push:
branches:
- main
schedule:
- cron: '0 0 1 * *'
- cron: "0 0 1 * *"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ">=1.20.5"
go-version-file: go.mod
cache: false
- uses: golangci/golangci-lint-action@v6
with:
args: -E misspell,gofmt
- run: make
env:
TEST_GCAL_API_KEY: ${{ secrets.TEST_GCAL_API_KEY }}
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
run:
timeout: 5m
linters:
enable:
- misspell
- gosimple
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vet:

.PHONY: lint
lint:
golangci-lint run -E misspell,gofmt
golangci-lint run

.PHONY: test
test:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/kanmu/jhol.svg)](https://pkg.go.dev/github.com/kanmu/jhol)
[![Go Report Card](https://goreportcard.com/badge/github.com/kanmu/jhol)](https://goreportcard.com/report/github.com/kanmu/jhol)

Go language library to check Japanese holidays using [Google Calendar](https://calendar.google.com/calendar/embed?src=ja.japanese%23holiday%40group.v.calendar.google.com).
Go language library to check Japanese holidays using [NAOJ Calendar](https://calendar.google.com/calendar/embed?src=2bk907eqjut8imoorgq1qa4olc%40group.calendar.google.com).

## Preparation

Expand Down Expand Up @@ -85,7 +85,6 @@ Flags:
-h, --help Show context-sensitive help.
--version
--api-key=STRING Google API Key ($JHOL_API_KEY)
--lang="ja" Calendar language (ja, en).
Commands:
next --api-key=STRING [<n>]
Expand Down
3 changes: 1 addition & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
)

const (
EnJapaneseHolidayCalendar = "en.japanese#[email protected]"
JaJapaneseHolidayCalendar = "ja.japanese#[email protected]"
JaJapaneseHolidayCalendar = "[email protected]"
)

type Client struct {
Expand Down
30 changes: 15 additions & 15 deletions client_between_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,45 @@ func TestClientBetween(_t *testing.T) {
{"2024-01-01", "元日"},
{"2024-01-08", "成人の日"},
{"2024-02-11", "建国記念の日"},
{"2024-02-12", "建国記念の日 振替休日"},
{"2024-02-12", "休日"},
{"2024-02-23", "天皇誕生日"},
{"2024-03-20", "春分の日"},
{"2024-04-29", "昭和の日"},
{"2024-05-03", "憲法記念日"},
{"2024-05-04", "みどりの日"},
{"2024-05-05", "こどもの日"},
{"2024-05-06", "こどもの日 振替休日"},
{"2024-05-06", "休日"},
{"2024-07-15", "海の日"},
{"2024-08-11", "山の日"},
{"2024-08-12", "休日 山の日"},
{"2024-08-12", "休日"},
{"2024-09-16", "敬老の日"},
{"2024-09-22", "秋分の日"},
{"2024-09-23", "秋分の日 振替休日"},
{"2024-09-23", "休日"},
{"2024-10-14", "スポーツの日"},
{"2024-11-03", "文化の日"},
{"2024-11-04", "文化の日 振替休日"},
{"2024-11-04", "休日"},
{"2024-11-23", "勤労感謝の日"},
}},
{"2024-01-08 00:00:00", "2024-11-04 23:59:59", []expectedHoliday{
{"2024-01-08", "成人の日"},
{"2024-02-11", "建国記念の日"},
{"2024-02-12", "建国記念の日 振替休日"},
{"2024-02-12", "休日"},
{"2024-02-23", "天皇誕生日"},
{"2024-03-20", "春分の日"},
{"2024-04-29", "昭和の日"},
{"2024-05-03", "憲法記念日"},
{"2024-05-04", "みどりの日"},
{"2024-05-05", "こどもの日"},
{"2024-05-06", "こどもの日 振替休日"},
{"2024-05-06", "休日"},
{"2024-07-15", "海の日"},
{"2024-08-11", "山の日"},
{"2024-08-12", "休日 山の日"},
{"2024-08-12", "休日"},
{"2024-09-16", "敬老の日"},
{"2024-09-22", "秋分の日"},
{"2024-09-23", "秋分の日 振替休日"},
{"2024-09-23", "休日"},
{"2024-10-14", "スポーツの日"},
{"2024-11-03", "文化の日"},
{"2024-11-04", "文化の日 振替休日"},
{"2024-11-04", "休日"},
}},
}

Expand Down Expand Up @@ -106,23 +106,23 @@ func TestClientBetween_UTC(_t *testing.T) {
{"2024-01-01", "元日"},
{"2024-01-08", "成人の日"},
{"2024-02-11", "建国記念の日"},
{"2024-02-12", "建国記念の日 振替休日"},
{"2024-02-12", "休日"},
{"2024-02-23", "天皇誕生日"},
{"2024-03-20", "春分の日"},
{"2024-04-29", "昭和の日"},
{"2024-05-03", "憲法記念日"},
{"2024-05-04", "みどりの日"},
{"2024-05-05", "こどもの日"},
{"2024-05-06", "こどもの日 振替休日"},
{"2024-05-06", "休日"},
{"2024-07-15", "海の日"},
{"2024-08-11", "山の日"},
{"2024-08-12", "休日 山の日"},
{"2024-08-12", "休日"},
{"2024-09-16", "敬老の日"},
{"2024-09-22", "秋分の日"},
{"2024-09-23", "秋分の日 振替休日"},
{"2024-09-23", "休日"},
{"2024-10-14", "スポーツの日"},
{"2024-11-03", "文化の日"},
{"2024-11-04", "文化の日 振替休日"},
{"2024-11-04", "休日"},
{"2024-11-23", "勤労感謝の日"},
{"2025-01-01", "元日"},
}},
Expand Down
40 changes: 20 additions & 20 deletions client_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,44 @@ func TestClientGet(_t *testing.T) {
}{
{"2024-01-01 00:00:00", "2024-01-01", "元日"},
{"2024-02-11 00:00:00", "2024-02-11", "建国記念の日"},
{"2024-02-12 00:00:00", "2024-02-12", "建国記念の日 振替休日"},
{"2024-02-12 00:00:00", "2024-02-12", "休日"},
{"2024-02-23 00:00:00", "2024-02-23", "天皇誕生日"},
{"2024-03-20 00:00:00", "2024-03-20", "春分の日"},
{"2024-04-29 00:00:00", "2024-04-29", "昭和の日"},
{"2024-05-03 00:00:00", "2024-05-03", "憲法記念日"},
{"2024-05-04 00:00:00", "2024-05-04", "みどりの日"},
{"2024-05-05 00:00:00", "2024-05-05", "こどもの日"},
{"2024-05-06 00:00:00", "2024-05-06", "こどもの日 振替休日"},
{"2024-05-06 00:00:00", "2024-05-06", "休日"},
{"2024-07-15 00:00:00", "2024-07-15", "海の日"},
{"2024-08-11 00:00:00", "2024-08-11", "山の日"},
{"2024-08-12 00:00:00", "2024-08-12", "休日 山の日"},
{"2024-08-12 00:00:00", "2024-08-12", "休日"},
{"2024-09-16 00:00:00", "2024-09-16", "敬老の日"},
{"2024-09-22 00:00:00", "2024-09-22", "秋分の日"},
{"2024-09-23 00:00:00", "2024-09-23", "秋分の日 振替休日"},
{"2024-09-23 00:00:00", "2024-09-23", "休日"},
{"2024-10-14 00:00:00", "2024-10-14", "スポーツの日"},
{"2024-11-03 00:00:00", "2024-11-03", "文化の日"},
{"2024-11-04 00:00:00", "2024-11-04", "文化の日 振替休日"},
{"2024-11-04 00:00:00", "2024-11-04", "休日"},
{"2024-11-23 00:00:00", "2024-11-23", "勤労感謝の日"},

{"2024-01-01 23:59:59", "2024-01-01", "元日"},
{"2024-02-11 23:59:59", "2024-02-11", "建国記念の日"},
{"2024-02-12 23:59:59", "2024-02-12", "建国記念の日 振替休日"},
{"2024-02-12 23:59:59", "2024-02-12", "休日"},
{"2024-02-23 23:59:59", "2024-02-23", "天皇誕生日"},
{"2024-03-20 23:59:59", "2024-03-20", "春分の日"},
{"2024-04-29 23:59:59", "2024-04-29", "昭和の日"},
{"2024-05-03 23:59:59", "2024-05-03", "憲法記念日"},
{"2024-05-04 23:59:59", "2024-05-04", "みどりの日"},
{"2024-05-05 23:59:59", "2024-05-05", "こどもの日"},
{"2024-05-06 23:59:59", "2024-05-06", "こどもの日 振替休日"},
{"2024-05-06 23:59:59", "2024-05-06", "休日"},
{"2024-07-15 23:59:59", "2024-07-15", "海の日"},
{"2024-08-11 23:59:59", "2024-08-11", "山の日"},
{"2024-08-12 23:59:59", "2024-08-12", "休日 山の日"},
{"2024-08-12 23:59:59", "2024-08-12", "休日"},
{"2024-09-16 23:59:59", "2024-09-16", "敬老の日"},
{"2024-09-22 23:59:59", "2024-09-22", "秋分の日"},
{"2024-09-23 23:59:59", "2024-09-23", "秋分の日 振替休日"},
{"2024-09-23 23:59:59", "2024-09-23", "休日"},
{"2024-10-14 23:59:59", "2024-10-14", "スポーツの日"},
{"2024-11-03 23:59:59", "2024-11-03", "文化の日"},
{"2024-11-04 23:59:59", "2024-11-04", "文化の日 振替休日"},
{"2024-11-04 23:59:59", "2024-11-04", "休日"},
{"2024-11-23 23:59:59", "2024-11-23", "勤労感謝の日"},
}

Expand Down Expand Up @@ -123,44 +123,44 @@ func TestClientGet_UTC(_t *testing.T) {
}{
{"2024-01-01 00:00:00", "2024-01-01", "元日"},
{"2024-02-11 00:00:00", "2024-02-11", "建国記念の日"},
{"2024-02-12 00:00:00", "2024-02-12", "建国記念の日 振替休日"},
{"2024-02-12 00:00:00", "2024-02-12", "休日"},
{"2024-02-23 00:00:00", "2024-02-23", "天皇誕生日"},
{"2024-03-20 00:00:00", "2024-03-20", "春分の日"},
{"2024-04-29 00:00:00", "2024-04-29", "昭和の日"},
{"2024-05-03 00:00:00", "2024-05-03", "憲法記念日"},
{"2024-05-04 00:00:00", "2024-05-04", "みどりの日"},
{"2024-05-05 00:00:00", "2024-05-05", "こどもの日"},
{"2024-05-06 00:00:00", "2024-05-06", "こどもの日 振替休日"},
{"2024-05-06 00:00:00", "2024-05-06", "休日"},
{"2024-07-15 00:00:00", "2024-07-15", "海の日"},
{"2024-08-11 00:00:00", "2024-08-11", "山の日"},
{"2024-08-12 00:00:00", "2024-08-12", "休日 山の日"},
{"2024-08-12 00:00:00", "2024-08-12", "休日"},
{"2024-09-16 00:00:00", "2024-09-16", "敬老の日"},
{"2024-09-22 00:00:00", "2024-09-22", "秋分の日"},
{"2024-09-23 00:00:00", "2024-09-23", "秋分の日 振替休日"},
{"2024-09-23 00:00:00", "2024-09-23", "休日"},
{"2024-10-14 00:00:00", "2024-10-14", "スポーツの日"},
{"2024-11-03 00:00:00", "2024-11-03", "文化の日"},
{"2024-11-04 00:00:00", "2024-11-04", "文化の日 振替休日"},
{"2024-11-04 00:00:00", "2024-11-04", "休日"},
{"2024-11-23 00:00:00", "2024-11-23", "勤労感謝の日"},

{"2024-01-01 14:59:59", "2024-01-01", "元日"},
{"2024-02-11 14:59:59", "2024-02-11", "建国記念の日"},
{"2024-02-12 14:59:59", "2024-02-12", "建国記念の日 振替休日"},
{"2024-02-12 14:59:59", "2024-02-12", "休日"},
{"2024-02-23 14:59:59", "2024-02-23", "天皇誕生日"},
{"2024-03-20 14:59:59", "2024-03-20", "春分の日"},
{"2024-04-29 14:59:59", "2024-04-29", "昭和の日"},
{"2024-05-03 14:59:59", "2024-05-03", "憲法記念日"},
{"2024-05-04 14:59:59", "2024-05-04", "みどりの日"},
{"2024-05-05 14:59:59", "2024-05-05", "こどもの日"},
{"2024-05-06 14:59:59", "2024-05-06", "こどもの日 振替休日"},
{"2024-05-06 14:59:59", "2024-05-06", "休日"},
{"2024-07-15 14:59:59", "2024-07-15", "海の日"},
{"2024-08-11 14:59:59", "2024-08-11", "山の日"},
{"2024-08-12 14:59:59", "2024-08-12", "休日 山の日"},
{"2024-08-12 14:59:59", "2024-08-12", "休日"},
{"2024-09-16 14:59:59", "2024-09-16", "敬老の日"},
{"2024-09-22 14:59:59", "2024-09-22", "秋分の日"},
{"2024-09-23 14:59:59", "2024-09-23", "秋分の日 振替休日"},
{"2024-09-23 14:59:59", "2024-09-23", "休日"},
{"2024-10-14 14:59:59", "2024-10-14", "スポーツの日"},
{"2024-11-03 14:59:59", "2024-11-03", "文化の日"},
{"2024-11-04 14:59:59", "2024-11-04", "文化の日 振替休日"},
{"2024-11-04 14:59:59", "2024-11-04", "休日"},
{"2024-11-23 14:59:59", "2024-11-23", "勤労感謝の日"},
}

Expand Down
2 changes: 1 addition & 1 deletion client_is_holiday_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestClientIsNotHoliday(t *testing.T) {
{"2022-01-07 00:00:00"}, // -1
{"2022-02-13 00:00:00"}, // +2
{"2022-02-22 00:00:00"}, // -1
{"2022-03-21 00:00:00"}, // +1
{"2022-03-22 00:00:00"}, // +1
{"2022-04-28 00:00:00"}, // -1
{"2022-05-13 00:00:00"}, // +10
{"2022-05-14 00:00:00"}, // +10
Expand Down
6 changes: 3 additions & 3 deletions client_next_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestClientNextN(_t *testing.T) {
{"2024-01-02 00:00:00", []expectedHoliday{
{"2024-01-08", "成人の日"},
{"2024-02-11", "建国記念の日"},
{"2024-02-12", "建国記念の日 振替休日"},
{"2024-02-12", "休日"},
}},
{"2024-05-03 00:00:00", []expectedHoliday{
{"2024-05-03", "憲法記念日"},
Expand All @@ -52,7 +52,7 @@ func TestClientNextN(_t *testing.T) {
{"2024-05-04 00:00:00", []expectedHoliday{
{"2024-05-04", "みどりの日"},
{"2024-05-05", "こどもの日"},
{"2024-05-06", "こどもの日 振替休日"},
{"2024-05-06", "休日"},
}},
{"2024-11-23 00:00:00", []expectedHoliday{
{"2024-11-23", "勤労感謝の日"},
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestClientNextN_UTC(_t *testing.T) {
{"2024-01-01 15:00:00", []expectedHoliday{
{"2024-01-08", "成人の日"},
{"2024-02-11", "建国記念の日"},
{"2024-02-12", "建国記念の日 振替休日"},
{"2024-02-12", "休日"},
}},
}

Expand Down
14 changes: 4 additions & 10 deletions cmd/jhol/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import (

var version string

const (
calendarID = jhol.JaJapaneseHolidayCalendar
)

var cli struct {
Version kong.VersionFlag
APIKey string `required:"" env:"JHOL_API_KEY" help:"Google API Key"`
Lang string `enum:"ja,en" default:"ja" help:"Calendar language (ja, en)."`
Next subcmd.Next `cmd:"" help:"Show next holidays."`
IsHoliday subcmd.IsHoliday `cmd:"" help:"Check whether the specified date is a holiday."`
}
Expand All @@ -30,15 +33,6 @@ func main() {
kong.Vars{"version": version},
)

var calendarID string

switch cli.Lang {
case "ja":
calendarID = jhol.JaJapaneseHolidayCalendar
case "en":
calendarID = jhol.EnJapaneseHolidayCalendar
}

client := jhol.NewClientWithCalendar(cli.APIKey, calendarID).WithoutContext()
err := ctx.Run(&subcmd.Binds{
Client: client,
Expand Down
6 changes: 3 additions & 3 deletions cmd/subcmd/next_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestNextCmd_3(_t *testing.T) {

assert.Equal(`2024-07-15 海の日
2024-08-11 山の日
2024-08-12 休日 山の日
2024-08-12 休日
`, out.String())
}

Expand All @@ -53,7 +53,7 @@ func TestNextCmd_5(_t *testing.T) {

assert.Equal(`2024-07-15 海の日
2024-08-11 山の日
2024-08-12 休日 山の日
2024-08-12 休日
2024-09-16 敬老の日
2024-09-22 秋分の日
`, out.String())
Expand All @@ -79,6 +79,6 @@ func TestNextCmd_Format(_t *testing.T) {

assert.Equal(`2024/07/15(Mon) 海の日
2024/08/11(Sun) 山の日
2024/08/12(Mon) 休日 山の日
2024/08/12(Mon) 休日
`, out.String())
}

0 comments on commit dc5cfd5

Please sign in to comment.