From 6778baadc6a7bdc766bdc4150146b91b853dcb03 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Fri, 23 Aug 2024 10:00:19 +0200 Subject: [PATCH] Modernize CI --- .github/workflows/ci.yml | 84 +++++++++++++++++++++++++--------------- package.json | 3 +- 2 files changed, 54 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ff472ce5..53221377c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,40 +1,62 @@ name: "CI" on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, macos-latest, windows-latest] node-version: - 18.x - 20.x + - 22.x steps: - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Ensure line endings are consistent run: git config --global core.autocrlf input - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Load cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-test-modules-v1-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies - run: yarn install --frozen-lockfile + run: yarn install --frozen-lockfile --ignore-engines - name: Build project run: yarn run build - - name: Run tests - run: export NODE_OPTIONS="--max_old_space_size=4096" && yarn run test-ci + - name: Run unit tests (ubuntu, mac) + if: ${{ (matrix.os == 'ubuntu-latest') || (matrix.os == 'macos-latest') }} + run: export NODE_OPTIONS="--max_old_space_size=4096" && yarn run test-ci:unit + - name: Run unit tests (windows) + if: ${{ matrix.os == 'windows-latest' }} + run: set NODE_OPTIONS=--max-old-space-size=4096 && yarn run test-ci:unit + - name: Run system tests + if: ${{ matrix.os == 'ubuntu-latest' }} + uses: nick-fields/retry@v3 + with: + timeout_minutes: 2 + max_attempts: 3 + command: export NODE_OPTIONS="--max_old_space_size=4096" && yarn run test-ci:system - name: Run browser tests - run: yarn run test-browser + if: ${{ matrix.os == 'ubuntu-latest' }} + uses: nick-fields/retry@v3 + with: + timeout_minutes: 3 + max_attempts: 3 + command: yarn run test-browser - name: Submit coverage results - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.github_token }} flag-name: run-${{ matrix.node-version }} @@ -45,7 +67,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Consolidate test coverage from different jobs - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.github_token }} parallel-finished: true @@ -54,18 +76,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '18.x' + node-version: 18.x - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Load cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-lint-modules-v1-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies - run: yarn install --frozen-lockfile + run: yarn install --frozen-lockfile --ignore-engines - name: Run linter run: yarn run lint @@ -76,18 +98,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '18.x' + node-version: 18.x - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Load cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-docker-modules-v1-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies - run: yarn install --frozen-lockfile + run: yarn install --frozen-lockfile --ignore-engines - name: Install Lerna Docker run: sh -c "`curl -fsSl https://raw.githubusercontent.com/rubensworks/lerna-docker/master/install.sh`" - name: Build Docker images @@ -103,23 +125,23 @@ jobs: runs-on: ubuntu-latest steps: - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '18.x' + node-version: 18.x - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Load cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-docs-modules-v1-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies - run: yarn install --frozen-lockfile + run: yarn install --frozen-lockfile --ignore-engines - name: Build docs run: yarn run doc - name: Deploy TSDoc to GitHub Pages if: startsWith(github.ref, 'refs/heads/master') - uses: JamesIves/github-pages-deploy-action@v4.4.1 + uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages folder: documentation @@ -132,18 +154,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '18.x' + node-version: 18.x - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Load cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-webclients-modules-v1-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies - run: yarn install --frozen-lockfile + run: yarn install --frozen-lockfile --ignore-engines - name: Build web clients run: ./web-clients/build-web-clients.sh - name: Deploy web clients diff --git a/package.json b/package.json index 3abcd6302..28891a861 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,7 @@ "test": "yarn run test:unit && yarn run test:system -i packages/", "test-ci:unit": "jest packages/ --ci --maxWorkers=4 --coverage", "test-ci:system": "jest engines/ --ci --maxWorkers=4 --coverage=false", - "test-ci": "yarn run test-ci:unit && yarn run test-ci:system", - "test-browser": "karma start karma.config.js --single-run || true", + "test-browser": "karma start karma.config.js --single-run", "lint": "eslint . --cache", "lint-fix": "eslint . --fix", "clean": "tsc --build --clean && rm -rf ./node_modules && rm -rf ./packages/*/node_modules",