czyzby / wesnoth-wml-linter

A GitHub Action that verifies Wesnoth WML files
6 stars 1 forks source link

`wmllint` thinks that the checked campaigns are part of mainline even when they're supposed to be add-ons #8

Closed cooljeanius closed 10 months ago

cooljeanius commented 10 months ago

In wesnoth/wesnoth@c1a074e, @Elvish-Hunter added a check to wmllint validate rank= values, as I had requested in wesnoth/wesnoth#7224. This check generally works well enough when I'm running wmllint locally, however, when run as part of this action, it will print a warning like this:

 "_main.cfg", line 10: rank for mainline campaigns should be a multiple of 5 between 0 and 299 (included)

However, the add-on in question that I'm checking isn't supposed to be a mainline campaign, but rather, it's an add-on. See: https://github.com/cooljeanius/A_Little_Adventure/actions/runs/7363399849/job/20042827417

czyzby commented 10 months ago

This is the problematic part of the check:

                # assume that UMCs are into the data/add-ons directory and mainline is into data/campaigns   
                if "add-ons" in filename:
                    if campaign_rank < 300:
                        print(errlead + "rank for add-on campaigns should be greater than or equal to 300")
                else:
                    if campaign_rank >= 300 or (campaign_rank % 5) != 0:
                        print(errlead + "rank for mainline campaigns should be a multiple of 5 between 0 and 299 (included)")  

It assumes that all UMC projects are nested under data/add-ons, so the output of the wmllint might vary depending on where the action is executed.

The thing is, moving the cloned repository is not viable within the linter script, since it's checked out by actions/checkout in most pipelines and some other actions might expect a specific path as to where it's located. @cooljeanius Could you try modifying your actions/checkout setup so that it includes a path parameter and check if the issue persists?

    - name: Checkout repository
      uses: actions/checkout@v4
      with:
        path: add-ons
Elvish-Hunter commented 10 months ago

As said by @czyzby, wmllint assumes that a campaign is an add-on if it finds add-ons in its file path, otherwise it's handled as a mainline campaign. I can modify it so that mainline campaigns must have campaigns in their path and if they don't the check will be skipped.

czyzby commented 10 months ago

@Elvish-Hunter Another option would be to add a command line parameter that determines whether the content should be treated as mainline or UMC, with a default that checks the file paths for backwards compatibility. That way you could have reproducible checks for both mainline and UMC campaigns, regardless of where they are placed.

cooljeanius commented 10 months ago

@cooljeanius Could you try modifying your actions/checkout setup so that it includes a path parameter and check if the issue persists?

    - name: Checkout repository
      uses: actions/checkout@v4
      with:
        path: add-ons

OK, this seems to have worked.

I can modify it so that mainline campaigns must have campaigns in their path and if they don't the check will be skipped.

@Elvish-Hunter Another option would be to add a command line parameter that determines whether the content should be treated as mainline or UMC, with a default that checks the file paths for backwards compatibility. That way you could have reproducible checks for both mainline and UMC campaigns, regardless of where they are placed.

Either of these ideas would be good to have as well.

czyzby commented 10 months ago

I've documented this in the README. There's not much else I can do within the action itself, so I'm going to close this issue. Note that this action already supports command line arguments, so if this ends up being added to wmllint, you'd be able to enable it with the existing action parameters:

    - name: Lint WML
      uses: czyzby/wesnoth-wml-linter@v1
      with:
        lint-flags: --umc  # Modify this parameter.

Until this is addressed in the Wesnoth repository, you can consider splitting the GitHub pipeline into separate checks if nesting the project under add-ons causes any issues with wmlscope or any other pipeline steps.