From c4fa370b4fba26ce1851782f170906c3c10b01c8 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 29 Aug 2020 14:52:47 +0200 Subject: [PATCH 1/3] Add 'make watch' This combines frontend and backend watch into a single command that runs them in parallel on on SIGINT terminates both. Termination is not super-clean but I guess it does not have to. --- Makefile | 5 +++++ build/watch.sh | 11 +++++++++++ docs/content/doc/advanced/hacking-on-gitea.en-us.md | 8 ++------ 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 build/watch.sh diff --git a/Makefile b/Makefile index 1fec4eb503cad..42ff97b42bab4 100644 --- a/Makefile +++ b/Makefile @@ -155,6 +155,7 @@ help: @echo " - build build everything" @echo " - frontend build frontend files" @echo " - backend build backend files" + @echo " - watch watch everything and continuously rebuild" @echo " - watch-frontend watch frontend files and continuously rebuild" @echo " - watch-backend watch backend files and continuously rebuild" @echo " - clean delete backend and integration files" @@ -314,6 +315,10 @@ lint-frontend: node_modules .PHONY: lint-backend lint-backend: golangci-lint revive vet +.PHONY: watch +watch: + bash build/watch.sh + .PHONY: watch-frontend watch-frontend: node-check $(FOMANTIC_DEST) node_modules rm -rf $(WEBPACK_DEST_ENTRIES) diff --git a/build/watch.sh b/build/watch.sh new file mode 100644 index 0000000000000..3a5436fb9fbac --- /dev/null +++ b/build/watch.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -euo pipefail +trap "kill 0" SIGINT + +make --no-print-directory watch-frontend & +PIDS+="$! "; +make --no-print-directory watch-backend & +PIDS+="$!"; + +trap "kill ${PIDS[*]}" SIGINT +wait $PIDS diff --git a/docs/content/doc/advanced/hacking-on-gitea.en-us.md b/docs/content/doc/advanced/hacking-on-gitea.en-us.md index b24260c68a42a..17bb330a28a1b 100644 --- a/docs/content/doc/advanced/hacking-on-gitea.en-us.md +++ b/docs/content/doc/advanced/hacking-on-gitea.en-us.md @@ -97,14 +97,10 @@ See `make help` for all available `make` targets. Also see [`.drone.yml`](https: ## Building continuously -Both the `frontend` and `backend` targets can be ran continuously when source files change: +To run and continously rebuild when source files change: ````bash -# in your first terminal -make watch-backend - -# in your second terminal -make watch-frontend +make watch ```` On macOS, watching all backend source files may hit the default open files limit which can be increased via `ulimit -n 12288` for the current shell or in your shell startup file for all future shells. From a2cecef61d7c856b0d22f25e86e74de48770a6ee Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 29 Aug 2020 19:59:59 +0200 Subject: [PATCH 2/3] move to tools/, trap more signals, remove gnu-specific flag --- Makefile | 2 +- build/watch.sh | 11 ----------- tools/watch.sh | 11 +++++++++++ 3 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 build/watch.sh create mode 100644 tools/watch.sh diff --git a/Makefile b/Makefile index 42ff97b42bab4..11d0d7bbad445 100644 --- a/Makefile +++ b/Makefile @@ -317,7 +317,7 @@ lint-backend: golangci-lint revive vet .PHONY: watch watch: - bash build/watch.sh + bash tools/watch.sh .PHONY: watch-frontend watch-frontend: node-check $(FOMANTIC_DEST) node_modules diff --git a/build/watch.sh b/build/watch.sh deleted file mode 100644 index 3a5436fb9fbac..0000000000000 --- a/build/watch.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -euo pipefail -trap "kill 0" SIGINT - -make --no-print-directory watch-frontend & -PIDS+="$! "; -make --no-print-directory watch-backend & -PIDS+="$!"; - -trap "kill ${PIDS[*]}" SIGINT -wait $PIDS diff --git a/tools/watch.sh b/tools/watch.sh new file mode 100644 index 0000000000000..2873225610800 --- /dev/null +++ b/tools/watch.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -euo pipefail +trap "kill 0" SIGINT SIGTERM SIGQUIT + +make watch-frontend & +PIDS+="$! "; +make watch-backend & +PIDS+="$!"; + +trap "kill ${PIDS[*]}" SIGINT SIGTERM SIGQUIT +wait $PIDS From f13d864f4fec859b642d7e35906b69fa94d78850 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 30 Aug 2020 18:13:08 +0200 Subject: [PATCH 3/3] simplify --- tools/watch.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/watch.sh b/tools/watch.sh index 2873225610800..61e3dc40a25bc 100644 --- a/tools/watch.sh +++ b/tools/watch.sh @@ -1,11 +1,8 @@ #!/bin/bash set -euo pipefail -trap "kill 0" SIGINT SIGTERM SIGQUIT make watch-frontend & -PIDS+="$! "; make watch-backend & -PIDS+="$!"; -trap "kill ${PIDS[*]}" SIGINT SIGTERM SIGQUIT -wait $PIDS +trap 'kill $(jobs -p)' EXIT +wait