8000 Detect ubuntu version from /etc/os-release if ImageOS = Linux by iStefo · Pull Request #327 · erlef/setup-beam · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Detect ubuntu version from /etc/os-release if ImageOS = Linux #327

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iStefo
Copy link
@iStefo iStefo commented Apr 25, 2025

Description

Adds logic to getRunnerOSVersion to identify the ubuntu version by reading /etc/os-release.

I have extracted the function into its own file to avoid complications when importing it for unit testing.

Using fs.readFileSync is not ideal, but I saw that the codebase also makes use of other sync fs functions already. Overall, there are a few refactoring opportunities in the codebase 🙃

To avoid bringing in any new dependency, I made use of node's own test runner which is somewhat new and not perfect, but available on LTS. Node's test runner will run all files ending in .test.js, which includes the current single test file.

As test fixtures, I grabbed the contents of /etc/os-release for three ubuntu and one alpine version and added them to the test directory.

Closes #279.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer to keep this in a single file, for now. If the time comes to split we'll do a separate pull request. (also, this way we have to compare/review across different files, which is not ideal)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to follow up with a refactor update, if you'd like, but lets keep concerns separated.

Comment on lines -30 to +32
const osVersion = getRunnerOSVersion()
const osVersion = getRunnerOSVersion(process.env.ImageOS)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer to keep the process. stuff inside the function.


core.info(`ImageOS is set to '${imageOS}'`)

if (imageOS === 'Linux') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be better to just look at /etc/os-release existing than this? Reason for it is we seem to be moving from one constraint to the other. If we want to be more generic we can base ourselves on the standard (/etc/os-release) and not the results we're looking at today.

@paulo-ferraz-oliveira
Copy link
Collaborator

I'm approving the workflow runs. Overall it's good, but I left comments where I think we can change less. For such a small change, 8 new files and syntax changes, etc. seems a bit much, but let's discuss.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you ran npm run build-dist (as https://github.com/erlef/setup-beam/blob/main/CONTRIBUTING.md proposes) so this'll likely fail CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Identify Ubuntu version automatically?
2 participants
0