stages:
    - build
    - test
    - qa
    - deploy

# Compile the code, must succeed before we start testing.
build:
    stage: build
    script: "mvn -B clean compile"

# Run the quick test suite (Unit tests mostly)
quicktests:
    stage: test
    script: "mvn -B test --fail-at-end"
    artifacts:
      expire_in: 1 week
      paths:
      - "**/target/jacoco.exec"

# Run the integration test suite (Unit tests which don't use mocks and commonly exclude mock usages)
integration-tests:
    stage: test
    script: "mvn -B verify --fail-at-end -Dtest=excludeUnitTests -DfailIfNoTests=false"
    artifacts:
      expire_in: 1 week
      paths:
      - "**/target/jacoco-it.exec"

# Run a sonar analysis.
sonar:
    stage: qa
    script: "mvn -B compile test-compile sonar:sonar -Dsonar.host.url=https://sonarqube.johnnei.org -Dsonar.branch=$CI_BUILD_REF_NAME"
    dependencies:
      - quicktests
      - integration-tests

deploy to maven central:
    stage: deploy
    script: "mvn -B -Prelease clean deploy -DskipTests -Dgpg.passphrase=$GPG_PASS"
    environment: MavenCentral
    artifacts:
      paths:
      - "**/target/*.jar"
      - "**/target/*.jar.asc"
    when: manual
    only:
      - tags

stages:
    - build
    - test
    - qa
    - deploy

# Compile the code, must succeed before we start testing.
build:
    stage: build
    script: "mvn -B clean compile"

# Run the quick test suite (Unit tests mostly)
quicktests:
    stage: test
    script: "mvn -B test --fail-at-end"
    artifacts:
      expire_in: 1 week
      paths:
      - "**/target/jacoco.exec"

# Run the integration test suite (Unit tests which don't use mocks and commonly exclude mock usages)
integration-tests:
    stage: test
    script: "mvn -B verify --fail-at-end -Dtest=excludeUnitTests -DfailIfNoTests=false"
    artifacts:
      expire_in: 1 week
      paths:
      - "**/target/*.log"
      - "**/target/jacoco-it.exec"

# Run a sonar analysis.
sonar:
    stage: qa
    script: "mvn -B compile test-compile sonar:sonar -Dsonar.host.url=https://sonarqube.johnnei.org -Dsonar.branch=$CI_BUILD_REF_NAME"
    dependencies:
      - quicktests
      - integration-tests

deploy to maven central:
    stage: deploy
    script: "mvn -B -Prelease clean deploy -DskipTests -Dgpg.passphrase=$GPG_PASS"
    environment: MavenCentral
    artifacts:
      paths:
      - "**/target/*.jar"
      - "**/target/*.jar.asc"
    when: manual
    only:
      - tags

Store utp log in artifact.
JBT-57: Store utp log in artifact.
