# variables que puedo usar? https://woodpecker-ci.org/docs/0.15/usage/environment#built-in-environment-variables

steps:
  style:
    image: python:3.9
    commands:
      - pip3 install flake8
      - flake8

  tests:
    image: python:3.9
    environment:
      - DB_CACHE=/tmp
      - DB_NAME=trytontest
      - TRYTOND_DATABASE_URI=postgresql://tryton:tryton@postgres:5432/
    commands:
      - pip3 install psycopg2 proteus
      - python3 setup.py install
      - python3 -m unittest

  notify-success:
    image: gitea.onecluster.org/alnus/plugins/matrix:latest
    settings:
      home_server: https://matrix.org
      roomid: "!oxZmsJwfvciTuLYIwg:matrix.org"
      username:
        from_secret: matrix_user
      password:
        from_secret: matrix_password
    template: >
      PikPukPak..
      <p>${CI_COMMIT_AUTHOR}: <a href="${CI_BUILD_LINK}">Task ${CI_BUILD_NUMBER}</a> <font color="green"><b>TODO BIEN EN ${CI_REPO}</b></font></p>
      <pre><a href="${CI_COMMIT_LINK}">${CI_COMMIT_MESSAGE}</a></pre>
    when:
      status: [success]

  notify-failure:
    image: plugins/matrix
    settings:
      home_server: https://matrix.org
      roomid: "!oxZmsJwfvciTuLYIwg:matrix.org"
      username:
        from_secret: matrix_user
      password:
        from_secret: matrix_password
    template: >
      PikPukPak..
      <p>${CI_COMMIT_AUTHOR}: <a href="${CI_BUILD_LINK}">Task ${CI_BUILD_NUMBER}</a> <font color="red"><b>!!!TODO MAL EN ${CI_REPO} </b></font></p>
      <pre><a href="${CI_COMMIT_LINK}">${CI_COMMIT_MESSAGE}</a></pre>
    when:
      status: [failure]

services:
  postgres:
    image: postgres:12
    environment:
      - POSTGRES_USER=tryton
      - POSTGRES_PASSWORD=tryton
      - POSTGRES_DB=demo