forgejo-release.sh: Improve support for different Linux bases #95
No reviewers
Labels
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
actions/forgejo-release!95
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Synchro/forgejo-release:distro-agnostic"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently if you run this action and aren't using a Debian based runner you need to install all tools ahead of time or the Action fails.
Calls to dpkg and apt are replaced with Distro-agnostic equivalents. Additionally the use of
whichhas also been swapped out withcommand -vfor use in environments wherewhichisn't available.This should improve the behaviour so that it will attempt to install all dependencies on a best effort basis, and at the very least provide some information to the console.
@ -172,0 +191,4 @@echo "jq and/or curl missing, attempting to install..." >&2if command -v apt-get >/dev/null 2>&1; thenthese all need to be tested
I've tested this with all the listed package managers locally and they all work properly.
Do you want me to write a test in CI to do this? Adding a unit test is also something that could be done if wanted.
Also: looking at this again, yum is fairly niche and could probably be removed.
I have a version of CentOS 7 that I run locally when an archaic build environment is required.
@Synchro wrote in #95 (comment):
Yes, this is what will guard this against future regressions. Untested code, however small and simple, tend to break. And without CI, fixing it will require a contributor to manually re-created the problem which is going to be non trivial.
I'll make some changes to the test.yml workflow. Due to the actions/checkout action being used, images with Node would be required. I will remove everything except the
aptandapkinstall lines, the fallback message is an improvement over how it currently functions now.Testing on Alpine and Debian should be enough; seeing as the release action already assumes you're in a Debian environment.
a91ae74f37854ee4ce4fI have updated the tests.yml workflow so that it runs on a Debian and Alpine base image.
If jq and curl aren't found packages will attempt to be installed. On other distros that we can't test for here, an error message is displayed.
@ -4,1 +6,4 @@tag: [lts, lts-alpine]runs-on: dockercontainer:image: "node:${{ matrix.tag }}"Is needed because:
Also lts and lts-alpine are not mirrored at the moment 😁
Sweet that makes things easy 😄
Didn't realise you guys had local mirrors, I'll swap those out and then hopefully all is good.
This should be in place now as of
1d79e86315Let me know if anything else needs to be adjusted.
854ee4ce4f1d79e86315https://code.forgejo.org/actions/forgejo-release/actions/runs/846/jobs/0/attempt/2
the checkout action fails on 22-alpine 🤔
you need to install bash for alpline before running the tests, that's why it fails
@earl-warren wrote in #95 (comment):
It works, it is bash missing, of course. It is worth a mention in the action.yml / README
@earl-warren wrote in #95 (comment):
Ah that's a good point. Do you have any issues with dropping some bash-isms in the script(s) and using POSIX sh instead?
Functionality should be identical, just some minor syntax adjustments should be needed. That should solve any issues for images that lack
bashOkay, it looks like I have everything working according to the tests!
Let me know if you'd like any changes to the implementation, or if there is anything new that needs to be added to the
integration.ymlworkflow.@ -4,0 +4,4 @@strategy:matrix:image:- code.forgejo.org/oci/node:22-trixienot data.forgejo.org? @earl-warren ?
that's ok for now, it lands on code.forgejo.org anyways. Only actions are on a separate server.
@ -29,0 +43,4 @@}check_dependencies() {# Always required for API parsing and downloadsConcerning my comment below, don’t check always for these default deps, but make them all extra arguments.
Good point! I was tempted to go that route initially and I guess I should have in hindsight 😄
I can make that adjustment, setup_api can pass in curl and jq as arguments. One limitation that might be good to adjust in the future when it becomes a problem is that the binary names that are searched for with
command -vmay not match the package name.As of now however it seems like the package name matches the binaries that they provide (for the packages that this action needs)
Fixed with !95 (commit
5d73a41e6a)@ -128,3 +175,2 @@sign_release() {local passphraseif test -s "$GPG_PASSPHRASE"; thencheck_dependencies gpg gpg-agentAfter this latest edit it seems to me that
check_dependenciesshould always be called with input arguments, e.g.,sign_releasedoes not need jq and curl.Fixed with !95 (commit
5d73a41e6a)@Synchro wrote in #95 (comment):
Looks good, in my opinion!
@ -4,0 +5,4 @@matrix:image:- code.forgejo.org/oci/node:22-trixie- code.forgejo.org/oci/node:22-alpinewhy not
node:24?This was to make sure that the LTS release is targeted, there is no
LTStag that is mirrored.See below for context:
#95 (comment)
OK, thanks for the explanation.
@earl-warren Why can't I resolve threads here?
that changes the scope of the pull request significantly. It is excellent the tests pass but it will take time to review it thoroughly.
Could you split this refactor in a different pull request? It is fine with me on principle.
@earl-warren wrote in #95 (comment):
I found reviewing via the new single-commit review with split view pleasant for this PR. But, up to you to decide.
I agree this pull request is very pleasant to work with. There are two very different topics (refactor + alpine support) and I do prefer they are in two separate pull requests to help with discovery in the future.
Apologies I got swamped with work, so just got to looking at this now.
I can go ahead and split this PR into two parts, but in order for Alpine support to function correctly without first installing bash the refactor is also needed. It feels a bit weird to require bash for this PR when in reality a minor refactor is needed to avoid it entirely.
If I do split this PR in two parts the testing will fail when run on an Alpine container. So I can either disable Alpine tests or omit it from this PR entirely or I can rephrase this PR to be a POSIX sh refactor + improvements to dependency checking.
If reordering the commits is what you'd like to make it easier to review (or make more sense overall) let me know.
The refactor only really does some minor syntax changes (dealing with arrays, debugging adjustments) other functionality is untouched.
@ -29,0 +63,4 @@return 1fifi}I would also add
dnfandpacman. Do note that this will not work on bare-metal (dockerless) runners.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.