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.
    If the tests succeed, push the images to the public repos. If the tests were triggered by
    pushing a tag to the git repo, apply floating tags to the pushed images.
  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
  - name: commands
    description: Test commands to run
    type: array
    default:
    - 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
  - name: repo-prefix
    description: The prefix (usually hostname/orgname) of the destination repo where the Snapshot components will be pushed
    default: quay.io/ramalama
  - name: skip-components
    description: A space-separated list of components that should not be pushed
    default: bats
  results:
  - name: TEST_OUTPUT
    description: Test results in JSON format
    value: $(tasks.push.results.TEST_OUTPUT)
  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_IMAGE=$(tasks.init.results.ramalama-image)
      - RAMALAMA_STACK_IMAGE=$(tasks.init.results.stack-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
    when:
    - input: $(tasks.init.results.sync)
      operator: in
      values: ["true"]
  - name: push
    params:
    - name: SNAPSHOT
      value: $(params.SNAPSHOT)
    - name: event-type
      value: $(tasks.init.results.event-type)
    - name: snapshot-type
      value: $(tasks.init.results.snapshot-type)
    - name: release-tags
      value: $(tasks.init.results.release-tags)
    - name: sync
      value: $(tasks.init.results.sync)
    - name: repo-prefix
      value: $(params.repo-prefix)
    - name: skip-components
      value: $(params.skip-components)
    taskRef:
      resolver: git
      params:
      - name: url
        value: $(params.git-url)
      - name: revision
        value: $(params.git-revision)
      - name: pathInRepo
        value: .tekton/integration/tasks/push-snapshot.yaml
    runAfter:
    - test
