Merge pull request 'fix(ci): build and push only after lint and tests pass' (#138) from fix/ci-order into main
ci / lint (push) Successful in 9m23s
ci / test (push) Successful in 14m58s
ci / build (push) Successful in 16m15s
ci / image (push) Successful in 4m43s

This commit was merged in pull request #138.
This commit is contained in:
Sebi committed 2026-11-23 19:58:50 +00:00
commit ac0d212a01
3 files changed
+12 -1

No files matched your search

+3
View File
@@ -122,6 +122,9 @@ jobs:
run: go test -p 1 -count=1 ./... run: go test -p 1 -count=1 ./...
build: build:
# Nothing is built or pushed from code that fails lint or tests; the
# image job waits for this one.
needs: [lint, test]
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
version: ${{ steps.binaries.outputs.version }} version: ${{ steps.binaries.outputs.version }}
+6 -1
View File
@@ -60,6 +60,8 @@ type Server struct {
mu sync.Mutex mu sync.Mutex
cache map[string]entry cache map[string]entry
refreshing map[string]bool refreshing map[string]bool
// background tracks refreshes started by visits.
background sync.WaitGroup
} }
// entry is one cached page, also its on-disk form. // entry is one cached page, also its on-disk form.
@@ -309,7 +311,7 @@ func (s *Server) lookup(ctx context.Context, key, host, slug string) (entry, boo
s.mu.Unlock() s.mu.Unlock()
if cached { if cached {
if s.now().Sub(e.Fetched) >= freshFor { if s.now().Sub(e.Fetched) >= freshFor {
go s.refresh(context.WithoutCancel(ctx), key, host, slug) s.background.Go(func() { s.refresh(context.WithoutCancel(ctx), key, host, slug) })
} }
return e, true return e, true
} }
@@ -356,6 +358,9 @@ func (s *Server) refresh(ctx context.Context, key, host, slug string) {
s.fetch(ctx, key, host, slug) s.fetch(ctx, key, host, slug)
} }
// Wait returns once the background refreshes started by visits are done.
func (s *Server) Wait() { s.background.Wait() }
// Run keeps every known page fresh until ctx ends, so pages stay current // Run keeps every known page fresh until ctx ends, so pages stay current
// even without visitors and the cache is warm when the API goes away. // even without visitors and the cache is warm when the API goes away.
func (s *Server) Run(ctx context.Context) { func (s *Server) Run(ctx context.Context) {
+3
View File
@@ -73,6 +73,9 @@ func newHarness(t *testing.T, src *fakeSource, dir string, now *time.Time) harne
t.Fatal(err) t.Fatal(err)
} }
s.now = func() time.Time { return *now } s.now = func() time.Time { return *now }
// Runs before the cleanup of a TempDir created earlier, so no refresh
// writes into a directory being removed.
t.Cleanup(s.Wait)
gin.SetMode(gin.TestMode) gin.SetMode(gin.TestMode)
r := gin.New() r := gin.New()
s.Mount(r) s.Mount(r)