
on: pull_request
name: Build and Test
jobs:
  tests-integration-img:
    strategy:
      matrix:
        go-version: [1.16.x]
        platform: [ubuntu-latest]
    runs-on: ${{ matrix.platform }}
    steps:
    - name: Install Go
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go-version }}
    - name: Checkout code
      uses: actions/checkout@v2
    - name: setup-docker
      uses: docker-practice/actions-setup-docker@0.0.1
    - name: Install deps
      run: |
            sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
            sudo curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/img"
            sudo chmod a+x "/usr/bin/img"
    - name: Tests with Img backend
      run: sudo -E env "PATH=$PATH" env "LUET_BACKEND=img" make test-integration

  tests-integration:
    strategy:
      matrix:
        go-version: [1.16.x]
        platform: [ubuntu-latest]
    runs-on: ${{ matrix.platform }}
    steps:
    - name: Install Go
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go-version }}
    - name: Checkout code
      uses: actions/checkout@v2
    - name: setup-docker
      uses: docker-practice/actions-setup-docker@0.0.1
    - name: Install deps
      run: |
            sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
    - name: Tests
      run: sudo -E env "PATH=$PATH" make test-integration
  tests-unit:
    strategy:
      matrix:
        go-version: [1.16.x]
        platform: [ubuntu-latest]
    runs-on: ${{ matrix.platform }}
    steps:
    - name: Install Go
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go-version }}
    - name: Checkout code
      uses: actions/checkout@v2
    - name: setup-docker
      uses: docker-practice/actions-setup-docker@0.0.1
    - name: Install deps
      run: |
            sudo apt-get install -y upx && sudo -E env "PATH=$PATH" make deps
            sudo curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/bin/img"
            sudo chmod a+x "/usr/bin/img"
            make build
            sudo cp -rf luet /usr/bin/luet
    - name: Install GoReleaser
      uses: goreleaser/goreleaser-action@v2
      with:
        install-only: true
    - name: Build
      run: sudo -E env "PATH=$PATH" make multiarch-build-small
    - name: Tests
      run: sudo -E env "PATH=$PATH" make coverage
    - name: Codecov
      uses: codecov/codecov-action@v2.1.0
      with:
        file: coverage.txt
