image: oarteam/batsim_ci:latest

variables:
  GIT_SUBMODULE_STRATEGY: none

stages:
  - unique

unique:
  stage: unique
  script:
    # build and run stuff
    - nix build .#ci-batsim-internal-test -o result-int
    - cp -rL --no-preserve=all result-int ./internal_test_report
    - cat ./internal_test_report/test_report.json

    - nix build .#ci-batsim-edc-test-from-internal-gcda -o result-ext
    - cp -rL --no-preserve=all result-ext ./external_test_report

    - nix build .#ci-batsim-test-coverage-report -o result-cov
    - cp -rL --no-preserve=all result-cov ./coverage_report
    - cat result-cov/file-summary.txt

    # fail if any test have failed
    - if [[ "$(cat ./result-ext/pytest_returncode)" -ne 0 ]] ; then echo "external tests failed (pytest returned non-zero), aborting" ; exit 1 ; fi
  coverage: '/^TOTAL.*\s+(\d+\%)$/'
  artifacts:
    when: always
    expire_in: 8 hours
    paths:
      - ./internal_test_report
      - ./external_test_report
      - ./coverage_report
