# We're following this recipe
#   Advanced Use
#   https://salsa.debian.org/salsa-ci-team/pipeline#advanced-use

include:
  - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/recipes/debian.yml


variables:
# See:
#   https://salsa.debian.org/salsa-ci-team/pipeline#skipping-a-job
#   Skipping a job
  # Very slow and resource-intensive.   Do only the test(s)
  # that are particularly likely to fail *only* in autopkgtest.
  SALSA_CI_AUTOPKGTEST_ARGS: --test-name t2u-email
  # We build no arch-specific packages; thse are just wasted faff
  SALSA_CI_DISABLE_BUILD_PACKAGE_ANY: 1
  SALSA_CI_DISABLE_BUILD_PACKAGE_I386: 1
  SALSA_CI_DISABLE_CROSSBUILD_ARM64: 1
  # We don't compile executables, so we don't care about hardening flags.
  SALSA_CI_DISABLE_BLHC: 1
  # Our rules file doesn't do anything different for all vs any
  # and we just rely on debhelper.  Rebuilding the package again isn't useful.
  SALSA_CI_DISABLE_BUILD_PACKAGE_ALL: 1
  # Doesn't work with unfinalised changelogs
  SALSA_CI_DISABLE_REPROTEST: 1
  # Doesn't like git-debpush having a Replaces without a Breaks.
  # See <https://bugs.debian.org/592610#64>.
  SALSA_CI_DISABLE_MISSING_BREAKS: 1
  SALSA_CI_LINTIAN_SUPPRESS_TAGS: changelog-empty-entry
  # t2usm project
  T2USM_EXECUTABLE_URL: https://salsa.debian.org/dgit-team/tag2upload-service-manager/-/jobs/artifacts/main/raw/artifacts/tag2upload-service-manager?job=build
  # The Salsa CI pipleine likes to test with usntable by default.
  # But that means that breakage from other packages, which are in sid
  # but not migrating to testing because of our own autopkgtests,
  # end up breaking our own CI!  We don't want this uncontrolled input.
  DEFAULT_RELEASE: testing

autopkgtest:
  # See `DEFAULT_RELEASE` above.  For reasons I don't understand,
  # DEFAULT_RELEASE is not effective and we must replace the default job.
  extends: .test-autopkgtest
  variables:
    RELEASE: "testing"

.dgit-test-suite:
  stage: test
  image: debian:testing
  dependencies:
    - build
  after_script:
    - tests/maybe-tail-log-of-one-failing-test
  artifacts:
    name: logs
    when: always
    expire_in: 1 week
    paths:
      - tests/tmp/*

dgit-test-suite:
  extends: .dgit-test-suite
  script:
    - apt-get -y update
    - tests/gitlab-ci-run-all

dgit-test-suite-trixie:
  extends: dgit-test-suite
  image: debian:trixie
  variables:
    DGIT_TEST_CURRENT_SUITE: trixie

dgit-test-suite-bookworm:
  extends: dgit-test-suite
  image: debian:bookworm
  variables:
    DGIT_TEST_CURRENT_SUITE: bookworm

dgit-test-suite-bullseye:
  extends: dgit-test-suite
  image: debian:bullseye
  variables:
    DGIT_TEST_CURRENT_SUITE: bullseye

t2u-integration:
  extends: .dgit-test-suite
  stage: test
  script:
    - apt-get -y update
    - apt-get -y install curl
    - curl -L "$T2USM_EXECUTABLE_URL" >tag2upload-service-manager
    - chmod +x tag2upload-service-manager
    - export DGIT_TEST_T2USM_PROGRAM=$(pwd)/tag2upload-service-manager
    - export TESTSCRIPTS=$(tests/list-t2u-integration-tests)
    - tests/gitlab-ci-run-all

# Job corresponding to the release of Debian used by our live deployment.
t2u-integration-trixie:
  extends: t2u-integration
  image: debian:trixie
  # Don't set DGIT_TEST_CURRENT_SUITE just in case that might suppress the
  # very test case(s) we care about.

blocking-todos:
  stage: test
  needs: []
  script:
    # We reject three or more X's in a row, in a word, in either case.
    # This is for TODOs that we want to fix before merging.
    #
    # We do it here, rather than in tests/, because we may want branches
    # to have blocking todos in intermediate states, but we sometimes
    # run the test suite on every commit on a branch.
    #
    - apt-get -y update
    - apt-get -y install git
    - set +e; git grep -P -i '\bx+xx\b'; test $? = 1

signed-off-by:
  stage: test
  needs: []
  allow_failure: true
  script:
    - apt-get -y update
    - apt-get -y install git
    - tests/gitlab-ci-check-sob
