actions / setup-dotnet

Set up your GitHub Actions workflow with a specific version of the .NET core sdk
MIT License
943 stars 458 forks source link

Ubuntu:latest runners are ignoring files with .metadata.json extension #392

Closed mirkoSekulic closed 1 year ago

mirkoSekulic commented 1 year ago

Description

Seems like there is a bug in the github "ubuntu:latest" actions runners. Files with extension ".metadata.json" are not present when running scripts and therefore dotnet tests are failing.

Our repo had test files that had extension ".metadata.json". Pipeline failed with exception message that files doesn't exists.

Removing "metadata" from test file names fixed the issue. That renaming workaround was implemented in this pr.

Platforms affected

Runner images affected

Image version and build link

Ubuntu:latest Here is the link to failed pipeline: https://github.com/Altinn/altinn-studio/actions/runs/4016169742/jobs/6898823480

Here is the link to failed pipeline: https://github.com/mirkoSekulic/runner-fail-test/actions/runs/4311965692

Is it regression?

No

Expected behavior

Files should be accessible by test scripts.

Actual behavior

Files are removed from repo when running scripts and not accessible from the tests

Repro steps

~~1. Go to altinn-studio repo

  1. Create a new branch from this commit

  2. Remove Skip="ubuntu-fail" from tests in DataModeling.Tests.JsonMetadataParserTests class and in DataModeling.Tests.JsonSchemaToMetamodelConverterTests . Tests are located in backend folder

  3. Run the pipelines~~

  4. Go to this repo

  5. Create a dummy pr to run the pipeline, or check the logs of the latest failed pipeline

Workarund with renaming files is done in following pr: Altinn/altinn-studio#9673

Alexey-Ayupov commented 1 year ago

Hello @mirkoSekulic, Since your project looks quite difficult we aren't sure that we have sufficient knowledge for proper debugging. Could you please provide the exact minimal repro steps?

mirkoSekulic commented 1 year ago

@Alexey-Ayupov I'll try at least. It's really strange behavior. Here are the steps how you can reproduce the issue:

  1. Create a new repo
  2. Create a testData/Model/Metadata folder in the root or repo.
  3. Add some json files in that folder with names ending with ".metadata.json"
  4. Create a dotnet test project in backend/tests folder or repo
  5. Reference root testData folder as embedded resource in csproj file. Something like:

    <ItemGroup>
    <EmbeddedResource Include="..\..\..\testdata\Model\**\*.*">
      <LinkBase>TestData\Model</LinkBase>
    </EmbeddedResource>
    </ItemGroup>
    1. Create a simple test with code that will list all embedded resource files from that assembly You can refer to following code example.
      <Your-assembly> .GetManifestResourceNames()
    2. Run dotnet build and dotnet test commands in the pipeline on ubuntu:latest runner

    You'll see that files with name ending with ".metadata.json" are not listed. But when removing "metadata" part from the file names, for example renaming to "xxx.json", they are listed.

mirkoSekulic commented 1 year ago

@Alexey-Ayupov here is the minimal repo with reproduced issue. You can check latest failed pipeline. Project have 2 embedded files with the same content. One file have extension ".json" and another ".metadata.json". You'll see that in the test only ".json" file is listed as a resource.

mikhailkoliada commented 1 year ago

@marko-zivic-93 @dmitry-shibanov transferring to you as to most relevant maintainers as setup-dotnet is used. If you need any help from us just let me know

IvanZosimov commented 1 year ago

Hi, @mirkoSekulic 👋 Sorry for the late response, we started to investigate the issue. As soon as we have any information, we will get back with it to you.

dusan-trickovic commented 1 year ago

Hello, @mirkoSekulic ! I just wanted to give you a gentle ping to see if you've come across the same issue again? If so, could you please share a more recent workflow run, as the one provided has expired in the meantime. I will take a closer look into it and see how I can help.

Thank you for your cooperation and I apologize for the late response :)

IvanZosimov commented 1 year ago

Hi, @mirkoSekulic 👋 I tried to reproduce the issue on my local machine (macOS) with .NET 7.0 preinstalled. As the result, I got the same error. It seems like files with metadata.json extension are interpreted by EmbeddedResource item group in a specific manner. So basically cause of the problem is in the peculiarities of the .NET behavior and it's not a problem of GitHub hosted runners or the setup-dotnet itself. Unfortunately, I can't help you to solve this problem, as I don't have broad experience with .NET.

Now, I'm going to close this issue, If you have any additional questions feel free to ping me.