Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frontend/backend make targets, fix source release #10325

Merged
merged 4 commits into from Feb 22, 2020

Conversation

silverwind
Copy link
Member

  • Fix missing 'dist' folders inside 'node_modules' being excluded because of tar excluding them recursively.

  • Add 'make build-offline' which skips on verifying node_modules and stops npx from downloading missing dependencies on-demand.

  • Store VERSION in file VERSION for the release tarballs and prefer that file over git-derived version.

Makefile Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 17, 2020
@techknowlogick techknowlogick added the topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile label Feb 17, 2020
@techknowlogick techknowlogick added this to the 1.12.0 milestone Feb 17, 2020
@codecov-io
Copy link

codecov-io commented Feb 17, 2020

Codecov Report

Merging #10325 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10325      +/-   ##
==========================================
- Coverage   43.75%   43.74%   -0.02%     
==========================================
  Files         586      586              
  Lines       81265    81265              
==========================================
- Hits        35560    35549      -11     
- Misses      41309    41317       +8     
- Partials     4396     4399       +3
Impacted Files Coverage Δ
services/pull/check.go 50% <0%> (-3.05%) ⬇️
modules/git/command.go 86.95% <0%> (-2.61%) ⬇️
models/notification.go 63.29% <0%> (-1.9%) ⬇️
modules/queue/workerpool.go 58% <0%> (+1.06%) ⬆️
modules/indexer/stats/db.go 59.37% <0%> (+9.37%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c8d1c38...27039e9. Read the comment docs.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@silverwind
Copy link
Member Author

silverwind commented Feb 18, 2020

Maybe we need a quick vote:

👍 ship built webpack assets in the source tarball
👎 don't ship built webpack assets in the source tarball

Decision made, see #10325 (comment)

@guillep2k
Copy link
Member

Maybe we need a quick vote:

👍 ship built webpack assets in the source tarball
👎 don't ship built webpack assets in the source tarball

I guess it depends. As long as it's still useful for the package distributions, I figure the smaller the better. But I can't really say what "strict rules" they need to abide. 😓

Please take this with a grain of salt since packages and distributions are not my area of expertise: I think it would be cool to leave only go code left for compiling, with all assets ready to pack (css, js, etc). That way anyone's offline-built Gitea would be as close to our own packages as it gets. If any intermediate node stages could give us a surprise in one platform or another, that's avoided (*). We should probably not include anything node related (save of course source code directly from our repo) since anybody else that just wants the tarball for building from source can actually go and download those.

(*) We've recently turned down a js library because it referenced pre-compiled binaries that were not available in all platforms; I can't remember what it was ATM.

@silverwind
Copy link
Member Author

silverwind commented Feb 19, 2020

Yeah I guess it's a matter of "we compile" vs. "user compiles". But given that the target is the browser, it really does not matter who does it and I think we're in a better position to produce proper files then relying on a inconsistent Node.js version installed by the distributor on their build system. Still Node.js should stay as a build dependency of course, even if not used in this special case.

Native Node.js dependencies are a absolute no-go and I think we should actually enforce a check for it on CI, maybe something I will check out later.

I will update the PR to include the assets again later.

@silverwind
Copy link
Member Author

This will need a 1.11 backport to fully resolve #10253.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 19, 2020
@silverwind
Copy link
Member Author

silverwind commented Feb 19, 2020

So the only remaining topic here is whether we should attempt to skip the fomantic/webpack build because depending on tar extraction order, the webpack and fomantic steps will run on a extracted source tarball that includes the assets. We could potentially add a hackish @touch $(WEBPACK_DEST) $(FOMANTIC_EVIDENCE) prereq step to the build-offline but I'd prefer to not add tarball-specific hacks to that target.

@guillep2k
Copy link
Member

So the only remaining topic here is whether we should attempt to skip the fomantic/webpack build

👍

I vote for skipping them. If we reorder the dependency tree (maybe split a couple of them in two) we should be able to remove those from the list. i.e. make build-offline should only require go.

@silverwind
Copy link
Member Author

If I remove them from the prereq chain, make build-offline does not seem like a appropriate name any more, as it's now make build-offline-without-frontend-assets. Any idea on a better name? Maybe make build-dist?

@guillep2k
Copy link
Member

Maybe make build-dist?

Sounds good to me!

@sapk
Copy link
Member

sapk commented Feb 19, 2020

build-from-archive ?

@silverwind silverwind changed the title Fix release tarballs, add 'make build-offline' Add frontend/backend make targets, fix source release Feb 21, 2020
@silverwind
Copy link
Member Author

PR reworked, here is a updated summary:

- Add 'make backend' and 'make frontend' make targets which are used to
  build go and js/css/svg files respectively.

- The 'backend' target can be invoked without requiring Node.js to be
  present on the system if pre-built frontend assets are present like
  in the release source tarballs.

- Fix source releases missing 'dist' folders inside 'node_modules' which
  were erronously excluded from tar.

- Store VERSION in file VERSION for the release tarballs and prefer that
  file over git-derived version.

Copy link
Member

@guillep2k guillep2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this looks much nicer! 🚀

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 22, 2020
- Add 'make backend' and 'make frontend' make targets which are used to
  build go and js/css/svg files respectively.

- The 'backend' target can be invoked without requiring Node.js to be
  present on the system if pre-built frontend assets are present like
  in the release source tarballs.

- Fix source releases missing 'dist' folders inside 'node_modules' which
  were erronously excluded from tar.

- Store VERSION in file VERSION for the release tarballs and prefer that
  file over git-derived version.
README.md Show resolved Hide resolved
@lunny lunny merged commit 2ed9ead into go-gitea:master Feb 22, 2020
@lunny
Copy link
Member

lunny commented Feb 22, 2020

Please send backport to v1.11

@silverwind
Copy link
Member Author

Backport: #10414

silverwind added a commit to silverwind/gitea that referenced this pull request Feb 22, 2020
* Add frontend/backend make targets, fix source release

- Add 'make backend' and 'make frontend' make targets which are used to
  build go and js/css/svg files respectively.

- The 'backend' target can be invoked without requiring Node.js to be
  present on the system if pre-built frontend assets are present like
  in the release source tarballs.

- Fix source releases missing 'dist' folders inside 'node_modules' which
  were erronously excluded from tar.

- Store VERSION in file VERSION for the release tarballs and prefer that
  file over git-derived version.

* fix release task

* fix typo

* fix another typo

Fixes: go-gitea#10253
@sapk sapk added the backport/done All backports for this PR have been created label Feb 22, 2020
guillep2k pushed a commit that referenced this pull request Feb 22, 2020
* Add frontend/backend make targets, fix source release

- Add 'make backend' and 'make frontend' make targets which are used to
  build go and js/css/svg files respectively.

- The 'backend' target can be invoked without requiring Node.js to be
  present on the system if pre-built frontend assets are present like
  in the release source tarballs.

- Fix source releases missing 'dist' folders inside 'node_modules' which
  were erronously excluded from tar.

- Store VERSION in file VERSION for the release tarballs and prefer that
  file over git-derived version.

* fix release task

* fix typo

* fix another typo

Fixes: #10253
@strk
Copy link
Member

strk commented Feb 27, 2020

Sorry, I'm confused: in current master branch (6b01972) I find no build-offline nor backend Makefile target. What's the deal ?

@jolheiser
Copy link
Member

jolheiser commented Feb 27, 2020

6b01972 is from 6 days ago, this was merged after that

@strk
Copy link
Member

strk commented Feb 27, 2020 via email

@silverwind
Copy link
Member Author

build-offline never made it to any official branch, fyi.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants