.certification:R1:turris-omnia:
  stage: certification-R1-turris-omnia
  extends: .certification-generic-R1
  variables:
    RUN_ON_DEVICE: "turris-omnia"
  before_script:
    - tools/deploy_firmware.py --device turris-omnia --target-name "$RUN_ON_DEVICE" --image "$TURRIS_OMNIA_FULLIMAGE" --whm --configuration ci/configuration/certification/R1/whm/turris-omnia.sh
    - tools/deploy_ipk.sh --certification-mode $RUN_ON_DEVICE build/$RUN_ON_DEVICE/prplmesh.ipk
  needs:
    - job: build-for-turris-omnia
  tags:
    - certs-tests
    - turris-omnia

.certification:R1:haze:
  stage: certification-R1-haze
  extends: .certification-generic-R1
  variables:
    RUN_ON_DEVICE: "haze"
  before_script:
    - tools/deploy_firmware.py --device haze --target-name "$RUN_ON_DEVICE" --image "$HAZE_FULLIMAGE" --whm --configuration ci/configuration/certification/R1/whm/haze.sh
    - tools/deploy_ipk.sh --certification-mode $RUN_ON_DEVICE build/$RUN_ON_DEVICE/prplmesh.ipk
  needs:
    - job: build-for-haze
  tags:
    - certs-tests
    - haze

.certification:R4:turris-omnia:
  stage: certification-R4-turris-omnia
  extends: .certification-generic-R4
  variables:
    RUN_ON_DEVICE: "turris-omnia"
  before_script:
    - tools/deploy_firmware.py --device turris-omnia --target-name "$RUN_ON_DEVICE" --image "$TURRIS_OMNIA_FULLIMAGE" --whm --configuration ci/configuration/certification/R4/whm/turris-omnia.sh
    - tools/deploy_ipk.sh --certification-mode $RUN_ON_DEVICE build/$RUN_ON_DEVICE/prplmesh.ipk
  needs:
    - job: build-for-turris-omnia
  tags:
    - certs-tests-R4
    - turris-omnia

.certification:R4:haze:
  stage: certification-R4-haze
  extends: .certification-generic-R4
  variables:
    RUN_ON_DEVICE: "haze"
  before_script:
    - tools/deploy_firmware.py --device haze --target-name "$RUN_ON_DEVICE" --image "$HAZE_FULLIMAGE" --whm --configuration ci/configuration/certification/R4/whm/haze.sh
    - tools/deploy_ipk.sh --certification-mode $RUN_ON_DEVICE build/$RUN_ON_DEVICE/prplmesh.ipk
  needs:
    - job: build-for-haze
  tags:
    - certs-tests-R4
    - haze

.certification:R4:freedom:
  stage: certification-R4-freedom
  extends: .certification-generic-R4
  variables:
    RUN_ON_DEVICE: "freedom"
  before_script:
    - tools/deploy_firmware.py --device freedom --target-name "$RUN_ON_DEVICE" --image "$FREEDOM_FULLIMAGE" --whm --configuration ci/configuration/certification/R4/whm/freedom.sh
    - tools/deploy_ipk.sh --certification-mode $RUN_ON_DEVICE build/$RUN_ON_DEVICE/prplmesh.ipk
    - echo "Setting no on-boot scan for prplMesh"
    - ssh freedom 'sed -ri "s/on_boot_scan=.*/on_boot_scan=0/g" /opt/prplmesh/config/beerocks_agent.conf'
    - echo "Setting no profile disallow for prplMesh"
    - ssh freedom 'sed -ri "s/profile_x_disallow_override_unsupported_configuration=.*/profile_x_disallow_override_unsupported_configuration=1/g" /opt/prplmesh/config/beerocks_agent.conf'
  needs:
    - job: build-for-freedom
  tags:
    - certs-tests-R4
    - freedom

.certification:R4:freedom_on_boot_24:
  extends: .certification:R4:freedom
  before_script:
    - !reference [.certification:R4:freedom, before_script]
    - echo "Setting 2.4GHz on-boot scan for prplMesh"
    - ssh freedom 'sed -ri "s/on_boot_scan=.*/on_boot_scan=2/g" /opt/prplmesh/config/beerocks_agent.conf'

.certification:R4:freedom_on_boot_5:
  extends: .certification:R4:freedom
  before_script:
    - !reference [.certification:R4:freedom, before_script]
    - echo "Setting 5GHz on-boot scan for prplMesh"
    - ssh freedom 'sed -ri "s/on_boot_scan=.*/on_boot_scan=1/g" /opt/prplmesh/config/beerocks_agent.conf'

.certification:R4:freedom_downstream_R1_agent:
  extends: .certification:R4:freedom
  before_script:
    - !reference [.certification:R4:freedom, before_script]
    - echo "Setting Multi-AP profile 2 disallow for prplMesh (downstream R1 agent)"
    - ssh freedom 'sed -ri "s/profile_x_disallow_override_unsupported_configuration=.*/profile_x_disallow_override_unsupported_configuration=2/g" /opt/prplmesh/config/beerocks_agent.conf'

include:
  - local: "ci/certification/R1/turris-omnia.yml"
  - local: "ci/certification/R1/haze.yml"
  - local: "ci/certification/R4/turris-omnia.yml"
  - local: "ci/certification/R4/haze.yml"
  - local: "ci/certification/R4/freedom.yml"

# Merge train tests
##################

merge-train:R1:haze:MAP-4.2.1:
  extends: .certification:R1:haze
  rules:
    - if: '$CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"'
      when: on_success
  retry: 2
