Skip to content

Move the logic that invokes setup-fortran.sh out of the action YAML and into a reusable script #123

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

Merged

Conversation

timdawborn
Copy link
Contributor

@timdawborn timdawborn commented Mar 20, 2025

Right now, all of the logic for interacting with setup-fortran.sh is embedded within the YAML file of the Action definition. This logic should ideally be reusable by others, and it's not easily reusable in its current form as its not accessible outside of the YAML.

This PR moves the logic into its own shell script, and updates the YAML to invoke it.

Why am I suggesting this change? I have a use case where I'm building my own CI images using setup-fortran.sh, and I want to be able to reuse this entry logic in my own scripts. What I'd like to be able to get to is have a Dockerfile like as follows, which works the same way as using this action does:

FROM ubuntu:24.04

ARG COMPILER
ARG VERSION
ARG SETUP_FORTRAN_VERSION=v1.6.3

# Update dependencies.
RUN apt update && apt -y upgrade

# Install dependencies.
RUN apt install -y curl make software-properties-common sudo

# Setup the Fortran compiler.
RUN for f in main.sh setup-fortran.sh; do \
      curl -o ${f} "https://raw.githubusercontent.com/fortran-lang/setup-fortran/${SETUP_FORTRAN_VERSION}/${f}" \
    done \
    env COMPILER=$COMPILER VERSION=$VERSION bash main.sh

If we could get to this point, then the pattern I'm setting up here lends itself towards a partial solution for #98. People can setup their own pre-built CI images, reusing the same logic that the Action uses when running on GHA's ubuntu-latest image to setup the Fortran compilers. This is exactly what I'm currently doing. CI time for my own project is down from ~2-5 minutes to ~20 seconds using pre-built images.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted not to put this logic in the bottom of setup-fortran.sh as I figured some people may be using it as something sourceable without side effects currently, and putting this code in there would break those semantics.

@timdawborn timdawborn marked this pull request as ready for review March 20, 2025 13:33
Copy link
Contributor

@wpbonelli wpbonelli left a comment

Choose a reason for hiding this comment

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

thanks for this. good use case. I will have to try your container suggestion.

@wpbonelli wpbonelli merged commit a6ee716 into fortran-lang:main Mar 20, 2025
162 checks passed
@timdawborn
Copy link
Contributor Author

timdawborn commented Mar 21, 2025

I'll send through either another PR or comment on the aforementioned issue in due course with how I've set this up 👍

@timdawborn timdawborn deleted the move-entry-logic-into-reusable-script branch March 21, 2025 05:59
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.

2 participants