2

I have a very basic python app that I’m testing with to get the CI working. I have a gitlab-ci.yml file that contains the following which runs on a windows gitlab runner.

test:
  script:
    - conda env create -f environment.yml
    - activate scraper-worker
    - python -m pytest

It creates the environment ok, but as soon as the the environment is activated it just prints out: Job succeeded, and it never runs pytest, it just finishes.

If I comment out the activate scraper-worker line then pytest will run, but it fails obviously because the environment isn’t active. Any idea what I’ve got wrong here?

Just as an FYI. I have tried doing the environment setup and activation in a before_script, but again, same thing. Env gets built and activated but the test never runs.

7
  • Have you started a job session , to run this tests and scripts? Commented Jan 10, 2018 at 3:08
  • Hey Abe. Can you clarify? It does actually run on the gitlab runner, I can go to the runner and watch it build the environment, but as soon as it's activated it just finishes and never gets to any step beyond that. Commented Jan 10, 2018 at 3:12
  • As the Official Docs specify, every step of your buildings must be inside a job. When your root of session is test, this doesnt defines a well formated job. So, try to move this script session to a new session (such as job_1, that have a flag stage:test) and run it again. Commented Jan 10, 2018 at 3:18
  • Gotcha. Unfortunately, same thing. It's like when the environment is activated, normally it would put you inside of the environment for the test to be ran, but that doesn't seem to be happening within the CI process. It does work under a Linux runner, but not under a windows one for some reason. Commented Jan 10, 2018 at 3:24
  • Think I got it, will answer my own question. Thanks for the help Abe. Commented Jan 10, 2018 at 3:40

2 Answers 2

2

Turns out that I had to add Shell = "powershell" to my gitlab runner config for this to work.

Sign up to request clarification or add additional context in comments.

4 Comments

where did you do this?
I don't have access to the particular setup anymore, but it was in the actual gitlab runner configuration on the windows gitlab runner. Can't remember the actual directory on the windows server, but if you can locate that then you can add it into the runner configuration there.
Ah, it's the config.toml file that's created after you register the runner. (It's in the same folder as where the gitlab-runner is stored.
I have my gitlab-runner in a Windows Server 2019 Datacenter AWS EC2 instance. Already configured to have this setting but the same problem exists.
0

I still have the same issue of the Python environment not being activated even after configuring the gitlab-runner shell attribute.

I did this instead:

default:
  before_script:
    - conda env list
    - $env:PATH += ";C:\Tools\miniconda\envs\myenv"

the conda env list is for debugging purposes only.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.