Skip to content

Add concurrency control to GitHub Actions workflows #2

Add concurrency control to GitHub Actions workflows

Add concurrency control to GitHub Actions workflows #2

Workflow file for this run

name: Tests
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
workflow_dispatch: # Allow manual triggering
# Cancel in-progress runs when a new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [18.x, 20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install libssh (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssh-dev
- name: Install libssh (macOS)
if: runner.os == 'macOS'
run: |
brew install libssh
- name: Install libssh (Windows)
if: runner.os == 'Windows'
run: |
choco install cmake -y
vcpkg install libssh:x64-windows
vcpkg integrate install
shell: powershell
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build TypeScript
run: yarn build:ts
- name: Run linter
run: yarn lint --max-warnings 0
continue-on-error: true
- name: Run tests
run: yarn test
- name: Build native module (Ubuntu/macOS)
if: runner.os != 'Windows'
run: yarn build:native
continue-on-error: true
- name: Build native module (Windows)
if: runner.os == 'Windows'
run: yarn build:native
env:
VCPKG_ROOT: C:\vcpkg
continue-on-error: true
test-coverage:
name: Test Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'yarn'
- name: Install libssh
run: |
sudo apt-get update
sudo apt-get install -y libssh-dev
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build TypeScript
run: yarn build:ts
- name: Run tests with coverage
run: yarn test --coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage/coverage-final.json
fail_ci_if_error: false