on:
  pull_request:

jobs:
  build:
    name: Build
    strategy:
      matrix:
        platform: [windows-latest]
        go-version: [1.13.x]
        node-version: [10.x]
        python-version: [3.7]
        dotnet: ['3.1.100']
    runs-on: ${{ matrix.platform }}
    env:
      GOPATH: ${{ github.workspace }}
    steps:
    - name: Install DotNet ${{ matrix.dotnet }}
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: ${{ matrix.dotnet }}
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: Set up Go ${{ matrix.go-version }}
      uses: actions/setup-go@v1
      with:
        go-version: ${{ matrix.go-version }}
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install Python Deps
      run: |
        pip3 install pyenv-win
        pip3 install pipenv
    - name: Set Build Env Vars
      shell: bash
      run: |
        echo "::set-env name=PULUMI_TEST_OWNER::moolumi"
        echo "::set-env name=PULUMI_LOCAL_NUGET::D:\\Pulumi\\nuget"
        echo "::set-env name=PULUMI_ACCESS_TOKEN::${{ secrets.PULUMI_ACCESS_TOKEN }}"
        echo "::set-env name=PULUMI_ACCESS_TOKEN::${{ secrets.PULUMI_ACCESS_TOKEN }}"
        echo "::add-path::D:\\Pulumi\\bin"
    - name: Set AWS Env Vars
      uses: allenevans/set-env@v1.0.0
      with:
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    - name: Check out code into the Go module directory
      uses: actions/checkout@v2
      with:
        path: ./src/github.com/${{ github.repository }}
    - name: Checkout Repo history to ensure we get correct version
      run: |
        cd ./src/github.com/${{ github.repository }} && git fetch --quiet --prune --unshallow
    - name: Get dependencies
      run: |
        cd src\github.com\${{ github.repository }}
        set GO111MODULE=on
        pushd .
        cd sdk
        go mod tidy
        go mod download
        popd
        pushd .
        cd pkg
        go mod tidy
        go mod download
        popd
        pushd .
        cd tests
        go mod tidy
        go mod download
        popd
    - name: Build Pulumi
      run: |
        cd src\github.com\${{ github.repository }}
        dotnet msbuild /t:Build /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi"
    - name: Run Pulumi Tests
      run: |
        cd src\github.com\${{ github.repository }}
        dotnet msbuild /t:Tests /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi"
