mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
Setup golangci-lint Github Action
This commit is contained in:
parent
9242350f0e
commit
6e2e2d1665
14 changed files with 52 additions and 66 deletions
50
.github/workflows/ci.yml
vendored
50
.github/workflows/ci.yml
vendored
|
@ -5,36 +5,6 @@ on:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
linters:
|
|
||||||
name: Linter Check
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v1
|
|
||||||
with:
|
|
||||||
go-version: 1.16
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v1
|
|
||||||
with:
|
|
||||||
fetch-depth: 3
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Install linters
|
|
||||||
run: |
|
|
||||||
cd /tmp && go get -u golang.org/x/lint/golint
|
|
||||||
sudo npm install -g jshint
|
|
||||||
env:
|
|
||||||
GO111MODULE: off
|
|
||||||
- name: Run golint
|
|
||||||
run: |
|
|
||||||
export PATH=/home/runner/go/bin:$PATH
|
|
||||||
make lint
|
|
||||||
- name: Run jshint
|
|
||||||
run: jshint ui/static/js/*.js
|
|
||||||
|
|
||||||
unit-tests:
|
unit-tests:
|
||||||
name: Unit Tests
|
name: Unit Tests
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
@ -45,17 +15,11 @@ jobs:
|
||||||
go-version: [1.16]
|
go-version: [1.16]
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
fetch-depth: 3
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: make test
|
run: make test
|
||||||
|
|
||||||
|
@ -74,17 +38,11 @@ jobs:
|
||||||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.16
|
go-version: 1.16
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
fetch-depth: 3
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Install Postgres client
|
- name: Install Postgres client
|
||||||
run: sudo apt-get install -y postgresql-client
|
run: sudo apt-get install -y postgresql-client
|
||||||
- name: Run integration tests
|
- name: Run integration tests
|
||||||
|
|
30
.github/workflows/linters.yml
vendored
Normal file
30
.github/workflows/linters.yml
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
name: Linters
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
jshint:
|
||||||
|
name: Javascript Linter
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install jshint
|
||||||
|
run: |
|
||||||
|
sudo npm install -g jshint
|
||||||
|
- name: Run jshint
|
||||||
|
run: jshint ui/static/js/*.js
|
||||||
|
|
||||||
|
golangci:
|
||||||
|
name: Golang Linter
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.16
|
||||||
|
- uses: golangci/golangci-lint-action@v2
|
||||||
|
with:
|
||||||
|
args: --skip-dirs tests --disable errcheck --enable sqlclosecheck --enable misspell --enable gofmt --enable goimports --enable whitespace
|
||||||
|
skip-go-installation: true
|
|
@ -345,7 +345,7 @@ func (c *Client) MarkFeedAsRead(feedID int64) error {
|
||||||
|
|
||||||
// RefreshAllFeeds refreshes all feeds.
|
// RefreshAllFeeds refreshes all feeds.
|
||||||
func (c *Client) RefreshAllFeeds() error {
|
func (c *Client) RefreshAllFeeds() error {
|
||||||
_, err := c.request.Put(fmt.Sprintf("/v1/feeds/refresh"), nil)
|
_, err := c.request.Put("/v1/feeds/refresh", nil)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,9 +82,9 @@ func (r *request) execute(method, path string, data interface{}) (io.ReadCloser,
|
||||||
}
|
}
|
||||||
|
|
||||||
if data != nil {
|
if data != nil {
|
||||||
switch data.(type) {
|
switch data := data.(type) {
|
||||||
case io.ReadCloser:
|
case io.ReadCloser:
|
||||||
request.Body = data.(io.ReadCloser)
|
request.Body = data
|
||||||
default:
|
default:
|
||||||
request.Body = io.NopCloser(bytes.NewBuffer(r.toJSON(data)))
|
request.Body = io.NopCloser(bytes.NewBuffer(r.toJSON(data)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ func TestToString(t *testing.T) {
|
||||||
r := &Response{Body: strings.NewReader(input)}
|
r := &Response{Body: strings.NewReader(input)}
|
||||||
|
|
||||||
if r.BodyAsString() != input {
|
if r.BodyAsString() != input {
|
||||||
t.Error(`Unexpected ouput`)
|
t.Error(`Unexpected output`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,12 @@ func Path(router *mux.Router, name string, args ...interface{}) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var pairs []string
|
var pairs []string
|
||||||
for _, param := range args {
|
for _, arg := range args {
|
||||||
switch param.(type) {
|
switch param := arg.(type) {
|
||||||
case string:
|
case string:
|
||||||
pairs = append(pairs, param.(string))
|
pairs = append(pairs, param)
|
||||||
case int64:
|
case int64:
|
||||||
val := param.(int64)
|
pairs = append(pairs, strconv.FormatInt(param, 10))
|
||||||
pairs = append(pairs, strconv.FormatInt(val, 10))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ type UserModificationRequest struct {
|
||||||
KeyboardShortcuts *bool `json:"keyboard_shortcuts"`
|
KeyboardShortcuts *bool `json:"keyboard_shortcuts"`
|
||||||
ShowReadingTime *bool `json:"show_reading_time"`
|
ShowReadingTime *bool `json:"show_reading_time"`
|
||||||
EntrySwipe *bool `json:"entry_swipe"`
|
EntrySwipe *bool `json:"entry_swipe"`
|
||||||
DisplayMode *string `json:"display_mode"`
|
DisplayMode *string `json:"display_mode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch updates the User object with the modification request.
|
// Patch updates the User object with the modification request.
|
||||||
|
|
|
@ -157,7 +157,7 @@ func (a *atom10Entry) entryHash() string {
|
||||||
|
|
||||||
func (a *atom10Entry) entryEnclosures() model.EnclosureList {
|
func (a *atom10Entry) entryEnclosures() model.EnclosureList {
|
||||||
enclosures := make(model.EnclosureList, 0)
|
enclosures := make(model.EnclosureList, 0)
|
||||||
duplicates := make(map[string]bool, 0)
|
duplicates := make(map[string]bool)
|
||||||
|
|
||||||
for _, mediaThumbnail := range a.AllMediaThumbnails() {
|
for _, mediaThumbnail := range a.AllMediaThumbnails() {
|
||||||
if _, found := duplicates[mediaThumbnail.URL]; !found {
|
if _, found := duplicates[mediaThumbnail.URL]; !found {
|
||||||
|
|
|
@ -292,7 +292,7 @@ func (r *rssItem) entryURL() string {
|
||||||
|
|
||||||
func (r *rssItem) entryEnclosures() model.EnclosureList {
|
func (r *rssItem) entryEnclosures() model.EnclosureList {
|
||||||
enclosures := make(model.EnclosureList, 0)
|
enclosures := make(model.EnclosureList, 0)
|
||||||
duplicates := make(map[string]bool, 0)
|
duplicates := make(map[string]bool)
|
||||||
|
|
||||||
for _, mediaThumbnail := range r.AllMediaThumbnails() {
|
for _, mediaThumbnail := range r.AllMediaThumbnails() {
|
||||||
if _, found := duplicates[mediaThumbnail.URL]; !found {
|
if _, found := duplicates[mediaThumbnail.URL]; !found {
|
||||||
|
|
|
@ -374,7 +374,7 @@ func (e *EntryQueryBuilder) buildSorting() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.direction != "" {
|
if e.direction != "" {
|
||||||
parts = append(parts, fmt.Sprintf(`%s`, e.direction))
|
parts = append(parts, e.direction)
|
||||||
}
|
}
|
||||||
|
|
||||||
if e.limit > 0 {
|
if e.limit > 0 {
|
||||||
|
|
|
@ -106,7 +106,7 @@ func (f *FeedQueryBuilder) buildSorting() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.direction != "" {
|
if f.direction != "" {
|
||||||
parts = append(parts, fmt.Sprintf(`%s`, f.direction))
|
parts = append(parts, f.direction)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(parts) > 0 {
|
if len(parts) > 0 {
|
||||||
|
|
|
@ -136,10 +136,7 @@ func truncate(str string, max int) string {
|
||||||
|
|
||||||
func isEmail(str string) bool {
|
func isEmail(str string) bool {
|
||||||
_, err := mail.ParseAddress(str)
|
_, err := mail.ParseAddress(str)
|
||||||
if err != nil {
|
return err == nil
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func elapsedTime(printer *locale.Printer, tz string, t time.Time) string {
|
func elapsedTime(printer *locale.Printer, tz string, t time.Time) string {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Use of this source code is governed by the Apache 2.0
|
// Use of this source code is governed by the Apache 2.0
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build integration
|
||||||
|
|
||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -212,7 +212,7 @@ func TestGetUserByID(t *testing.T) {
|
||||||
func TestGetUserByUsername(t *testing.T) {
|
func TestGetUserByUsername(t *testing.T) {
|
||||||
username := getRandomUsername()
|
username := getRandomUsername()
|
||||||
client := miniflux.New(testBaseURL, testAdminUsername, testAdminPassword)
|
client := miniflux.New(testBaseURL, testAdminUsername, testAdminPassword)
|
||||||
user, err := client.CreateUser(username, testStandardPassword, false)
|
_, err := client.CreateUser(username, testStandardPassword, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ func TestGetUserByUsername(t *testing.T) {
|
||||||
t.Fatal(`Should returns a 404`)
|
t.Fatal(`Should returns a 404`)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err = client.UserByUsername(username)
|
user, err := client.UserByUsername(username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue