Improve CI performances - attempt 2 #244
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and test Sinch Node.js SDK | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
packages/**/node_modules | |
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ matrix.node-version }}- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Run ESLint | |
run: npx eslint "packages/**/{src,tests}/**/*.ts" | |
- name: Build project | |
run: yarn run build | |
- name: Cache build output | |
uses: actions/cache@v3 | |
with: | |
path: | | |
packages/**/dist | |
key: ${{ runner.os }}-node-${{ matrix.node-version }}-build-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ matrix.node-version }}-build- | |
- name: Run unit tests | |
run: yarn run test | |
e2e: | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [ 18.x, 20.x ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Checkout sinch-sdk-mockserver repository | |
uses: actions/checkout@v3 | |
with: | |
repository: sinch/sinch-sdk-mockserver | |
token: ${{ secrets.PAT_CI }} | |
fetch-depth: 0 | |
path: sinch-sdk-mockserver | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Restore Node.js modules cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
packages/**/node_modules | |
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ matrix.node-version }}- | |
- name: Restore build output | |
uses: actions/cache@v3 | |
with: | |
path: | | |
packages/**/dist | |
key: ${{ runner.os }}-node-${{ matrix.node-version }}-build-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ matrix.node-version }}-build- | |
- name: Install Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
- name: Start mock servers with Docker Compose | |
run: | | |
cd sinch-sdk-mockserver | |
docker-compose up -d | |
- name: Create target directories for feature files | |
run: | | |
mkdir -p ./packages/fax/tests/e2e/features | |
mkdir -p ./packages/numbers/tests/e2e/features | |
mkdir -p ./packages/conversation/tests/e2e/features | |
mkdir -p ./packages/elastic-sip-trunking/tests/e2e/features | |
mkdir -p ./packages/sms/tests/e2e/features | |
mkdir -p ./packages/verification/tests/e2e/features | |
mkdir -p ./packages/voice/tests/e2e/features | |
- name: Copy feature files | |
run: | | |
cp sinch-sdk-mockserver/features/fax/*.feature ./packages/fax/tests/e2e/features/ | |
cp sinch-sdk-mockserver/features/numbers/*.feature ./packages/numbers/tests/e2e/features/ | |
cp sinch-sdk-mockserver/features/conversation/*.feature ./packages/conversation/tests/e2e/features/ | |
cp sinch-sdk-mockserver/features/elastic-sip-trunking/*.feature ./packages/elastic-sip-trunking/tests/e2e/features/ | |
cp sinch-sdk-mockserver/features/sms/*.feature ./packages/sms/tests/e2e/features/ | |
cp sinch-sdk-mockserver/features/verification/*.feature ./packages/verification/tests/e2e/features/ | |
cp sinch-sdk-mockserver/features/voice/*.feature ./packages/voice/tests/e2e/features/ | |
- name: Run e2e tests | |
run: yarn run e2e | |
sonarcloud: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Disabling shallow clone is recommended for improving relevancy of reporting | |
fetch-depth: 0 | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_CI }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |