scilus / nf-scil

SCIL Nextflow Toolbox
GNU General Public License v3.0
1 stars 16 forks source link

[WIP] Migration from pytest to nf-test. #120

Closed gagnonanthony closed 5 months ago

gagnonanthony commented 5 months ago

This is the first attempt to migrate a module from the pytest framework to nf-test. Here is a list of changes made to make it work:

Configs (@AlexVCaron feel free to make changes to how I did things, it sure isn't perfect!):

Steps to convert pytest to nf-test (@ThoumyreStanislas I'll make it cleaner so you can add it to the workflow doc soon.):

  1. Create an environment.yml file within the module's folder. The conversion crashes if this file isn't available.
  2. Run nf-core modules create --migrate-pytest <tool/subtool> and fill out the prompts.
  3. Replace the input in the new main.nf.test file with the one in your previous test file. Those inputs are positional, so it is mandatory to keep the structure input[0] = file(....
  4. To generate the snapshot, run nf-core modules --git-remote https://github.com/scilus/nf-scil.git test segmentation/fastseg. In the latest nf-core, using --git-remote solves the previous issue of the hardcoded nf-core directory structure.

114 #116 #117

gagnonanthony commented 5 months ago

Thanks @AlexVCaron ! Yes, the tests passed locally. I think once we figure out the actions/etc., the switch between pytest and nf-test will be fairly easy.

AlexVCaron commented 5 months ago

Thanks @AlexVCaron ! Yes, the tests passed locally. I think once we figure out the actions/etc., the switch between pytest and nf-test will be fairly easy.

I'm super happy ! I'll give a look on the action framework, make sure everything is run correctly, with the right workflow versions. There may be something to modify in the checks.yml workflow, it think the nf-test modules are not fetched in the failing-modules step.

gagnonanthony commented 5 months ago

Yeah, that's exactly what I was looking at! I'll go through the nf-core/modules repo to see what they are doing over there.

Update: I've added the fetching of nf-test modules and a separate workflow to test them (to avoid using pytest when it is an nf-test module). That way, it shouldn't mess up other modules that are still using pytest. Two minor issues: nf-test action isn't set up in the workflow, not sure why and the module's linting requires the environment-schema.json which I added, but can't be used until the PR is merged. @AlexVCaron, I'm not sure the environment.yml file is really necessary in our case since we do not really use environments, should we just remove it?

AlexVCaron commented 5 months ago

You're a rockstar :metal: I'll add the schema for the environment file to the main, I'll keep you updated. Also, I opened an issues for the setup action for nf-test, waiting on it, it'll fix the current test step failure !

Waiting on nf-core/setup-nf-test#6

AlexVCaron commented 5 months ago

I trickled a bit in the action. Can you try AlexVCaron/setup-nf-test@main instead of the one from nf-core, see if it fixes our problem ?

gagnonanthony commented 5 months ago

Done, seems like it returned a different error message this time: Error: File not found: '/home/runner/_work/_actions/AlexVCaron/setup-nf-test/main/dist/index.js'

AlexVCaron commented 5 months ago

Allright. The setup-nf-test action is working correctly. The environment-schema file is also available on the main. There seems to still be a problem with the testing. It doesn't look like the tests are run inside the docker container, even with the PROFILE=docker supplied to nf-test. Is there a missing configuration ?