Skip to content

Commit

Permalink
Merge pull request #284 from camathieu/1.3-RC1
Browse files Browse the repository at this point in the history
1.3-RC1
  • Loading branch information
camathieu authored Mar 4, 2020
2 parents 620be7b + 257e6aa commit 8b35fac
Show file tree
Hide file tree
Showing 880 changed files with 22,519 additions and 303,856 deletions.
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
plik
*/plik
plikd
clients
server/plik.db
*.db
*.db-wal
*.db-shm
server/files
server/public/public
webapp/dist
clients
client/client
servers
server/server
server/common/version.go
release
releases
Expand All @@ -21,3 +22,4 @@ plikd_*.cfg
# IntelliJ IDEA
.idea
plik.iml
coverage.out
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: go
sudo: required

go:
- 1.11.13
- 1.14

go_import_path: github.com/root-gg/plik

Expand All @@ -13,7 +13,7 @@ before_install:
- npm install -g bower

before_script:
- go get -u github.com/golang/lint/golint
- go get -u golang.org/x/lint/golint

script:
- make test && make
- make && make lint && make test && make test-backends && make docker
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
##
#

# Let's start with a fresh debian jessie
FROM debian:jessie
# Let's start with a fresh debian image
FROM debian:buster

# Some generic information
MAINTAINER Charles-Antoine Mathieu
Expand All @@ -22,11 +22,13 @@ EXPOSE 8080
# Copy plik
ADD server /home/plik/server/
ADD clients /home/plik/clients/
ADD webapp /home/plik/webapp/

# Set permission
RUN chown -R plik:plik /home/plik
RUN chmod +x /home/plik/server/plikd

# Launch it
# Launch Plik server
USER plik
WORKDIR /home/plik/server
CMD ./plikd

CMD ./plikd
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ The MIT License (MIT)

Copyright (c) <2015>
- Mathieu Bodjikian <mathieu@bodjikian.fr>
- Charles-Antoine Mathieu <skatkatt@root.gg>
- Charles-Antoine Mathieu <cam@root.gg>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
144 changes: 57 additions & 87 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
###
# The MIT License (MIT)
#
# Copyright (c) <2015>
# - Mathieu Bodjikian <mathieu@bodjikian.fr>
# - Charles-Antoine Mathieu <skatkatt@root.gg>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###
SHELL = /bin/bash

RELEASE_VERSION="1.2.4"
RELEASE_VERSION=$(shell version/version.sh)
RELEASE_DIR="release/plik-$(RELEASE_VERSION)"
RELEASE_TARGETS=darwin-386 darwin-amd64 freebsd-386 \
freebsd-amd64 linux-386 linux-amd64 linux-arm openbsd-386 \
openbsd-amd64 windows-amd64 windows-386

GOHOSTOS=`go env GOHOSTOS`
GOHOSTARCH=`go env GOHOSTARCH`
GOHOSTOS=$(shell go env GOHOSTOS)
GOHOSTARCH=$(shell go env GOHOSTARCH)

DEBROOT_SERVER=debs/server
DEBROOT_CLIENT=debs/client
Expand All @@ -50,16 +26,16 @@ all: clean clean-frontend frontend clients server
# Build frontend ressources
###
frontend:
@if [ ! -d server/public/node_modules ]; then cd server/public && npm install ; fi
@if [ ! -d server/public/bower_components ]; then cd server/public && node_modules/bower/bin/bower install --allow-root ; fi
@if [ ! -d server/public/public ]; then cd server/public && node_modules/grunt-cli/bin/grunt ; fi
@if [ ! -d webapp/node_modules ]; then cd webapp && npm install ; fi
@if [ ! -d webapp/bower_components ]; then cd webapp && node_modules/bower/bin/bower install --allow-root ; fi
@cd webapp && node_modules/grunt-cli/bin/grunt

###
# Build plik server for the current architecture
###
server:
@server/gen_build_info.sh $(RELEASE_VERSION)
@echo "Compiling Plik server"
@echo "Building Plik server"
@cd server && $(build) -o plikd ./

###
Expand All @@ -75,7 +51,7 @@ servers: frontend
mkdir -p ../servers/$$target; \
if [ $$GOOS = "windows" ] ; then SERVER_PATH=$$SERVER_DIR/plikd.exe ; fi ; \
if [ -e $$SERVER_PATH ] ; then continue ; fi ; \
echo "Compiling Plik server for $$target to $$SERVER_PATH"; \
echo "Building Plik server for $$target to $$SERVER_PATH"; \
$(build) -o $$SERVER_PATH ; \
done

Expand All @@ -87,6 +63,7 @@ client:
@echo "Building Plik client"
@cd client && $(build) -o plik ./


###
# Build plik client for all architectures
###
Expand All @@ -101,19 +78,12 @@ clients:
mkdir -p $$CLIENT_DIR; \
if [ $$GOOS = "windows" ] ; then CLIENT_PATH=$$CLIENT_DIR/plik.exe ; fi ; \
if [ -e $$CLIENT_PATH ] ; then continue ; fi ; \
echo "Compiling Plik client for $$target to $$CLIENT_PATH"; \
echo "Building Plik client for $$target to $$CLIENT_PATH"; \
$(build) -o $$CLIENT_PATH ; \
md5sum $$CLIENT_PATH | awk '{print $$1}' > $$CLIENT_MD5; \
done
@mkdir -p clients/bash && cp client/plik.sh clients/bash

###
# Build docker
###
docker: release
@cp Dockerfile $(RELEASE_DIR)
@cd $(RELEASE_DIR) && docker build -t rootgg/plik .

###
# Make server and clients Debian packages
###
Expand Down Expand Up @@ -168,25 +138,18 @@ debs-client: clients
# Prepare the release base (css, js, ...)
###
release-template: clean frontend clients
@mkdir -p $(RELEASE_DIR)/server/public

@cp -R clients $(RELEASE_DIR)
@cp -R changelog $(RELEASE_DIR)
@cp -R server/plikd.cfg $(RELEASE_DIR)/server
@cp -R server/public/css $(RELEASE_DIR)/server/public
@cp -R server/public/fonts $(RELEASE_DIR)/server/public
@cp -R server/public/img $(RELEASE_DIR)/server/public
@cp -R server/public/js $(RELEASE_DIR)/server/public
@cp -R server/public/partials $(RELEASE_DIR)/server/public
@cp -R server/public/public $(RELEASE_DIR)/server/public
@cp -R server/public/index.html $(RELEASE_DIR)/server/public
@cp -R server/public/favicon.ico $(RELEASE_DIR)/server/public
@mkdir -p $(RELEASE_DIR)/webapp
@mkdir -p $(RELEASE_DIR)/server
@cp -r clients $(RELEASE_DIR)
@cp -r changelog $(RELEASE_DIR)
@cp -r webapp/dist $(RELEASE_DIR)/webapp/dist
@cp -r server/plikd.cfg $(RELEASE_DIR)/server

###
# Build release archive
###
release: release-template server
@cp -R server/plikd $(RELEASE_DIR)/server
@cp -R server/plikd $(RELEASE_DIR)/server/plikd
@cd release && tar czvf plik-$(RELEASE_VERSION)-$(GOHOSTOS)-$(GOHOSTARCH).tar.gz plik-$(RELEASE_VERSION)

###
Expand Down Expand Up @@ -225,37 +188,44 @@ build-info:
@server/gen_build_info.sh $(RELEASE_VERSION)

###
# Run tests and sanity checks
# Run linters
###
lint:
@FAIL=0 ;echo -n " - go fmt :" ; OUT=`gofmt -l . | grep -v ^vendor` ; \
if [[ -z "$$OUT" ]]; then echo " OK" ; else echo " FAIL"; echo "$$OUT"; FAIL=1 ; fi ;\
echo -n " - go vet :" ; OUT=`go vet ./...` ; \
if [[ -z "$$OUT" ]]; then echo " OK" ; else echo " FAIL"; echo "$$OUT"; FAIL=1 ; fi ;\
echo -n " - go lint :" ; OUT=`golint ./... | grep -v ^vendor` ; \
if [[ -z "$$OUT" ]]; then echo " OK" ; else echo " FAIL"; echo "$$OUT"; FAIL=1 ; fi ;\
test $$FAIL -eq 0

###
# Run fmt
###
fmt:
@goimports -w -l -local "github.com/root-gg/plik" $(shell find . -type f -name '*.go' -not -path "./vendor/*")

###
# Run tests
###
test:
@if curl -s 127.0.0.1:8080 > /dev/null ; then echo "Plik server probably already running" && exit 1 ; fi
@server/gen_build_info.sh $(RELEASE_VERSION)
@ERR="" ; for directory in server client ; do \
cd $$directory; \
echo -n "go test $$directory : "; \
TEST=`go test -race ./... 2>&1`; \
if [ $$? = 0 ] ; then echo "OK" ; else echo "$$TEST" | grep -v "no test files" | grep -v "^\[" && ERR="1"; fi ; \
echo "go fmt $$directory : "; \
for file in $$(find -name "*.go" | grep -v vendor ); do \
echo -n " - file $$file : " ; \
FMT=`gofmt -l $$file` ; \
if [ "$$FMT" = "" ] ; then echo "OK" ; else echo "FAIL" && ERR="1" ; fi ; \
done; \
echo -n "go tool vet $$directory : "; \
for file in $$(find -name "*.go" | grep -v vendor ); do \
echo -n " - file $$file : " ; \
FMT=`go tool vet $$file` ; \
if [ "$$FMT" = "" ] ; then echo "OK" ; else echo "FAIL" && ERR="1" ; fi ; \
done; \
echo -n "golint $$directory : "; \
for file in $$(find -name "*.go" | grep -v vendor ); do \
echo -n " - file $$file : " ; \
FMT=`golint $$file` ; \
if [ "$$FMT" = "" ] ; then echo "OK" ; else echo "FAIL" && ERR="1" ; fi ; \
done; \
cd - 2>&1 > /dev/null; \
done ; if [ "$$ERR" = "1" ] ; then exit 1 ; fi
@echo "cli client integration tests :\n" && cd client && ./test.sh
@GORACE="halt_on_error=1" go test -race -cover -p 1 ./... 2>&1 | grep -v "no test files"; test $${PIPESTATUS[0]} -eq 0
@echo "cli client integration tests :" && cd client && ./test.sh

###
# Run integration tests for all available backends
###
test-backends:
@testing/test_backends.sh

###
# Build docker
###
docker: release
@cp Dockerfile $(RELEASE_DIR)
@cd $(RELEASE_DIR) && docker build -t rootgg/plik .

###
# Remove server build files
Expand All @@ -274,18 +244,18 @@ clean:
# Remove frontend build files
###
clean-frontend:
@rm -rf server/public/bower_components
@rm -rf server/public/public
@rm -rf webapp/bower_components
@rm -rf webapp/dist

###
# Remove all build files and node modules
###
clean-all: clean clean-frontend
@rm -rf server/public/node_modules
@rm -rf webapp/node_modules

###
# Since the client/server directories are not generated
# Since the client/server/version directories are not generated
# by make, we must declare these targets as phony to avoid :
# "make: `client' is up to date" cases at compile time
###
.PHONY: client server
.PHONY: client server
Loading

0 comments on commit 8b35fac

Please sign in to comment.