node-opcua/node-opcua-crypto

View on GitHub
.github/workflows/main.yml

Summary

Maintainability
Test Coverage
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
    # Triggers the workflow on push or pull request events but only for the master branch
    push:
        branches: [master]
    pull_request:
        branches: [master]

    # Allows you to run this workflow manually from the Actions tab
    workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
    prepare:
        strategy:
            matrix:
                node-version: [20.x]
                os: [ubuntu-latest, macos-latest, windows-latest]
        runs-on: ${{ matrix.os }}

        steps:
            - uses: actions/checkout@v3
            - name: Use Node.js ${{ matrix.node-version }}
              uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node-version }}
            - run: npm install
            - name: Cache dependencies
              uses: actions/cache/save@v3
              with:
                  key: ${{ runner.os }}-node-modules-${{ github.sha }}
                  path: node_modules

    build:
        needs: prepare
        strategy:
            matrix:
                node-version: [20.x]
                os: [ubuntu-latest]
        runs-on: ${{ matrix.os }}
        steps:
            - uses: actions/checkout@v3
            - uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node-version }}
            - name: Cache dependencies
              uses: actions/cache/restore@v3
              with:
                  key: ${{ runner.os }}-node-modules-${{ github.sha }}
                  path: node_modules
            - run: npm install
            - run: npm run build
            - name: Cache build artifacts
              uses: actions/cache/save@v3
              with:
                  enableCrossOsArchive: true
                  key: dist-${{ github.sha }}
                  path: |
                      ./packages/node-opcua-crypto/dist*
                      ./packages/node-opcua-crypto-test/dist*

    test-new:
        needs: build
        strategy:
            matrix:
                node-version: [19.x, 20.x]
                os: [ubuntu-20.04, ubuntu-latest, macos-latest, windows-latest]
        runs-on: ${{ matrix.os }}
        steps:
            # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
            - name: checkout
              uses: actions/checkout@v3

            - name: Use Node.js ${{ matrix.node-version }}
              uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node-version }}

            - name: Restore dependencies
              uses: actions/cache/restore@v3
              with:
                  key: ${{ runner.os }}-node-modules-${{ github.sha }}
                  path: node_modules

            - name: Restore build artifacts
              uses: actions/cache/restore@v3
              with:
                  enableCrossOsArchive: true
                  key: dist-${{ github.sha }}
                  path: |
                      ./packages/node-opcua-crypto/dist*
                      ./packages/node-opcua-crypto-test/dist*

            - name: Run test
              run: npm test

    test:
        needs: build
        strategy:
            matrix:
                node-version: [16.x, 18.x]
                os: [ubuntu-20.04, ubuntu-latest, macos-latest, windows-latest]
        runs-on: ${{ matrix.os }}
        steps:
            - name: checkout
              uses: actions/checkout@v3

            - name: Use Node.js ${{ matrix.node-version }}
              uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node-version }}

            - name: nodejs
              run: node --version

            - name: Restore dependencies
              uses: actions/cache/restore@v3
              with:
                  key: ${{ runner.os }}-node-modules-${{ github.sha }}
                  path: node_modules

            - name: Restore build artifacts
              uses: actions/cache/restore@v3
              with:
                  enableCrossOsArchive: true
                  key: dist-${{ github.sha }}
                  path: |
                      ./packages/node-opcua-crypto/dist*
                      ./packages/node-opcua-crypto-test/dist*
              
            - name: Run test
              run: npm test
            - name: run esm test
              run: npm run esm:test

    test-legacy:
        needs: build
        strategy:
            matrix:
                node-version: [14.x]
                os: [
                        # ubuntu-18.04,
                        ubuntu-20.04,
                        ubuntu-latest,
                        macos-latest,
                        windows-latest,
                    ]
        runs-on: ${{ matrix.os }}
        steps:
            - name: checkout
              uses: actions/checkout@v3

            - name: Use Node.js ${{ matrix.node-version }}
              uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node-version }}

            - name: nodejs
              run: node --version


            - name: Restore dependencies
              uses: actions/cache/restore@v3
              with:
                  key: ${{ runner.os }}-node-modules-${{ github.sha }}
                  path: node_modules

            - name: Restore build artifacts
              uses: actions/cache/restore@v3
              with:
                  enableCrossOsArchive: true
                  key: dist-${{ github.sha }}
                  path: |
                      ./packages/node-opcua-crypto/dist*
                      ./packages/node-opcua-crypto-test/dist*
              
            - name: Run test
              run: npm test