bahmutov / cypress-split-example

Split Cypress specs on GitHub Actions
https://github.com/bahmutov/cypress-split
10 stars 8 forks source link

How to use this on Azure devops pipelines #7

Open damasofc opened 1 year ago

damasofc commented 1 year ago

how can I make this to run on Azure devops?

ivan-xue-prospa commented 11 months ago

I recently managed it work for Azure DevOps, you can check my solution here.

damasofc commented 8 months ago

@ivan-xue-prospa can you share your .yml file? I'm unable to get it to run

ivan-xue-prospa commented 8 months ago

@ivan-xue-prospa can you share your .yml file? I'm unable to get it to run

I cannot share the whole YAML file, but you can check the following two tasks. - pwsh: | $index = $(System.JobPositionInPhase) - 1 echo "##vso[task.setvariable variable=index;isOutput=true]$index" name: index displayName: "Get Job Index"

- pwsh: | npx cyress run -- --env split=true --browser chrome workingDirectory: "$(Build.Repository.LocalPath)/$(repo.repoName)/${{ parameters.testFolder }}" displayName: "Execute tests" env: SPLIT: 2 SPLIT_INDEX: $(index.index)

damasofc commented 8 months ago
Screenshot 2023-10-19 at 4 35 44 PM

Thanks for the answer @ivan-xue-prospa The thing is that I'm using bash but with this config I'm getting this error: System.JobPositionInPhase - 1: syntax error: invalid arithmetic operator (error token is ".JobPositionInPhase - 1")

bahmutov commented 8 months ago

Check the index that starts with 1 https://github.com/bahmutov/cypress-split#index-starts-at-1

damasofc commented 8 months ago

Thanks so much, I was able to set it up on azure devops, my problem was that I didn't add the parallel on the Job inside the .yml so I did this:

jobs:
      - job: EndToEndTests
        displayName: End To End Test Run
        strategy:
          parallel: 3

after adding strategy and parallel it works and then I used what @bahmutov said the SPLIT_INDEX1

- task: Bash@3
    displayName: Run external tests against archive stage
    inputs:
      workingDirectory: .
      targetType: inline
      script: |
        export SPLIT="$(AGENTS)"
        export SPLIT_INDEX1="$(System.JobPositionInPhase)"