Skip to content

Commit

Permalink
Add C.I., Add Go Modules (#27)
Browse files Browse the repository at this point in the history
* Create FUNDING.yml (#23)
* Add C.I. GitHub Actions, Add Go Mod (#25)
* Add Go Mod (#26)

Co-authored-by: iwittkau <[email protected]>
  • Loading branch information
eduncan911 and iwittkau authored Feb 7, 2020
1 parent 5e077a1 commit 71f0d6d
Show file tree
Hide file tree
Showing 67 changed files with 15,819 additions and 3,708 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/go-cicd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
on: [push]
name: go-cicd

jobs:

golangci-lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.13.x
- name: setup env
shell: bash
run: |
echo "::set-env name=GOPATH::${{ github.workspace }}/go"
echo "::add-path::${{ github.workspace }}/go/bin"
- name: checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
path: podcast/go/src/github.com/${{ github.repository }}
- name: Install golangci-lint
shell: bash
run: |
go get github.com/golangci/golangci-lint/cmd/golangci-lint
- name: Run linters
shell: bash
run: |
golangci-lint -E bodyclose,misspell,gocyclo,dupl,gofmt,golint,unconvert,depguard,interfacer run
coveralls:
runs-on: ubuntu-latest
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v1
with:
go-version: 1.13.x
- name: setup env
shell: bash
run: |
echo "::set-env name=GOPATH::${{ github.workspace }}/go"
echo "::add-path::${{ github.workspace }}/go/bin"
- name: checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
path: podcast/go/src/github.com/${{ github.repository }}
- name: Calc coverage
run: |
export PATH=$PATH:$(go env GOPATH)/bin
go test -v -covermode=count -coverprofile=coverage.out
- name: Convert coverage to lcov
uses: jandelgado/[email protected]
with:
infile: coverage.out
outfile: coverage.lcov
- name: Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov

go-bench:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.13.x
- name: setup env
shell: bash
run: |
echo "::set-env name=GOPATH::${{ github.workspace }}/go"
echo "::add-path::${{ github.workspace }}/go/bin"
- name: checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
path: podcast/go/src/github.com/${{ github.repository }}
- name: Run Benchmark
shell: bash
run: |
go test -test.run Benchmark -cpu 1 -bench .
go-test:
strategy:
matrix:
go-version: [1.7.x, 1.13.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: setup env
shell: bash
run: |
echo "::set-env name=GOPATH::${{ github.workspace }}/go"
echo "::add-path::${{ github.workspace }}/go/bin"
- name: Install Go
if: success()
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
- name: checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
path: podcast/go/src/github.com/${{ github.repository }}
- name: Run tests
run: |
go test -v -covermode=count
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ GITHUB_REPO:=eduncan911/podcast

README:
godoc2ghmd github.com/$(GITHUB_REPO) > README.md.tmp
echo "[![GoDoc](https://godoc.org/github.com/$(GITHUB_REPO)?status.svg)](https://godoc.org/github.com/$(GITHUB_REPO))" > README.md
echo "[![Build Status](https://travis-ci.org/$(GITHUB_REPO).svg?branch=master)](https://travis-ci.org/$(GITHUB_REPO))" >> README.md
echo "[![GoDoc](https://godoc.org/github.com/$(GITHUB_REPO)?status.svg)](https://godoc.org/github.com/$(GITHUB_REPO))" > README.md
echo "[![Build Status](https://github.com/$(GITHUB_REPO)/workflows/go-cicd/badge.svg)](https://github.com/$(GITHUB_REPO)/actions?workflow=go-cicd)" >> README.md
echo "[![Coverage Status](https://coveralls.io/repos/github/$(GITHUB_REPO)/badge.svg?branch=master)](https://coveralls.io/github/$(GITHUB_REPO)?branch=master)" >> README.md
echo "[![Go Report Card](https://goreportcard.com/badge/github.com/$(GITHUB_REPO))](https://goreportcard.com/report/github.com/$(GITHUB_REPO))" >> README.md
echo "[![GoDoc](https://godoc.org/github.com/$(GITHUB_REPO)?status.svg)](https://godoc.org/github.com/$(GITHUB_REPO))"
Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![GoDoc](https://godoc.org/github.com/eduncan911/podcast?status.svg)](https://godoc.org/github.com/eduncan911/podcast)
[![Build Status](https://travis-ci.org/eduncan911/podcast.svg?branch=master)](https://travis-ci.org/eduncan911/podcast)
[![Build Status](https://github.com/eduncan911/podcast/workflows/go-cicd/badge.svg)](https://github.com/eduncan911/podcast/actions?workflow=go-cicd)
[![Coverage Status](https://coveralls.io/repos/github/eduncan911/podcast/badge.svg?branch=master)](https://coveralls.io/github/eduncan911/podcast?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/eduncan911/podcast)](https://goreportcard.com/report/github.com/eduncan911/podcast)
[![MIT License](https://img.shields.io/npm/l/mediaelement.svg)](https://eduncan911.mit-license.org/)
Expand Down Expand Up @@ -61,6 +61,11 @@ However, the new 2.x branch, while keeping the same API, is expected break those
bypass the API methods and use the underlying public properties instead.

### Release Notes
1.4.0

* Add C.I. GitHub Actions (#25)
* Add Go Modules (#26)

1.3.2

* Correct count len of UTF8 strings (#9)
Expand Down Expand Up @@ -595,23 +600,23 @@ Recommendations:
* For specifications of itunes tags, see:
<a href="https://help.apple.com/itc/podcasts_connect/#/itcb54353390">https://help.apple.com/itc/podcasts_connect/#/itcb54353390</a>

### <a name="Podcast.AddLastBuildDate">func</a> (\*Podcast) [AddLastBuildDate](./podcast.go#L343)
### <a name="Podcast.AddLastBuildDate">func</a> (\*Podcast) [AddLastBuildDate](./podcast.go#L344)
``` go
func (p *Podcast) AddLastBuildDate(datetime *time.Time)
```
AddLastBuildDate adds the datetime as a parsed PubDate.

UTC time is used by default.

### <a name="Podcast.AddPubDate">func</a> (\*Podcast) [AddPubDate](./podcast.go#L336)
### <a name="Podcast.AddPubDate">func</a> (\*Podcast) [AddPubDate](./podcast.go#L337)
``` go
func (p *Podcast) AddPubDate(datetime *time.Time)
```
AddPubDate adds the datetime as a parsed PubDate.

UTC time is used by default.

### <a name="Podcast.AddSubTitle">func</a> (\*Podcast) [AddSubTitle](./podcast.go#L352)
### <a name="Podcast.AddSubTitle">func</a> (\*Podcast) [AddSubTitle](./podcast.go#L353)
``` go
func (p *Podcast) AddSubTitle(subTitle string)
```
Expand All @@ -621,7 +626,7 @@ in iTunes.
Note that this field should be just a few words long according to Apple.
This method will truncate the string to 64 chars if too long with "..."

### <a name="Podcast.AddSummary">func</a> (\*Podcast) [AddSummary](./podcast.go#L370)
### <a name="Podcast.AddSummary">func</a> (\*Podcast) [AddSummary](./podcast.go#L371)
``` go
func (p *Podcast) AddSummary(summary string)
```
Expand All @@ -632,19 +637,19 @@ Limit: 4000 characters
Note that this field is a CDATA encoded field which allows for rich text
such as html links: `<a href="<a href="http://www.apple.com">http://www.apple.com</a>">Apple</a>`.

### <a name="Podcast.Bytes">func</a> (\*Podcast) [Bytes](./podcast.go#L385)
### <a name="Podcast.Bytes">func</a> (\*Podcast) [Bytes](./podcast.go#L386)
``` go
func (p *Podcast) Bytes() []byte
```
Bytes returns an encoded []byte slice.

### <a name="Podcast.Encode">func</a> (\*Podcast) [Encode](./podcast.go#L390)
### <a name="Podcast.Encode">func</a> (\*Podcast) [Encode](./podcast.go#L391)
``` go
func (p *Podcast) Encode(w io.Writer) error
```
Encode writes the bytes to the io.Writer stream in RSS 2.0 specification.

### <a name="Podcast.String">func</a> (\*Podcast) [String](./podcast.go#L407)
### <a name="Podcast.String">func</a> (\*Podcast) [String](./podcast.go#L410)
``` go
func (p *Podcast) String() string
```
Expand Down
4 changes: 4 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
//
// Release Notes
//
// 1.4.0
// * Add C.I. GitHub Actions (#25)
// * Add Go Modules (#26)
//
// 1.3.2
// * Correct count len of UTF8 strings (#9)
// * Implement duration parser (#8)
Expand Down
21 changes: 11 additions & 10 deletions enclosure_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package podcast_test

import (
"testing"

"github.com/eduncan911/podcast"
"github.com/stretchr/testify/assert"
"testing"
)

type enclosureTest struct {
Expand All @@ -12,15 +13,15 @@ type enclosureTest struct {
}

var enclosureTests = []enclosureTest{
enclosureTest{podcast.M4A, "audio/x-m4a"},
enclosureTest{podcast.M4V, "video/x-m4v"},
enclosureTest{podcast.MP4, "video/mp4"},
enclosureTest{podcast.MP3, "audio/mpeg"},
enclosureTest{podcast.MOV, "video/quicktime"},
enclosureTest{podcast.PDF, "application/pdf"},
enclosureTest{podcast.EPUB, "document/x-epub"},
enclosureTest{podcast.M4A, "audio/x-m4a"},
enclosureTest{99, "application/octet-stream"},
{podcast.M4A, "audio/x-m4a"},
{podcast.M4V, "video/x-m4v"},
{podcast.MP4, "video/mp4"},
{podcast.MP3, "audio/mpeg"},
{podcast.MOV, "video/quicktime"},
{podcast.PDF, "application/pdf"},
{podcast.EPUB, "document/x-epub"},
{podcast.M4A, "audio/x-m4a"},
{99, "application/octet-stream"},
}

func TestEnclosureTypes(t *testing.T) {
Expand Down
9 changes: 8 additions & 1 deletion examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,17 @@ func ExampleItem_AddPubDate() {
// add the pub date
i.AddPubDate(&d)

// before adding
if i.PubDate != nil {
fmt.Println(i.PubDateFormatted, *i.PubDate)
}
p.AddItem(i) // this should not override with Podcast.PubDate

// this should not override with Podcast.PubDate
if _, err := p.AddItem(i); err != nil {
fmt.Println(err)
}

// after adding item
fmt.Println(i.PubDateFormatted, *i.PubDate)
// Output:
// Tue, 24 Jan 2017 08:21:52 +0000 2017-01-24 08:21:52 +0000 UTC
Expand Down
13 changes: 13 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module github.com/eduncan911/podcast

go 1.13

require (
github.com/davecgh/go-spew v1.1.1
github.com/kr/pretty v0.1.0 // indirect
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.4.0
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.2.8
)
25 changes: 25 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2 changes: 1 addition & 1 deletion item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestItemAddSummaryTooLong(t *testing.T) {
if len(summary) >= 4051 {
break
}
summary = summary + "abc ss 5 "
summary += "abc ss 5 "
}

// act
Expand Down
13 changes: 8 additions & 5 deletions podcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,13 @@ func (p *Podcast) AddItem(i Item) (int, error) {
// iTunes it
//
if len(i.IAuthor) == 0 {
if i.Author != nil {
switch {
case i.Author != nil:
i.IAuthor = i.Author.Email
} else if len(p.IAuthor) != 0 {
case len(p.IAuthor) != 0:
i.Author = &Author{Email: p.IAuthor}
i.IAuthor = p.IAuthor
} else if len(p.ManagingEditor) != 0 {
case len(p.ManagingEditor) != 0:
i.Author = &Author{Email: p.ManagingEditor}
i.IAuthor = p.ManagingEditor
}
Expand Down Expand Up @@ -388,7 +389,9 @@ func (p *Podcast) Bytes() []byte {

// Encode writes the bytes to the io.Writer stream in RSS 2.0 specification.
func (p *Podcast) Encode(w io.Writer) error {
w.Write([]byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"))
if _, err := w.Write([]byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")); err != nil {
return errors.Wrap(err, "podcast.Encode: w.Write return error")
}

atomLink := ""
if p.AtomLink != nil {
Expand Down Expand Up @@ -434,7 +437,7 @@ var encoder = func(w io.Writer, o interface{}) error {
e := xml.NewEncoder(w)
e.Indent("", " ")
if err := e.Encode(o); err != nil {
return errors.Wrap(err, "podcast.encode: Encode returned error")
return errors.Wrap(err, "podcast.encoder: e.Encode returned error")
}
return nil
}
Expand Down
Loading

0 comments on commit 71f0d6d

Please sign in to comment.