Skip to content

Commit

Permalink
Add CI (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg authored Oct 27, 2023
1 parent 1f9d25b commit 9bf0400
Show file tree
Hide file tree
Showing 5 changed files with 314 additions and 53 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: build

permissions: {} # no need any permissions

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 10 * * 1' # run "At 10:00 on Monday"

jobs:
run:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: stable
check-latest: true

- name: Go Format
run: gofmt -s -w . && git diff --exit-code

- name: Go Tidy
run: go mod tidy && git diff --exit-code

- name: Go Mod
run: go mod download

- name: Go Mod Verify
run: go mod verify

- name: Go Compile Tests
run: go test -exec /bin/true ./...

- name: Go Benchmark
run: go test -v -shuffle=on -run=- -bench=. -benchtime=1x ./...
27 changes: 0 additions & 27 deletions bencode/bencode_marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (

IncSW "github.com/IncSW/go-bencode"
anacrolix "github.com/anacrolix/torrent/bencode"
chihaya "github.com/chihaya/chihaya/frontend/http/bencode"
cristalhq "github.com/cristalhq/bencode"
cuberat "github.com/cuberat/go-bencode"
ehmry "github.com/ehmry/go-bencode"
jackpal "github.com/jackpal/bencode-go"
lajide "github.com/lajide/bencode"
lwch "github.com/lwch/bencode"
Expand Down Expand Up @@ -124,7 +122,6 @@ func Benchmark_Nabilanam_Marshal(b *testing.B) {
}

func Benchmark_Jackpal_Marshal(b *testing.B) {
b.Skip()
w := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
Expand All @@ -135,18 +132,6 @@ func Benchmark_Jackpal_Marshal(b *testing.B) {
}
}

func Benchmark_Chihaya_Marshal(b *testing.B) {
b.Skip()
w := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := chihaya.NewEncoder(w).Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
}
}

func Benchmark_Owenliang_Marshal(b *testing.B) {
b.Skip()
b.ReportAllocs()
Expand All @@ -170,18 +155,6 @@ func Benchmark_Tumdum_Marshal(b *testing.B) {
}
}

func Benchmark_Ehmry_Marshal(b *testing.B) {
b.Skip()
w := bytes.NewBuffer(make([]byte, 0, 1<<12))
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := ehmry.NewEncoder(w).Encode(marshalBenchData)
if err != nil {
b.Fatal(err)
}
}
}

func Benchmark_Stints_Marshal(b *testing.B) {
b.Skip()
b.ReportAllocs()
Expand Down
26 changes: 0 additions & 26 deletions bencode/bencode_unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import (

IncSW "github.com/IncSW/go-bencode"
anacrolix "github.com/anacrolix/torrent/bencode"
chihaya "github.com/chihaya/chihaya/frontend/http/bencode"
cristalhq "github.com/cristalhq/bencode"
cuberat "github.com/cuberat/go-bencode"
ehmry "github.com/ehmry/go-bencode"
jackpal "github.com/jackpal/bencode-go"
lajide "github.com/lajide/bencode"
lwch "github.com/lwch/bencode"
Expand Down Expand Up @@ -98,7 +96,6 @@ func Benchmark_MarksammanBencode_Unmarshal(b *testing.B) {
}

func Benchmark_JackpalBencode_Unmarshal(b *testing.B) {
b.Skip()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
r := bytes.NewReader(unmarshalBenchData)
Expand All @@ -109,14 +106,6 @@ func Benchmark_JackpalBencode_Unmarshal(b *testing.B) {
}
}

func Benchmark_ChihayaBencode_Unmarshal(b *testing.B) {
b.Skip()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
chihaya.Unmarshal(unmarshalBenchData)
}
}

func Benchmark_AnacrolixTorrent_Unmarshal(b *testing.B) {
b.Skip()
res := map[string]interface{}{}
Expand Down Expand Up @@ -160,21 +149,6 @@ func Benchmark_TumdumBencoding_Unmarshal(b *testing.B) {
}
}

func Benchmark_EhmryGoBencode_Unmarshal(b *testing.B) {
b.Skip()
res := map[string]interface{}{}
b.ReportAllocs()
for n := 0; n < b.N; n++ {
err := ehmry.Unmarshal(unmarshalBenchData, &res)
if err != nil {
b.Fatal(err)
}
if res == nil {
b.Fatal("is nil")
}
}
}

func Benchmark_StintsBencode_Unmarshal(b *testing.B) {
b.Skip()
}
Expand Down
12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ go 1.21
// bencode
require (
github.com/IncSW/go-bencode v0.2.2
github.com/anacrolix/torrent v1.53.1
github.com/cristalhq/bencode v0.4.0
github.com/cuberat/go-bencode v1.0.0
github.com/jackpal/bencode-go v1.0.0
github.com/lajide/bencode v0.0.0-20190629152703-fb09cf4e9a4a
github.com/lwch/bencode v1.0.0
github.com/marksamman/bencode v0.0.0-20150821143521-dc84f26e086e
github.com/nabilanam/bencode v0.0.0-20190329141800-cde546b1530b
github.com/owenliang/dht v0.0.0-20180118074908-44baeeba7b13
github.com/stints/bencode v0.0.0-20160226205624-0ba65bd80165
github.com/tumdum/bencoding v0.0.0-20160911135503-fcfcb8bd55e9
github.com/zeebo/bencode v1.0.0
)

Expand Down Expand Up @@ -39,9 +48,12 @@ require (
)

require (
github.com/anacrolix/missinggo v1.3.0 // indirect
github.com/anacrolix/missinggo/v2 v2.7.2-0.20230527121029-a582b4f397b9 // indirect
github.com/fogleman/gg v1.3.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/smartystreets/goconvey v1.8.1 // indirect
Expand Down
Loading

0 comments on commit 9bf0400

Please sign in to comment.