MaxMilton/ekscss

View on GitHub
.github/workflows/ci.yml

Summary

Maintainability
Test Coverage
name: ci
on:
  push:
    branches: [master]
    paths-ignore: ['**.md']
  pull_request: {}
  workflow_dispatch: {}
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.run_id }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest
      - run: bun install --frozen-lockfile
      - run: bun run build
      - uses: actions/upload-artifact@v4
        with:
          name: build
          path: packages/*/dist/**
  test:
    needs: build
    strategy:
      fail-fast: false
      matrix:
        platform: [ubuntu-latest, windows-latest, macos-latest]
    name: test-bun (${{ matrix.platform }})
    runs-on: ${{ matrix.platform }}
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v4
      # bun install on windows is currently slow, cache it
      - uses: actions/cache@v4
        if: ${{ matrix.platform == 'windows-latest' }}
        with:
          path: ~/.bun/install/cache
          key: ${{ runner.os }}-bun-${{ hashFiles('bun.lockb') }}
          restore-keys: |
            ${{ runner.os }}-bun-
      - uses: actions/download-artifact@v4
        with:
          name: build
          path: packages
      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest
      - run: bun install --frozen-lockfile
      - run: bun run test --coverage --coverage-reporter=lcov --coverage-reporter=text
      - name: Report coverage
        if: ${{ matrix.platform == 'ubuntu-latest' && github.repository_owner == 'maxmilton' }}
        run: |
          curl -LO https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 \
               -LO https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64.sha256
          grep test-reporter-latest-linux-amd64 test-reporter-latest-linux-amd64.sha256 | shasum -a 256 -c -
          mv test-reporter-latest-linux-amd64 test-reporter
          chmod +x ./test-reporter
          ./test-reporter format-coverage -t lcov -o coverage/codeclimate.json coverage/lcov.info
          ./test-reporter upload-coverage
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
  test-node:
    needs: build
    strategy:
      fail-fast: false
      matrix:
        node-version: [12, 14, 16, 18, 20, 22]
        platform: [ubuntu-latest, windows-latest, macos-latest]
        exclude:
          # no prebuilt node <=14 for darwin arm64 (macos-latest; macos-14)
          - node-version: 12
            platform: macos-latest
          - node-version: 14
            platform: macos-latest
        include:
          - node-version: 12
            platform: macos-13
          - node-version: 14
            platform: macos-13
    name: test-node (v${{ matrix.node-version }} ${{ matrix.platform }})
    runs-on: ${{ matrix.platform }}
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      # bun install on windows is currently slow, cache it
      - uses: actions/cache@v4
        if: ${{ matrix.platform == 'windows-latest' }}
        with:
          path: ~/.bun/install/cache
          key: ${{ runner.os }}-bun-${{ hashFiles('bun.lockb') }}
          restore-keys: |
            ${{ runner.os }}-bun-
      - uses: actions/download-artifact@v4
        with:
          name: build
          path: packages
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}
      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest
      - run: bun install --frozen-lockfile
      - run: bun install --global pnpm@6
        if: ${{ matrix.node-version == 12 }}
      - run: bun install --global pnpm@7
        if: ${{ matrix.node-version == 14 }}
      - run: bun install --global pnpm@8
        if: ${{ matrix.node-version == 16 }}
      - run: bun install --global pnpm
        if: ${{ matrix.node-version >= 18 }}
      - run: pnpm run test:node
        if : ${{ matrix.node-version < 22 || matrix.platform != 'ubuntu-latest' }}
      - run: pnpm run test:node:c8
        if : ${{ matrix.node-version == 22 && matrix.platform == 'ubuntu-latest' }}
      - name: Report coverage
        if: ${{ matrix.node-version == 22 && matrix.platform == 'ubuntu-latest' && github.repository_owner == 'maxmilton' }}
        run: |
          curl -LO https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 \
               -LO https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64.sha256
          grep test-reporter-latest-linux-amd64 test-reporter-latest-linux-amd64.sha256 | shasum -a 256 -c -
          mv test-reporter-latest-linux-amd64 test-reporter
          chmod +x ./test-reporter
          ./test-reporter format-coverage -t lcov -o coverage/codeclimate.json coverage/lcov.info
          ./test-reporter upload-coverage
        env:
          CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
  lint:
    needs: build
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v4
      - uses: actions/download-artifact@v4
        with:
          name: build
          path: packages
      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest
      - run: bun install --frozen-lockfile
      - run: bun run lint