Skip to content

Commit

Permalink
ci changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TymKh committed Nov 6, 2024
1 parent 22862dc commit a6e465f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 36 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Set up Go
uses: actions/setup-go@v3
Expand All @@ -20,6 +32,9 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Run migrations
run: for file in schema/*.sql; do psql "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" -f $file; done

- name: Run unit tests and generate the coverage report
run: make test-race

Expand All @@ -40,7 +55,7 @@ jobs:
run: go install mvdan.cc/[email protected]

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@v0.4.2
run: go install honnef.co/go/tools/cmd/staticcheck@2024.1.1

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/[email protected]
Expand Down
1 change: 1 addition & 0 deletions adapters/database/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestGetBuilder(t *testing.T) {
t.Skip("skip until db is setup")
serv, err := NewDatabaseService("postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable")
if err != nil {
t.Errorf("NewDatabaseService() = %v; want nil", err)
Expand Down
4 changes: 0 additions & 4 deletions httpserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,3 @@ func (srv *Server) handleTestPanic(w http.ResponseWriter, r *http.Request) {
panic("foo")
// w.WriteHeader(http.StatusOK)
}

//
// BuilderConfigHub API: https://www.notion.so/flashbots/BuilderConfigHub-1076b4a0d8768074bcdcd1c06c26ec87?pvs=4#10a6b4a0d87680fd81e0cad9bac3b8c5
//
31 changes: 0 additions & 31 deletions httpserver/handler_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package httpserver

import (
"bytes"
"io"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -99,33 +98,3 @@ func Test_Handlers_Healthcheck_Drain_Undrain(t *testing.T) {
require.Equal(t, http.StatusOK, resp.StatusCode, "Healthcheck must return `Ok` after undraining")
}
}

func Test_Handlers_BuilderConfigHub(t *testing.T) {
routes := []struct {
method string
path string
payload []byte
}{
// BuilderConfigHub API: https://www.notion.so/flashbots/BuilderConfigHub-1076b4a0d8768074bcdcd1c06c26ec87?pvs=4#10a6b4a0d87680fd81e0cad9bac3b8c5
{http.MethodGet, "/api/l1-builder/v1/measurements", nil},
{http.MethodGet, "/api/l1-builder/v1/configuration", nil},
{http.MethodGet, "/api/l1-builder/v1/builders", nil},
{http.MethodPost, "/api/l1-builder/v1/register_credentials/rbuilder", []byte(`{"var1":"foo"}`)},
}

srv, err := NewHTTPServer(testServerConfig, ports.NewBuilderHubHandler(nil, getTestLogger()))
require.NoError(t, err)

for _, r := range routes {
var payload io.Reader
if r.payload != nil {
payload = bytes.NewReader(r.payload)
}
req, err := http.NewRequest(r.method, r.path, payload)
require.NoError(t, err)

rr := httptest.NewRecorder()
srv.getRouter().ServeHTTP(rr, req)
require.Equal(t, http.StatusOK, rr.Code)
}
}

0 comments on commit a6e465f

Please sign in to comment.