name: CI

on:
  pull_request:
    
jobs:
  build:
    runs-on: macOS-latest
    steps:
    - name: Checkout source
      uses: actions/checkout@v2
    
    - name: Build for testing
      run: xcodebuild build-for-testing -sdk iphonesimulator -scheme Wikipedia -derivedDataPath DerivedData

    - name: Upload derived data
      uses: actions/upload-artifact@v2
      with:
        name: DerivedData
        path: DerivedData/Build/Products/

  test:
    needs: build
    runs-on: macOS-latest
    strategy:		
       matrix:		
         destination: ['platform=iOS Simulator,OS=13.5,name=iPhone 8', 'platform=iOS Simulator,OS=12.4,name=iPhone X', 'platform=iOS Simulator,name=iPad Pro (12.9-inch) (4th generation)']
    steps:
    - name: Checkout source
      uses: actions/checkout@v2

    - name: Download build
      uses: actions/download-artifact@v2
      with:
        name: DerivedData
        path: DerivedData/Build/Products/
  
    - name: Run tests
      run: xcodebuild test-without-building -scheme Wikipedia -derivedDataPath DerivedData -destination ${{ matrix.destination }}

    - name: Upload test output
      if: ${{ success() || failure() }} # always run even if the tests fail
      uses: actions/upload-artifact@v2
      with:
        name: TestResults
        path: DerivedData/Logs/Test/

Revert "Remove GitHub actions workflow for testing PRs"
Revert "Remove GitHub actions workflow for testing PRs"

This reverts commit 6caa39ef00478ccc2d4f4b3dc1976477ea2cd34c.
