|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Test on ${{ matrix.os }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 18 | + node-version: [18.x, 20.x] |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 25 | + uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: ${{ matrix.node-version }} |
| 28 | + cache: 'yarn' |
| 29 | + |
| 30 | + - name: Install libssh (Ubuntu) |
| 31 | + if: runner.os == 'Linux' |
| 32 | + run: | |
| 33 | + sudo apt-get update |
| 34 | + sudo apt-get install -y libssh-dev |
| 35 | +
|
| 36 | + - name: Install libssh (macOS) |
| 37 | + if: runner.os == 'macOS' |
| 38 | + run: | |
| 39 | + brew install libssh |
| 40 | +
|
| 41 | + - name: Install libssh (Windows) |
| 42 | + if: runner.os == 'Windows' |
| 43 | + run: | |
| 44 | + choco install cmake -y |
| 45 | + vcpkg install libssh:x64-windows |
| 46 | + vcpkg integrate install |
| 47 | + shell: powershell |
| 48 | + |
| 49 | + - name: Install dependencies |
| 50 | + run: yarn install --frozen-lockfile |
| 51 | + |
| 52 | + - name: Build TypeScript |
| 53 | + run: yarn build:ts |
| 54 | + |
| 55 | + - name: Run linter |
| 56 | + run: yarn lint --max-warnings 0 |
| 57 | + continue-on-error: true |
| 58 | + |
| 59 | + - name: Run tests |
| 60 | + run: yarn test |
| 61 | + |
| 62 | + - name: Build native module (Ubuntu/macOS) |
| 63 | + if: runner.os != 'Windows' |
| 64 | + run: yarn build:native |
| 65 | + continue-on-error: true |
| 66 | + |
| 67 | + - name: Build native module (Windows) |
| 68 | + if: runner.os == 'Windows' |
| 69 | + run: yarn build:native |
| 70 | + env: |
| 71 | + VCPKG_ROOT: C:\vcpkg |
| 72 | + continue-on-error: true |
| 73 | + |
| 74 | + test-coverage: |
| 75 | + name: Test Coverage |
| 76 | + runs-on: ubuntu-latest |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: Checkout code |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Setup Node.js |
| 83 | + uses: actions/setup-node@v4 |
| 84 | + with: |
| 85 | + node-version: '20.x' |
| 86 | + cache: 'yarn' |
| 87 | + |
| 88 | + - name: Install libssh |
| 89 | + run: | |
| 90 | + sudo apt-get update |
| 91 | + sudo apt-get install -y libssh-dev |
| 92 | +
|
| 93 | + - name: Install dependencies |
| 94 | + run: yarn install --frozen-lockfile |
| 95 | + |
| 96 | + - name: Build TypeScript |
| 97 | + run: yarn build:ts |
| 98 | + |
| 99 | + - name: Run tests with coverage |
| 100 | + run: yarn test --coverage |
| 101 | + |
| 102 | + - name: Upload coverage to Codecov |
| 103 | + uses: codecov/codecov-action@v4 |
| 104 | + with: |
| 105 | + file: ./coverage/coverage-final.json |
| 106 | + fail_ci_if_error: false |
0 commit comments