Skip to content

Commit

Permalink
Adding codecov (#6)
Browse files Browse the repository at this point in the history
Also pulling in latest changes from Hardfin internal (just an upgrade to Go 1.22.1)
  • Loading branch information
Danny Hermes authored Mar 8, 2024
1 parent 5d9cd94 commit 1206fb8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
GO_LATEST: "1.22.1"

jobs:
go-test:
runs-on:
- ubuntu-22.04
strategy:
matrix:
go-version:
- "1.21.7"
- "1.22.0"
- "1.21.8"
- "go-latest"
timeout-minutes: 5

steps:
Expand All @@ -44,14 +47,21 @@ jobs:
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ matrix.go-version }}
go-version: ${{ matrix.go-version == 'go-latest' && env.GO_LATEST || matrix.go-version }}

- name: Go test
run: |
go test ./...
go test -race -covermode=atomic -coverprofile=coverage.out ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
with:
version: v1.56.1
args: "--verbose --timeout=2m"

- name: Upload coverage reports to Codecov
if: ${{ matrix.go-version == 'go-latest' }}
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: hardfinhq/go-date
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/hardfinhq/go-date

go 1.21.4
go 1.22.1

require github.com/stretchr/testify v1.9.0

Expand Down
6 changes: 3 additions & 3 deletions time_vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

// daysBefore is vendored in from the standard library:
// https://github.com/golang/go/blob/go1.21.4/src/time/time.go#L1039-L1056
// https://github.com/golang/go/blob/go1.22.1/src/time/time.go#L1060-L1077
var daysBefore = [...]int32{
0,
31,
Expand All @@ -37,7 +37,7 @@ var daysBefore = [...]int32{
}

// daysIn is vendored in from the standard library:
// https://github.com/golang/go/blob/go1.21.4/src/time/time.go#L1058-L1063
// https://github.com/golang/go/blob/go1.22.1/src/time/time.go#L1079-L1084
func daysIn(m time.Month, year int) int {
if m == time.February && isLeap(year) {
return 29
Expand All @@ -46,7 +46,7 @@ func daysIn(m time.Month, year int) int {
}

// isLeap is vendored in from the standard library:
// https://github.com/golang/go/blob/go1.21.4/src/time/time.go#L1427-L1429
// https://github.com/golang/go/blob/go1.22.1/src/time/time.go#L1448-L1450
func isLeap(year int) bool {
return year%4 == 0 && (year%100 != 0 || year%400 == 0)
}

0 comments on commit 1206fb8

Please sign in to comment.