Skip to content

Commit 53df0e7

Browse files
committed
More updates to linting and remove REST service
1 parent cf5d324 commit 53df0e7

10 files changed

Lines changed: 69 additions & 507 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444

4545
- name: Set up tools
4646
env:
47-
PISCES_CHROMEDP_REMOTE_URL: "http://localhost:9222"
47+
CHROMEDP_REMOTE_URL: "http://localhost:9222"
4848
run: |
4949
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
5050

.github/workflows/release.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030
- name: Upload artifacts
3131
uses: actions/upload-artifact@v4
3232
with:
33-
name: pisces-${{ matrix.goos }}-${{ matrix.goarch }}
34-
path: build/pisces*
33+
name: virgo-${{ matrix.goos }}-${{ matrix.goarch }}
34+
path: build/virgo*
3535

3636
release:
3737
needs: build
@@ -55,22 +55,22 @@ jobs:
5555

5656
- name: Prepare for release
5757
run: |
58-
tar -czvf pisces-darwin-amd64.tar.gz artifacts/pisces-darwin-amd64/pisces
59-
tar -czvf pisces-darwin-arm64.tar.gz artifacts/pisces-darwin-arm64/pisces
60-
tar -czvf pisces-linux-amd64.tar.gz artifacts/pisces-linux-amd64/pisces
61-
tar -czvf pisces-linux-arm64.tar.gz artifacts/pisces-linux-arm64/pisces
62-
zip -r pisces-win-amd64.zip artifacts/pisces-windows-amd64/pisces
63-
zip -r pisces-win-arm64.zip artifacts/pisces-windows-arm64/pisces
58+
tar -czvf virgo-darwin-amd64.tar.gz artifacts/virgo-darwin-amd64/virgo
59+
tar -czvf virgo-darwin-arm64.tar.gz artifacts/virgo-darwin-arm64/virgo
60+
tar -czvf virgo-linux-amd64.tar.gz artifacts/virgo-linux-amd64/virgo
61+
tar -czvf virgo-linux-arm64.tar.gz artifacts/virgo-linux-arm64/virgo
62+
zip -r virgo-win-amd64.zip artifacts/virgo-windows-amd64/virgo
63+
zip -r virgo-win-arm64.zip artifacts/virgo-windows-arm64/virgo
6464
6565
- name: Release
6666
uses: softprops/action-gh-release@v1
6767
with:
6868
body_path: ${{ github.workspace }}_RELEASE_NOTES.txt
6969
draft: true
7070
files: |
71-
pisces-darwin-amd64.tar.gz
72-
pisces-darwin-arm64.tar.gz
73-
pisces-linux-amd64.tar.gz
74-
pisces-linux-arm64.tar.gz
75-
pisces-win-amd64.zip
76-
pisces-win-arm64.zip
71+
virgo-darwin-amd64.tar.gz
72+
virgo-darwin-arm64.tar.gz
73+
virgo-linux-amd64.tar.gz
74+
virgo-linux-arm64.tar.gz
75+
virgo-win-amd64.zip
76+
virgo-win-arm64.zip

.golangci.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,13 @@ version: "2"
22
linters:
33
default: all
44
disable:
5-
# TODO: Get these linters enabled
6-
- contextcheck
7-
- gochecknoglobals
8-
- godox
9-
- ireturn
10-
- tparallel
11-
- paralleltest
12-
5+
- gomodguard # deprecated
136
# These are disabled for now, primarily out of author preference
147
- cyclop
158
- depguard
169
- embeddedstructfieldcheck
1710
- exhaustruct
18-
- funlen
19-
- lll
20-
- gocognit
11+
- godox
2112
- mnd
2213
- noinlineerr
2314
- testpackage
@@ -30,7 +21,28 @@ linters:
3021
rules:
3122
- path: engine/crawler.go
3223
linters:
24+
- funlen
25+
- gocognit
3326
- nestif
27+
- path: internal/browser/profiles.go
28+
linters:
29+
- lll
30+
- path: logger.go
31+
linters:
32+
- gochecknoglobals
33+
- path: internal/pagetest/pagetest.go
34+
linters:
35+
- gosec
36+
- path: "cmd/(.+)/main.go"
37+
linters:
38+
- funlen
39+
- gochecknoglobals
40+
- path: '(.+)_test\.go'
41+
linters:
42+
- funlen
43+
- goconst
44+
- lll
45+
- paralleltest
3446

3547
settings:
3648
tagliatelle:

cmd/virgo-web/main.go

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

cmd/virgo/main.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717
"github.com/urfave/cli/v3"
1818
)
1919

20+
const URL = "url"
21+
2022
var ErrInvalidDeviceProperties = errors.New("invalid device properties")
2123
var ErrScreenShotFailed = errors.New("screenshot result error")
2224

@@ -34,7 +36,9 @@ func main() {
3436
&cli.IntFlag{Name: "concurrency", Aliases: []string{"c"}, Usage: "number of concurrent workers"},
3537
&cli.IntFlag{Name: "remote-port", Usage: "remote DevTools port"},
3638
&cli.StringFlag{Name: "remote-host", Usage: "remote DevTools host"},
37-
&cli.StringFlag{Name: "device-type", Value: "desktop", Usage: "device type (desktop/mobile/tablet)", Action: validDeviceType},
39+
&cli.StringFlag{
40+
Name: "device-type", Value: "desktop", Usage: "device type (desktop/mobile/tablet)", Action: validDeviceType,
41+
},
3842
&cli.StringFlag{Name: "device-size", Value: "large", Usage: "device size preset", Action: validDeviceSize},
3943
&cli.StringFlag{Name: "user-agent", Value: "chrome", Usage: "browser user-agent preset"},
4044
}
@@ -53,7 +57,7 @@ func main() {
5357
Name: "screenshot",
5458
Usage: "Screenshot one or more URLs",
5559
Arguments: []cli.Argument{
56-
&cli.StringArgs{Name: "url", Min: 1, Max: -1},
60+
&cli.StringArgs{Name: URL, Min: 1, Max: -1},
5761
},
5862
Flags: append([]cli.Flag{
5963
&cli.StringFlag{Name: "output-dir", Value: "tmp/", Aliases: []string{"o"}, Usage: "directory for screenshots"},
@@ -64,7 +68,7 @@ func main() {
6468
}, {
6569
Name: "markdown",
6670
Usage: "Get the markdown content of a URL",
67-
Arguments: []cli.Argument{&cli.StringArg{Name: "url"}},
71+
Arguments: []cli.Argument{&cli.StringArg{Name: URL}},
6872
Flags: append([]cli.Flag{
6973
&cli.BoolFlag{Name: "include-images", Aliases: []string{"i"}, Usage: "include images in markdown output"},
7074
}, baseFlags...),
@@ -78,7 +82,7 @@ func main() {
7882
}, {
7983
Name: "plaintext",
8084
Usage: "Get the plantext content of a URL",
81-
Arguments: []cli.Argument{&cli.StringArg{Name: "url"}},
85+
Arguments: []cli.Argument{&cli.StringArg{Name: URL}},
8286
Flags: baseFlags,
8387
Action: func(ctx context.Context, cmd *cli.Command) error {
8488
return runTask(ctx, cmd, "plaintext", map[string]any{}, stdOutCallback)
@@ -100,12 +104,12 @@ func runTask(ctx context.Context, cmd *cli.Command, name string, params map[stri
100104
deviceType := cmd.StringArg("device-type")
101105
remoteHost := cmd.String("remote-host")
102106
remotePort := cmd.Int("remote-port")
103-
urls := cmd.StringArgs("url")
107+
urls := cmd.StringArgs(URL)
104108

105109
opts := []engine.Option{engine.WithLogger(virgo.Logger())}
106110

107111
if len(urls) == 0 {
108-
url := cmd.StringArg("url")
112+
url := cmd.StringArg(URL)
109113
urls = []string{url}
110114
}
111115

@@ -147,7 +151,7 @@ func stdOutCallback(cmd *cli.Command, e *engine.Engine) error {
147151
}
148152

149153
logger.Debug().
150-
Str("url", r.URL).
154+
Str(URL, r.URL).
151155
Str("duration", r.Elapsed.String()).
152156
Msg("plaintext result")
153157

@@ -186,7 +190,7 @@ func screenshotCallback(cmd *cli.Command, e *engine.Engine) error {
186190
}
187191

188192
logger.Debug().
189-
Str("url", r.URL).
193+
Str(URL, r.URL).
190194
Str("duration", r.Elapsed.String()).
191195
Msg("screenshot result")
192196

engine/engine_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func TestWithRemoteAllocator(t *testing.T) {
3838

3939
for _, tt := range tests {
4040
t.Run(tt.name, func(t *testing.T) {
41+
t.Parallel()
42+
4143
engine := New(1, WithRemoteAllocator(tt.host, tt.port))
4244

4345
assert.Equal(t, tt.expectedUrl, engine.config.remoteURL)
@@ -49,6 +51,8 @@ func TestWithLogger(t *testing.T) {
4951
t.Parallel()
5052

5153
t.Run("sets logger on engine", func(t *testing.T) {
54+
t.Parallel()
55+
5256
logger := zerolog.Nop()
5357

5458
engine := New(1, WithLogger(&logger))
@@ -62,6 +66,8 @@ func TestNew(t *testing.T) {
6266
t.Parallel()
6367

6468
t.Run("creates engine with valid concurrency", func(t *testing.T) {
69+
t.Parallel()
70+
6571
concurrency := 5
6672
engine := New(concurrency)
6773

@@ -72,6 +78,8 @@ func TestNew(t *testing.T) {
7278
})
7379

7480
t.Run("sets minimum concurrency to 1 when less than 1", func(t *testing.T) {
81+
t.Parallel()
82+
7583
engine := New(0)
7684
assert.Equal(t, 1, engine.config.concurrency)
7785

@@ -80,6 +88,8 @@ func TestNew(t *testing.T) {
8088
})
8189

8290
t.Run("creates engine with multiple options", func(t *testing.T) {
91+
t.Parallel()
92+
8393
logger := zerolog.Nop()
8494
host := "localhost"
8595
port := 9222
@@ -97,6 +107,8 @@ func TestNew(t *testing.T) {
97107
})
98108

99109
t.Run("creates engine with no options", func(t *testing.T) {
110+
t.Parallel()
111+
100112
engine := New(2)
101113

102114
assert.NotNil(t, engine)
@@ -106,6 +118,8 @@ func TestNew(t *testing.T) {
106118
})
107119

108120
t.Run("channels have correct buffer sizes", func(t *testing.T) {
121+
t.Parallel()
122+
109123
concurrency := 10
110124
engine := New(concurrency)
111125

@@ -121,6 +135,8 @@ func TestOptions_CanBeComposed(t *testing.T) {
121135
t.Parallel()
122136

123137
t.Run("options can be created and applied separately", func(t *testing.T) {
138+
t.Parallel()
139+
124140
logger := zerolog.Nop()
125141

126142
opts := []Option{

internal/browser/profiles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const SIZE_SMALL = "small"
77
const PROFILE_DESKTOP = "desktop"
88
const PROFILE_MOBILE = "mobile"
99

10-
var ChromeDesktopUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
10+
const ChromeDesktopUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
1111

1212
func IsValidDeviceType(deviceType string) bool {
1313
return (deviceType == PROFILE_DESKTOP) || (deviceType == PROFILE_MOBILE)

internal/pagetest/pagetest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
9595

9696
func NewTestContext() (context.Context, context.CancelFunc) {
9797
ctx := context.Background()
98-
remoteUrl, useRemote := os.LookupEnv("virgo_CHROMEDP_REMOTE_URL")
98+
remoteUrl, useRemote := os.LookupEnv("CHROMEDP_REMOTE_URL")
9999
if useRemote {
100100
return browser.StartRemote(ctx, remoteUrl)
101101
}
102102

103-
_, useHeadfull := os.LookupEnv("virgo_HEADFULL")
103+
_, useHeadfull := os.LookupEnv("CHROMEDP_HEADFULL")
104104

105105
return browser.StartLocal(ctx, useHeadfull)
106106
}

0 commit comments

Comments
 (0)