jeudi 9 mai 2019

Gitlab CI not starting gradle tests

I have a gitlab ci script with a test stage, it's set to run the ./gradlew test task. However, it's not running them, giving me a test coverage of 19%.

When i run the ./gradlew test task from the command line locally, it runs correctly, and outputs a jacoco report with a test coverage of 90%.

My script is as follows:

image: java:8-jdk
before_script:
  - echo `pwd`
  - export GRADLE_USER_HOME=`pwd`/.gradle
  - rm -f  .gradle/caches/modules-2/modules-2.lock
  - rm -fr .gradle/caches/*/plugin-resolution/
cache:
  paths:
    - .gradle/wrapper
    - .gradle/caches
build:
  script:
    - ./gradlew build

test:
  stage: test
  script:
    - ./gradlew test
    - cat build/jacocoHtml/index.html | grep -o 'Total[^%]*%'
  artifacts:
    paths:
      - build/jacocoHtml

      #deploy test coverage
pages:
  stage: deploy
  dependencies:
    - test
  script:
    - mkdir public
    #- mkdir public/jacoco
    #- ./gradlew javadoc
    #- mkdir public/docs
    - mv build/jacocoHtml/* public
    #- mv build/docs/* public/docs
    # - mv index.html public/index.html
  artifacts:
    paths:
      - public
  only:
    - master

I am currently running the same version of gradle locally as in the gitlab ci image.

Below is my log for the test stage:

$ ./gradlew test
Downloading https://services.gradle.org/distributions/gradle-4.8-bin.zip
........................................................................

Welcome to Gradle 4.8!

Here are the highlights of this release:
 - Dependency locking
 - Maven Publish and Ivy Publish plugins improved and marked stable
 - Incremental annotation processing enhancements
 - APIs to configure tasks at creation time

For more details see https://docs.gradle.org/4.8/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

> Task :compileJava
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :processResources
> Task :classes

> Task :compileTestJava
Note: /builds/SBLUKcic/sbl-xsam-kit/src/test/java/com/sblukcic/commands/samconversion/threads/SamRecordConverterThreadTest.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :processTestResources NO-SOURCE
> Task :testClasses
> Task :test
> Task :jacocoTestReport

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 41s
5 actionable tasks: 5 executed
$ cat build/jacocoHtml/index.html | grep -o 'Total[^%]*%'
Total</td><td class="bar">4,303 of 5,326</td><td class="ctr2">19%
Creating cache default...
.gradle/wrapper: found 669 matching files          
.gradle/caches: found 2251 matching files          
Uploading cache.zip to https://storage.googleapis.com/gitlab-com-runners-cache/project/12027803/default 
Created cache
Uploading artifacts...
build/jacocoHtml: found 300 matching files         
Uploading artifacts to coordinator... ok            id=209651109 responseStatus=201 Created token=ptppyj49
Job succeeded

When I run the same task locally, I get this log:

sam@equipment:~/IdeaProjects/SBL Xsam Kit$ ./gradlew test
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Task :compileJava
Note: /home/sam/IdeaProjects/SBL Xsam Kit/src/main/java/com/sblukcic/cli/stream/StreamOptionFactory.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :compileTestJava
Note: /home/sam/IdeaProjects/SBL Xsam Kit/src/test/java/com/sblukcic/commands/samconversion/threads/SamRecordConverterThreadTest.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :test
Running test: Test givenValidStreamModifierCommands_checkListCreatedCorrectly()(com.sblukcic.cli.stream.options.StreamModifierOptionsTest)
Running test: Test 
[REDACTED TESTS, ITS TOO LONG!!!]

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 19s
5 actionable tasks: 4 executed, 1 up-to-date

Finally, my test task looks like this:

test{

    outputs.upToDateWhen { false }

    //useTestNG()
    useJUnitPlatform()

    maxHeapSize = '1G'

    beforeTest { descriptor ->
        logger.lifecycle("Running test: $descriptor")
    }

    failFast = true

    finalizedBy jacocoTestReport
}

I'm using JUnit5 for my tests.

Any ideas where it may be going wrong?

Thanks in advance,

Sam

Aucun commentaire:

Enregistrer un commentaire