*: check that assets are up-to-date (#4731)

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
pull/4847/head
Simon Pasquier 6 years ago committed by GitHub
parent 7465118a2c
commit 5230e2730a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,7 +17,7 @@ jobs:
steps:
- checkout
- run: make promu
- run: make check_license style unused staticcheck build
- run: make check_license style unused staticcheck build check_assets
- store_artifacts:
path: prometheus
destination: /build/prometheus

@ -10,4 +10,4 @@ go:
go_import_path: github.com/prometheus/prometheus
script:
- make check_license style unused test staticcheck
- make check_license style unused test staticcheck check_assets

@ -29,3 +29,12 @@ DOCKER_IMAGE_NAME ?= prometheus
assets:
@echo ">> writing assets"
cd $(PREFIX)/web/ui && go generate
@$(GOFMT) -w ./web/ui
.PHONY: check_assets
check_assets: assets
@echo ">> checking that assets are up-to-date"
@if ! (cd $(PREFIX)/web/ui && git diff --exit-code); then \
echo "Run 'make assets' and commit the changes to fix the error."; \
exit 1; \
fi

@ -0,0 +1,67 @@
// Copyright 2018 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package modtimevfs implements a virtual file system that returns a fixed
// modification time for all files and directories.
package modtimevfs
import (
"net/http"
"os"
"time"
)
type timefs struct {
fs http.FileSystem
t time.Time
}
// New returns a file system that returns constant modification time for all files.
func New(fs http.FileSystem, t time.Time) http.FileSystem {
return &timefs{fs: fs, t: t}
}
type file struct {
http.File
os.FileInfo
t time.Time
}
func (t *timefs) Open(name string) (http.File, error) {
f, err := t.fs.Open(name)
if err != nil {
return f, err
}
defer func() {
if err != nil {
f.Close()
}
}()
fstat, err := f.Stat()
if err != nil {
return nil, err
}
return &file{f, fstat, t.t}, nil
}
// Stat implements the http.File interface.
func (f *file) Stat() (os.FileInfo, error) {
return f, nil
}
// ModTime implements the os.FileInfo interface.
func (f *file) ModTime() time.Time {
return f.t
}

@ -17,13 +17,17 @@ package main
import (
"log"
"time"
"github.com/prometheus/prometheus/web/ui"
"github.com/shurcooL/vfsgen"
"github.com/prometheus/prometheus/pkg/modtimevfs"
"github.com/prometheus/prometheus/web/ui"
)
func main() {
err := vfsgen.Generate(ui.Assets, vfsgen.Options{
fs := modtimevfs.New(ui.Assets, time.Unix(1, 0))
err := vfsgen.Generate(fs, vfsgen.Options{
PackageName: "ui",
BuildTags: "!dev",
VariableName: "Assets",

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save