Open zxiiro opened 4 months ago
This change depends on #174 being merged as it requires to fix to the input parameter to choose an alternative pom.xml file.
Looks like it also needs a GLOBAL_SETTINGS variable defined.
echo '' > global-settings.xml
It doesn't need to have any real data. Something like this should be sufficient:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
Alright this is ready to go but the unit test won't pass until the GLOBAL_SETTINGS variable is set as mentioned in my previous comment. Unfortunately I don't have the permissions to add it myself so someone in @lfit/release-engineering will have to add it and retest before this can be merged.
To make the code cleaner it proposed #176 and removed the unused parameters that I was putting dummy values in for.
This looks ok to me, but the job doesn't appear to be picking up the newly created GLOBAL_SETTINGS var that I added per your earlier statements.
It should be pulling from the repo's variables based on this code here. Calling {{ vars.GLOBAL_SETTINGS }}
.
Is there any security configuration in this repo preventing forked repos from fetching variables from the upstream repo?
Oh I was reading the docs for repo variable configuration and it says this:
Anyone with collaborator access to this repository can use these secrets and variables for actions. They are not passed to workflows that are triggered by a pull request from a fork.
ref: https://github.com/lfit/releng-reusable-workflows/settings/variables/actions
Yep, confirmed looks like variables definitely are not passed to forked repos. :(
https://github.com/orgs/community/discussions/44322
I'll see if we can code around this somehow.
Success! I had to make a small change to allow an input MVN_GLOBAL_SETTINGS
in order to allow the unit test to work from forked repos by hardcoding a minimal global settings file. The current behaviour continues to be the default behaviour even with this change so real jobs will still get ${{ var.GLOBAL_SETTINGS }}
as expected.
Since var.GLOBAL_SETTINGS
isn't passed down to forked repos though this means this is still a problem for any projects that are using GitHub to accept contributions rather than Gerrit. Which makes me think likely all of our maven jobs likely don't work projects using GitHub directly that want to accept contributions from forked repos.
This change creates a minimal pom.xml for unit testing of Maven jobs and creates a test job for the Maven Verify workflow. The intent here is to create a small unit test that can quickly validate Maven workflows and catch potential issues that maybe missed by a linter.