name: test

on: [push, pull_request]

jobs:
  test-lesspass-crypto:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: "12"
      - run: |
          cd packages/lesspass-crypto
          yarn install
          yarn test

  test-lesspass-entropy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: "12"
      - run: |
          cd packages/lesspass-entropy
          yarn install
          yarn test

  test-lesspass-fingerprint:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: "12"
      - run: |
          cd packages/lesspass-fingerprint
          yarn install
          yarn test

  test-lesspass-render-password:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: "12"
      - run: |
          cd packages/lesspass-render-password
          yarn install
          yarn test

  test-lesspass-site:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: "12"
      - run: |
          cd packages/lesspass-site
          yarn install
          yarn build

  test-mobile:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: "12"
      - name: test mobile
        run: |
          cd mobile
          yarn install
          yarn test

  test-cli:
    runs-on: ubuntu-18.04
    strategy:
      max-parallel: 3
      matrix:
        python-version: [3.6, 3.7, 3.8]
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: test cli
        run: |
          cd cli
          ./test

  test-backend:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: "3.8"
      - name: test backend
        run: |
          cd containers/backend
          python -m pip install --upgrade pip
          python -m pip install -r requirements.txt
          python manage.py test

  test-containers:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - name: test containers
        run: |
          cd containers
          ./test
