kind: Pipeline
apiVersion: tekton.dev/v1
metadata:
  name: bats-integration
spec:
  description: |
    Test the newly-built ramalama image and layered images on all supported architectures.
  params:
  - name: SNAPSHOT
    description: >-
      Information about the components included in the current snapshot under test.
  - name: platforms
    description: VM platforms on which to run test commands
    type: array
    default:
    - linux-c8xlarge/amd64
    - linux-c8xlarge/arm64
    - linux/ppc64le
    - linux/s390x
    - linux-g64xlarge/amd64
  - name: commands
    description: Test commands to run
    type: array
    default:
    - bash -cx "bin/ramalama info && make bats"
  - name: git-url
    description: URL of the Git repository containing pipeline and task definitions
    default: https://github.com/containers/ramalama.git
  - name: git-revision
    description: Revision of the Git repository containing pipeline and task definitions
    default: main
  tasks:
  - name: init
    params:
    - name: SNAPSHOT
      value: $(params.SNAPSHOT)
    taskRef:
      resolver: git
      params:
      - name: url
        value: $(params.git-url)
      - name: revision
        value: $(params.git-revision)
      - name: pathInRepo
        value: .tekton/integration/tasks/init-snapshot.yaml
  - name: test
    matrix:
      params:
      - name: PLATFORM
        value:
        - $(params.platforms)
      - name: cmd
        value:
        - $(params.commands)
    params:
    - name: image
      value: $(tasks.init.results.bats-image)
    - name: envs
      value:
      - RAMALAMA_DEFAULT_IMAGE="$(tasks.init.results.ramalama-image)"
      - RAMALAMA_DEFAULT_RAG_IMAGE="$(tasks.init.results.ramalama-rag-image)"
      - RAMALAMA_STACK_IMAGE=$(tasks.init.results.stack-image)
      - >-
        RAMALAMA_IMAGES='{"CUDA_VISIBLE_DEVICES": "$(tasks.init.results.cuda-image)"}'
      - >-
        RAMALAMA_RAG_IMAGES='{"CUDA_VISIBLE_DEVICES": "$(tasks.init.results.cuda-rag-image)"}'
    taskRef:
      resolver: git
      params:
      - name: url
        value: $(params.git-url)
      - name: revision
        value: $(params.git-revision)
      - name: pathInRepo
        value: .tekton/integration/tasks/test-vm-cmd.yaml
