Commit ddb21c82 authored by Jan Kiene's avatar Jan Kiene
Browse files

parametrize job over repos

parent 7d4f0b27
Loading
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -10,6 +10,9 @@ workflow:

variables:
  REPO_URL_FLOAT: "https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec"
  REPO_URL_BASOP: "https://forge.3gpp.org/rep/sa4/audio/ivas-basop"
  PROJECT_ID_FLOAT: "49"
  PROJECT_ID_BASOP: "77"

check-merged-ci-config-is-valid:
  stage: test
@@ -17,22 +20,38 @@ check-merged-ci-config-is-valid:
    - ivas-linux
  variables:
    MERGED_YAML: "merged.yaml"
    REPO_URL: $REPO_URL_FLOAT
    BASELINE_YAML: "baseline.yaml"
  parallel:
    matrix:
      - REPO:
        - ivas-codec
        - ivas-basop
  script:
    - git clone -b main --single-branch $REPO_URL code
    - cd code
    - sed -i".bak" "s/\&IVAS_CODEC_CI_REF main/\&IVAS_CODEC_CI_REF ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}/" .gitlab-ci.yml
    - set -euxo pipefail
    - if [ "$REPO" == "ivas-codec" ]; then repo_url=$REPO_URL_FLOAT; project_id=$PROJECT_ID_FLOAT; fi
    - if [ "$REPO" == "ivas-basop" ]; then repo_url=$REPO_URL_BASOP; project_id=$PROJECT_ID_BASOP; fi

    - git clone -b main --single-branch $repo_url $REPO
    - |
      jq --null-input --arg yaml "$(<$REPO/.gitlab-ci.yml)" '.content=$yaml' \
      curl --url "https://forge.3gpp.org/rep/api/v4/projects/49/ci/lint?include_merged_yaml=true" \
           --header 'Content-Type: application/json' \
           --data @-
           --output $BASELINE_YAML

    - sed -i".bak" "s/\&IVAS_CODEC_CI_REF main/\&IVAS_CODEC_CI_REF ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}/" $REPO/.gitlab-ci.yml
    - |
      jq --null-input --arg yaml "$(<.gitlab-ci.yml)" '.content=$yaml' \
      jq --null-input --arg yaml "$(<$REPO/.gitlab-ci.yml)" '.content=$yaml' \
      curl --url "https://forge.3gpp.org/rep/api/v4/projects/49/ci/lint?include_merged_yaml=true" \
           --header 'Content-Type: application/json' \
           --data @-
           --output $MERGED_YAML
    - |
      grep "\"valid\": true"
      grep "\"valid\": true" $MERGED_YAML
  artifacts:
    when: always
    access: all
    expire_in: "5 days"
    paths:
      - $MERGED_YAML
      - $BASELINE_YAML