---
kind: pipeline
name: build
type: docker

workspace:
  path: "/app"

platform:
  os: linux
  arch: amd64

clone:
  git:
    image: plugins/git:next

steps:
  - name: build
    pull: always
    image: jonasfranz/flutter:2.10.1
    commands:
      - flutter packages get
      - flutter build apk

  - name: lint
    pull: always
    image: jonasfranz/flutter:2.10.1
    depends_on:
      - build
    commands:
      - flutter analyze
      - flutter format --set-exit-if-changed

  - name: test
    pull: always
    image: jonasfranz/flutter:2.10.1
    depends_on:
      - build
    commands:
      - flutter test -r expanded

---
kind: pipeline
name: metrics
type: docker

depends_on:
  - build

workspace:
  path: "/app"

platform:
  os: linux
  arch: amd64

steps:
  - name: generate_metrics
    pull: always
    image: jonasfranz/flutter:2.10.1
    commands:
      - flutter pub run dart_code_metrics:metrics analyze lib -r html
  - name: convert_to_latex
    pull: always
    image: pandoc/core:2.17
    depends_on:
      - generate_metrics
    commands:
      - pandoc -s metrics/index.html -o metrics.tex
  - name: pull_thesis
    image: docker:git
    commands:
      - git clone https://git.jonasfranz.software/KoSI/thesis.git
      - mkdir -p thesis/results/${DRONE_REPO_BRANCH}
  - name: push_metrics
    depends_on:
      - convert_to_latex
      - pull_thesis
    image: docker:git
    commands:
      - cp metrics.tex thesis/results/${DRONE_REPO_BRANCH}/
      - cd thesis
      - git status