name: Test installation Linux

on:
  push:
    branches:
      - main
  pull_request:
    paths:
      - "release_files/install.sh"
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.actor_id }}
  cancel-in-progress: true
jobs:
  install-cli-only:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        check_bin_install: [true, false]
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Rename apt package
        if: ${{ matrix.check_bin_install }}
        run: |
          sudo mv /usr/bin/apt /usr/bin/apt.bak
          sudo mv /usr/bin/apt-get /usr/bin/apt-get.bak

      - name: Run install script
        run: |
          sh ./release_files/install.sh

      - name: Run tests
        run: |
          if ! command -v netbird &> /dev/null; then
            echo "Error: netbird is not installed"
            exit 1
          fi
