name: Build and Test Kive
on: push
jobs:
  build:
    runs-on: ubuntu-18.04
    services:
      # Label used to access the service container
      postgres:
        # Docker Hub image
        image: postgres
        # Provide the password for postgres
        env:
          POSTGRES_PASSWORD: postgres
        ports:
          # Opens tcp port on the host and service container
          - 5432:5432
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    env:
      KIVE_DB_USER: postgres
      KIVE_STATIC_ROOT: /tmp/kive_test_static_root
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.6
      - name: Install apt packages
        run: sudo apt-get install -y -q dh-autoreconf build-essential libarchive-dev squashfs-tools
      - name: Install node
        run: |
          nvm install 12.13.1
          nvm use 12.13.1

      - name: Install Kive's Python dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install -r requirements-test.txt
      - run: npm install

      - name: Install Singularity
        run: |
          sudo apt-get install -qq python dh-autoreconf build-essential libarchive-dev squashfs-tools
          touch real_file
          git clone https://github.com/singularityware/singularity.git
          cd singularity
          git checkout -q tags/2.5.2
          ./autogen.sh
          ./configure --prefix=/usr/local
          make
          sudo make install
          cd ..
          rm -rf singularity
      - run: npm run test:travis
      - name: Test with pytest
        run: |
          cd kive
          python manage.py collectstatic --no-input
          coverage run -m pytest --flake8 --ds kive.settings_test_pg
      - name: Test API with pytest
        run: |
          cd api
          coverage run --source=kiveapi -m pytest

      - name: Report code coverage
        run: |
          python -m pip install codecov
          codecov

Convert Travis config to GitHub Actions.
Convert Travis config to GitHub Actions.
