Skip to content

Commit 1a36fdb

Browse files
committed
Refactor function signatures and improve error handling across multiple files
- Updated function signatures to return named return values for better readability in: - `calls` method in `cascade_test.go` - `makeResp` function in `cf_test.go` - `GetStreamURL` and `GetEpisodeStreamURL` methods in `client.go` - `GetUpscaledDimensions` function in `anime4k.go` - `searchAnimeOnPage` function in `search_anime_test.go` - Changed HTTP request body from `nil` to `http.NoBody` in various places to improve clarity and intent: - Multiple instances in `client.go`, `stream.go`, `search.go`, and `retryafter_test.go` - Updated file permission constants from octal literals to the new `0o` syntax for consistency in: - `local.go`, `updater.go`, `install_and_pipeline_test.go`, `video.go`, and others - Improved error handling and logging in various test files and utility functions.
1 parent ed21f39 commit 1a36fdb

90 files changed

Lines changed: 692 additions & 479 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
day: monday
8+
time: '08:00'
9+
timezone: America/Sao_Paulo
10+
open-pull-requests-limit: 10
11+
groups:
12+
go-minor-and-patch:
13+
update-types:
14+
- minor
15+
- patch
16+
17+
- package-ecosystem: github-actions
18+
directory: /
19+
schedule:
20+
interval: weekly
21+
day: monday
22+
time: '08:30'
23+
timezone: America/Sao_Paulo
24+
open-pull-requests-limit: 10
25+
groups:
26+
actions:
27+
patterns:
28+
- '*'

.github/workflows/ci.yml

Lines changed: 145 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,136 @@
1-
name: GoAnime CI
1+
name: CI
22

33
on:
44
push:
5-
branches: [ main, dev]
5+
branches: [main, dev]
66
pull_request:
7-
branches: [ main, dev ]
7+
branches: [main, dev]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ci-${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
GO_VERSION: '1.26.5'
18+
GOFLAGS: -mod=readonly
19+
GOTOOLCHAIN: local
820

921
jobs:
22+
quality:
23+
name: Quality gates
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 25
26+
steps:
27+
- name: Check out code
28+
uses: actions/checkout@v4
29+
with:
30+
persist-credentials: false
31+
32+
- name: Set up Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version: ${{ env.GO_VERSION }}
36+
cache: true
37+
38+
- name: Verify module integrity
39+
shell: bash
40+
run: |
41+
go mod verify
42+
go mod tidy
43+
git diff --exit-code -- go.mod go.sum
44+
45+
- name: Check formatting
46+
shell: bash
47+
run: |
48+
unformatted="$(gofmt -l .)"
49+
if [[ -n "$unformatted" ]]; then
50+
echo "The following files are not gofmt formatted:"
51+
echo "$unformatted"
52+
exit 1
53+
fi
54+
55+
- name: Run go vet
56+
run: go vet ./...
57+
58+
- name: Run golangci-lint
59+
uses: golangci/golangci-lint-action@v9
60+
with:
61+
version: v2.12.2
62+
args: --timeout=20m
63+
64+
- name: Install go-critic
65+
run: go install github.com/go-critic/go-critic/cmd/gocritic@v0.14.4
66+
67+
- name: Run every go-critic check
68+
run: >
69+
gocritic check -enableAll
70+
-@hugeParam.sizeThreshold=256
71+
-@rangeValCopy.sizeThreshold=512
72+
-@unnamedResult.checkExported=true
73+
./...
74+
75+
security:
76+
name: Security gates
77+
runs-on: ubuntu-latest
78+
timeout-minutes: 25
79+
steps:
80+
- name: Check out code
81+
uses: actions/checkout@v4
82+
with:
83+
persist-credentials: false
84+
fetch-depth: 0
85+
86+
- name: Set up Go
87+
uses: actions/setup-go@v5
88+
with:
89+
go-version: ${{ env.GO_VERSION }}
90+
cache: true
91+
92+
- name: Review dependency changes
93+
if: github.event_name == 'pull_request'
94+
uses: actions/dependency-review-action@v4
95+
with:
96+
fail-on-severity: moderate
97+
98+
- name: Install security scanners
99+
run: |
100+
go install github.com/securego/gosec/v2/cmd/gosec@v2.28.0
101+
go install golang.org/x/vuln/cmd/govulncheck@v1.6.0
102+
103+
- name: Scan source for insecure patterns
104+
run: gosec -exclude-generated ./...
105+
106+
- name: Scan reachable dependencies for vulnerabilities
107+
run: govulncheck ./...
108+
10109
test:
110+
name: Tests (${{ matrix.os }})
111+
needs: quality
11112
runs-on: ${{ matrix.os }}
113+
timeout-minutes: 35
12114
strategy:
115+
fail-fast: false
13116
matrix:
14-
os: [ ubuntu-latest, windows-latest, macos-latest ]
117+
os: [ubuntu-latest, windows-latest, macos-latest]
15118
steps:
16119
- name: Check out code
17120
uses: actions/checkout@v4
121+
with:
122+
persist-credentials: false
18123

19124
- name: Set up Go
20125
uses: actions/setup-go@v5
21126
with:
22-
go-version: '1.26.5'
127+
go-version: ${{ env.GO_VERSION }}
128+
cache: true
129+
130+
- name: Download and verify dependencies
131+
run: |
132+
go mod download
133+
go mod verify
23134
24135
- name: Install dependencies (Linux)
25136
if: runner.os == 'Linux'
@@ -63,42 +174,41 @@ jobs:
63174
- name: Run macOS Socket Tests (macOS only)
64175
if: runner.os == 'macOS'
65176
run: |
66-
echo "=== Testing macOS-specific socket path handling ==="
67-
echo "TMPDIR=$TMPDIR"
68177
go test -race -v ./internal/player/test/... -run "Socket|MacOS" -count=1
69178
70-
- name: Get dependencies
71-
run: go mod download
72-
73-
- name: Run golangci-lint
74-
uses: golangci/golangci-lint-action@v9
75-
with:
76-
version: latest
77-
78-
- name: Install Gosec
79-
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
80-
81-
- name: Run Gosec Security Scanner
82-
run: gosec ./...
83-
84-
- name: Install govulncheck
85-
run: go install golang.org/x/vuln/cmd/govulncheck@latest
86-
87-
- name: Scan for vulnerabilities
88-
run: govulncheck ./...
89-
90-
- name: Run tests
179+
- name: Run tests with race detector and coverage
91180
shell: bash
92-
run: go test -race -v -coverprofile=coverage.out ./...
181+
run: go test -short -race -count=1 -covermode=atomic -coverprofile=coverage.out ./...
93182

94-
- name: Run source health diagnostics
183+
- name: Enforce minimum coverage
95184
if: runner.os == 'Linux'
96185
shell: bash
97-
run: go test -tags sourcehealth -run TestSourceHealthLive -count=1 -v ./internal/scraper
186+
run: |
187+
go tool cover -func=coverage.out
188+
go tool cover -func=coverage.out | awk '
189+
/^total:/ {
190+
coverage = $3
191+
sub(/%$/, "", coverage)
192+
if (coverage + 0 < 66.0) {
193+
printf "coverage %.1f%% is below the required 66.0%%\n", coverage
194+
exit 1
195+
}
196+
}'
197+
198+
- name: Upload coverage artifact
199+
if: runner.os == 'Linux'
200+
uses: actions/upload-artifact@v4
201+
with:
202+
name: coverage
203+
path: coverage.out
204+
if-no-files-found: error
205+
retention-days: 14
98206

99207
build-binaries:
100-
needs: test
208+
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
209+
needs: [quality, security, test]
101210
runs-on: ${{ matrix.os }}
211+
timeout-minutes: 20
102212
strategy:
103213
matrix:
104214
include:
@@ -186,8 +296,10 @@ jobs:
186296

187297
# Windows Installer Job - Creates an offline installer with bundled mpv
188298
build-windows-installer:
189-
needs: test
299+
name: Build Windows installer
300+
needs: [quality, security, test]
190301
runs-on: windows-latest
302+
timeout-minutes: 45
191303
steps:
192304
- name: Set up Go
193305
uses: actions/setup-go@v5

.github/workflows/codeql.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
branches: [main, dev]
8+
schedule:
9+
- cron: '23 6 * * 1'
10+
11+
permissions:
12+
contents: read
13+
security-events: write
14+
15+
concurrency:
16+
group: codeql-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
analyze:
21+
name: Analyze Go
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 30
24+
steps:
25+
- name: Check out code
26+
uses: actions/checkout@v4
27+
with:
28+
persist-credentials: false
29+
30+
- name: Initialize CodeQL
31+
uses: github/codeql-action/init@v3
32+
with:
33+
languages: go
34+
queries: security-extended,security-and-quality
35+
36+
- name: Build
37+
uses: github/codeql-action/autobuild@v3
38+
39+
- name: Analyze
40+
uses: github/codeql-action/analyze@v3
41+
with:
42+
category: /language:go

.github/workflows/coverage.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)