fvalverd/AutoApi

View on GitHub
.github/workflows/tests.yaml

Summary

Maintainability
Test Coverage
name: tests

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  tests:
    strategy:
      matrix:
        # platform: [ubuntu-latest, macos-latest, windows-latest]
        platform: [ubuntu-latest]
        python-version: [2.7, 3.6, 3.7, 3.8]
        mongo-db-version: [3.6, 4.0, 4.2]
    runs-on: ${{ matrix.platform }}
    env:
      MONGO_HOST: "127.0.0.1"
      MONGO_PORT: "27018"
      MONGO_PORT_AUTH: "27019"
      MONGO_ADMIN: "admin"
      MONGO_ADMIN_PASS: "pass"
    steps:
      - uses: actions/checkout@v2
      - name: Install Python ${{ matrix.python-version }}
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python-version }}
      - name: Upgrade Python tools & install Python dependencies
        run: |
          python -m pip install -U -r requirements-tools.txt
          python -m pip install -r requirements.txt -r requirements-dev.txt
      - name: Start MongoDB without authentication
        run: docker run -d -p ${{ env.MONGO_PORT }}:27017 mongo:${{ matrix.mongo-db-version }} mongod --bind_ip_all
      - name: Start MongoDB with authentication
        run: docker run -d -p ${{ env.MONGO_PORT_AUTH }}:27017 -e MONGO_INITDB_ROOT_USERNAME=${{ env.MONGO_ADMIN }} -e MONGO_INITDB_ROOT_PASSWORD=${{ env.MONGO_ADMIN_PASS }} mongo:${{ matrix.mongo-db-version }} mongod --auth --bind_ip_all
        if: ${{ matrix.platform != 'windows-latest' }}
      # - name: Start MongoDB with authentication (only windows)
      #   run: |
      #     export MONGO_AUTH_DIR=$(mktemp -d)
      #     docker run --name temporary_mongodb -d -v $MONGO_AUTH_DIR:C:\db mongo:latest mongod --bind_ip_all --dbpath=C:\db
      #     docker exec mongo --eval "db.createUser({user:'${{ env.MONGO_ADMIN }}', pwd:'${{ env.MONGO_ADMIN_PASS }}', roles:[{role:'root', db:'admin'}]})"
      #     docker kill temporary_mongodb
      #     docker run -d -p ${{ env.MONGO_PORT_AUTH }}:27017 -v $MONGO_AUTH_DIR:C:\db mongo:latest mongod --auth --bind_ip_all --dbpath=C:\db
      #   if: ${{ matrix.platform == 'windows-latest' }}
      - name: Set MongoDB root user as Auto-Api admin
        run: python -m auto_api update-admin --port ${{ env.MONGO_PORT_AUTH }}
      - name: Run unit, integration and functional tests
        run: python -m pytest -v
      - name: Coveralls
        env:
          COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
          COVERALLS_PARALLEL: true
        run: coveralls
  finish:
    needs: tests
    runs-on: ubuntu-latest
    steps:
    - name: Coveralls Finished
      run: curl --silent --insecure https://coveralls.io/webhook?repo_token=${{ secrets.COVERALLS_REPO_TOKEN }} -d "payload[build_num]=${GITHUB_SHA}&payload[status]=done"