Code Quality job running in parallel with build stage

Hi,

We’re using Gitlab.com, and I’m just trying out the Code Quality reports. I’m using this CI build:

default:
  image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/maven:3.8.4-jdk-8-slim
  cache:
    paths:
      - .m2/repository
      - target

variables:
  # This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
  # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
  MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
  MAVEN_CLI_OPTS: "-s maven-settings.xml --batch-mode --errors --fail-at-end --show-version"

stages: # List of stages for jobs, and their order of execution
  - build
  - test

include:
  - template: Code-Quality.gitlab-ci.yml

#Run on any non-main branch
build:
  stage: build
  script:
    - mvn $MAVEN_CLI_OPTS verify -s maven-settings.xml

  artifacts:
    when: always
    reports:
      junit:
        - target/surefire-reports/TEST-*.xml
        - target/failsafe-reports/TEST-*.xml
  except:
    variables:
      - $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

My understanding is that the ‘build’ stage should run first, and then the ‘test’ stage (with the Code Quality job). What I’m seeing is that the build and Code Quality jobs start at the same time, with both running through and suceeding, and I think being correct. Its just not what I expected in terms of ordering. Is this the expected behaviour (jobs in both stages running in parallel)?
I guess mostly I wanted to check its not causing an issue that I haven’t noticed?

Thanks for any help or advice or experience you can provide,

Matt

Hi @matt-harr
Code Quality scans your source code, it doesn’t need for the app to be compiled.

Reason why it runs together is that code quality job has needs: [], you can look it up here

And here is reference for needs.

Ah, that makes sense, thanks. Yes, it just needs the source code to work. I’d had a look at the included file, but missed the needs keyword.

Thanks for your help,

Matt