Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@ updates:
- package-ecosystem: gomod
directory: "/"
open-pull-requests-limit: 1
groups:
all-dependencies:
patterns:
- "*"
update-types:
- minor
- patch
schedule:
interval: weekly
30 changes: 15 additions & 15 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ jobs:
shell: bash

steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v5

- name: Run Lint
- name: Setup go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Run lint
uses: golangci/golangci-lint-action@v8

test:
Expand All @@ -33,24 +38,19 @@ jobs:
shell: bash

steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v5

- name: Setup Go
uses: actions/setup-go@v5
- name: Setup go
uses: actions/setup-go@v6
with:
go-version-file: go.mod

- name: Setup Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Download Dependencies
- name: Install dependencies
run: go mod download

- name: Run test
run: task test
run: go test ./...
env:
CI: true
TWICKETS_API_KEY: ${{ secrets.TWICKETS_API_KEY }}
CI: true
14 changes: 8 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,33 @@ on:
commit:
description: Branch, tag or commit hash
type: string
required: true
default: main

default-bump:
description: Default version bump (if none found in commit messages)
description: Default Version Bump (if none found in commit messages)
type: choice
options:
- major
- minor
- patch
required: false
default: patch

permissions:
contents: write

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
timeout-minutes: 5
timeout-minutes: 10
permissions:
contents: write
defaults:
run:
shell: bash

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
ref: ${{ inputs.commit }}

Expand Down
21 changes: 8 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# Ignore certain directories
build/
bin/
scratch/

# Ignore certain files
.env
.secrets
scratch*
*debug_bin*
*.DS_Store
.~lock*

# -----------------------------------------------------------------
# Go gitignore
# https://github.com/github/gitignore/blob/main/Go.gitignore
Expand All @@ -36,6 +23,14 @@ go.work
vendor/

# Ignore certain directories
build/
bin/
scratch/

# Ignore certain files
*.DS_Store
.~lock*
.env
.secrets
*.secrets
scratch*
55 changes: 37 additions & 18 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
# Docs: https://golangci-lint.run/usage/configuration/#config-file
# Docs: https://golangci-lint.run/docs/configuration/file
version: "2"

run:
go: "1.24"
timeout: 30m

formatters:
# Formatters: https://golangci-lint.run/docs/formatters
enable:
- gofmt # https://golangci-lint.run/usage/linters/#gofmt
- goimports # https://golangci-lint.run/usage/linters/#goimports
- gofumpt # https://golangci-lint.run/docs/formatters/configuration/#gofumpt

settings:
gofumpt:
extra-rules: true

linters:
# Linters: https://golangci-lint.run/docs/linters
enable:
# Default linters: https://golangci-lint.run/usage/linters#enabled-by-default
- gocritic # https://golangci-lint.run/usage/linters/#gocritic
- makezero # https://golangci-lint.run/usage/linters/#makezero
- misspell # https://golangci-lint.run/usage/linters/#misspell
- revive # https://golangci-lint.run/usage/linters/#revive
- testifylint # https://golangci-lint.run/usage/linters/#testifylint
- unparam # https://golangci-lint.run/usage/linters/#unparam
- usestdlibvars # https://golangci-lint.run/usage/linters/#usestdlibvars
- errcheck # https://golangci-lint.run/docs/linters/configuration/#errcheck
- gocritic # https://golangci-lint.run/docs/linters/configuration/#gocritic
- makezero # https://golangci-lint.run/docs/linters/configuration/#makezero
- misspell # https://golangci-lint.run/docs/linters/configuration/#misspell
- nolintlint # https://golangci-lint.run/docs/linters/configuration/#nolintlint
- revive # https://golangci-lint.run/docs/linters/configuration/#revive
- testifylint # https://golangci-lint.run/docs/linters/configuration/#testifylint
- unparam # https://golangci-lint.run/docs/linters/configuration/#unparam
- usestdlibvars # https://golangci-lint.run/docs/linters/configuration/#usestdlibvars

settings:
gocritic:
# Rules: https://go-critic.com/overview.html
enable-all: true
disabled-checks:
- commentedOutCode
- hugeParam # TODO Reenable this?
- rangeValCopy
- hugeParam
- whyNoLint

revive:
# Rules: https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS
enable-all-rules: true
rules:
- name: add-constant
Expand All @@ -39,6 +46,9 @@ linters:
- name: cognitive-complexity
disabled: true

- name: cyclomatic
arguments: [12]

- name: empty-lines
disabled: true

Expand All @@ -50,6 +60,9 @@ linters:
- disable-checks-on-types
- disable-checks-on-variables

- name: function-length
arguments: [50, 0] # Only check num statements, not num lines

- name: line-length-limit
arguments: [120]

Expand All @@ -59,15 +72,21 @@ linters:
- name: package-comments
disabled: true

- name: unhandled-error
arguments:
- fmt.Printf
- fmt.Println

- name: var-naming
arguments:
- ["ID", "IDS", "HTML", "HTTP", "JSON", "URL"] # Allow List
- [] # Deny List

- name: unhandled-error
disabled: true # Handled by errcheck linter

testifylint:
enable-all: true

unparam:
check-exported: true

exclusions:
# Exclusions: https://golangci-lint.run/docs/linters/false-positives
presets:
- std-error-handling
22 changes: 14 additions & 8 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
version: "3"

tasks:
lint:
format:
cmds:
- golangci-lint run
- go tool gofumpt -l -w .

format:
lint:
cmds:
- go fmt ./...
- go run github.com/segmentio/golines@latest -w .
- go tool golangci-lint run --fix ./...

test:
cmds:
- |
go clean -testcache
go test ./...
- go test ./...

test:clean:
cmds:
- go clean -testcache
- task: test

run:services:
cmds:
- docker compose up -d
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ func processFeedListings(
createdAfter time.Time,
) ([]TicketListing, bool) {
processedListings := make([]TicketListing, 0, len(listings))
for _, listing := range listings {
for idx := 0; idx < len(listings); idx++ {
listing := listings[idx]

// If listing NOT created after the earliest allowed time, break
if !listing.CreatedAt.After(createdAfter) {
Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func getMockUrlAndResponder(
t *testing.T,
events []string,
startTime time.Time,
interval time.Duration, // nolint:unparam
interval time.Duration, //nolint:unparam
) (string, httpmock.Responder) {
url := fmt.Sprintf(
"https://www.twickets.live/services/catalogue?api_key=%s&count=10&maxTime=%d&q=countryCode=%s",
Expand Down
7 changes: 5 additions & 2 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func main() {
listings,
filter.EventName("Hamilton", filter.DefaultEventNameSimilarity),
)
for _, listing := range hamiltonListings {
for idx := 0; idx < len(hamiltonListings); idx++ {
listing := listings[idx]

slog.Info(
"Found Hamilton ticket listing",
"Event", listing.Event.Name,
Expand All @@ -65,7 +67,8 @@ func main() {
filter.NumTickets(2), // Exactly 2 tickets in the listing
filter.MinDiscount(0.1), // Discount of > 10%
)
for _, listing := range coldplayListings {
for idx := 0; idx < len(coldplayListings); idx++ {
listing := coldplayListings[idx]
slog.Info(
"Found Coldplay ticket listing",
"Event", listing.Event.Name,
Expand Down
5 changes: 3 additions & 2 deletions filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/ahobsonsayers/twigots"
// FilterTicketListings filters ticket listings to those that satisfy all of the provided predicates.
//
// If no predicates are provided, all listings are returned.
func FilterTicketListings( // nolint
func FilterTicketListings( //revive:disable:exported
listings []twigots.TicketListing,
predicates ...TicketListingPredicate,
) []twigots.TicketListing {
Expand All @@ -14,7 +14,8 @@ func FilterTicketListings( // nolint
}

result := make([]twigots.TicketListing, 0, len(listings))
for _, listing := range listings {
for idx := 0; idx < len(listings); idx++ {
listing := listings[idx]
if TicketListingMatchesAllPredicates(listing, predicates...) {
result = append(result, listing)
}
Expand Down
Loading