kind: pipeline
name: sonarcube
type: docker

clone:
    retries: 10

steps:
  - name: code-analysis
    pull: if-not-exists
    image: sonarsource/sonar-scanner-cli
    commands:
      - sonar-scanner -Dsonar.host.url=$SONAR_HOST -Dsonar.login=$SONAR_TOKEN -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.projectVersion=$DRONE_REPO_BRANCH-$DRONE_COMMIT-$DRONE_COMMIT_AUTHOR -Dsonar.qualitygate.wait=true
    environment:
      SONAR_HOST:
        from_secret: sonar_host
      SONAR_TOKEN:
        from_secret: sonar_token
      SONAR_PROJECT_KEY:
        from_secret: sonar_project_key

trigger:
  event:
    - push
    - pull_request
---
kind: pipeline
name: tests
type: docker

trigger:
  event:
    - push
    - pull_request

steps:
  - name: unity-build-tests
    image: docker.io/library/unity-test-runner:0.1
    commands:
      - /opt/unity/editors/2021.3.19f1/Editor/Unity -runTests -batchmode -nographics -projectPath . -testResults results_editmode.xml -testPlatform EditMode || true
      - /opt/unity/editors/2021.3.19f1/Editor/Unity -runTests -batchmode -nographics -projectPath . -testResults results_playmode.xml -testPlatform PlayMode || true
      
  - name: tests-parser
    image: docker.io/library/unity-test-parser:0.1
    commands:
      - python /app/unity_test_parser.py results_editmode.xml results_playmode.xml 
