From 86d5b86dad1561a7ffed9db488cdfedf6ef9d20b Mon Sep 17 00:00:00 2001 From: agracio Date: Tue, 17 Sep 2024 23:25:07 +0100 Subject: [PATCH] updating GitHub pipeline --- .github/actions/create-test-report/action.yml | 55 +++++++++++ .github/actions/setup-env/action.yml | 43 +++++++++ .github/actions/test-windows/action.yml | 27 ++++++ .github/workflows/main.yml | 91 +++++-------------- README.md | 2 +- package-lock.json | 19 ++-- package.json | 2 +- tools/test.js | 4 + 8 files changed, 165 insertions(+), 78 deletions(-) create mode 100644 .github/actions/create-test-report/action.yml create mode 100644 .github/actions/setup-env/action.yml create mode 100644 .github/actions/test-windows/action.yml diff --git a/.github/actions/create-test-report/action.yml b/.github/actions/create-test-report/action.yml new file mode 100644 index 00000000..8f8aaf90 --- /dev/null +++ b/.github/actions/create-test-report/action.yml @@ -0,0 +1,55 @@ +name: 'Test report' +description: 'Create test report' +inputs: + name: + description: 'name' + required: false + default: 'test-results' + node: + description: 'Node.js version' + required: true + os: + description: 'runs-on' + required: true + +runs: + using: "composite" + steps: + + - name: Read mochawesome.json + uses: actions/github-script@v7 + with: + result-encoding: string + script: | + try { + const fs = require('fs') + const jsonString = fs.readFileSync('mochawesome.json') + var report = JSON.parse(jsonString); + let stats = { + passing: report.stats.passes, + skipped: report.stats.pending, + failures: report.stats.failures + }; + core.notice(JSON.stringify(stats)); + } catch(err) { + core.error("Error while reading or parsing mochawesome.json") + core.setFailed(err) + } + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + if: success() + with: + name: ${{ inputs.name }}-${{ inputs.os }}-${{ inputs.node }} + path: | + test-results.xml + mochawesome.json + + - name: Create test report + uses: phoenix-actions/test-reporting@v15 + if: success() + with: + name: ${{ inputs.name }}-${{ inputs.os }}-v${{ inputs.node }} + fail-on-error: true + path: mochawesome.json # Path to test results + reporter: mochawesome-json diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml new file mode 100644 index 00000000..cc2bddb9 --- /dev/null +++ b/.github/actions/setup-env/action.yml @@ -0,0 +1,43 @@ +name: 'Setup environment' +description: 'Sets up environment' +inputs: + node: + description: 'Node.js version' + required: true + os: + description: 'runs-on' + required: true + +runs: + using: "composite" + steps: + + - name: Setup NodeJS + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node }} + cache: 'npm' + cache-dependency-path: package-lock.json + + - name: Cache node modules + id: cache-nodemodules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + path: node_modules + key: ${{ inputs.os }}-${{ inputs.node }}-${{ hashFiles('package-lock.json') }} + + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' # SDK Version to use; x will use the latest version of the 8.0 channel + + - name: Versions + shell: bash + run: | + node -v && npm -v && dotnet --version && node -p process.platform && node -p process.arch + + - name: npm install + shell: bash + run: npm ci diff --git a/.github/actions/test-windows/action.yml b/.github/actions/test-windows/action.yml new file mode 100644 index 00000000..9d5a573f --- /dev/null +++ b/.github/actions/test-windows/action.yml @@ -0,0 +1,27 @@ +name: 'Test Windows' +description: 'Runs Windows tests' +inputs: + node: + description: 'Node.js version' + required: true + +runs: + using: "composite" + steps: + - uses: agracio/github-substring-action@v1.0.0 + id: node_version + with: + value: "${{ inputs.node }}" + length_from_start: 2 + + - name: Check edge-js Windows pre-built files + uses: andstor/file-existence-action@v3 + with: + files: "lib/native/win32/${{ runner.arch }}/${{ steps.node_version.outputs.substring }}/edge_coreclr.node, lib/native/win32/${{ runner.arch }}/${{ steps.node_version.outputs.substring }}/edge_nativeclr.node" + fail: true + ignore_case: true + + - name: Run .NET 4.5 tests + shell: bash + run: node tools/test.js CI + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c0bd7a61..82bef3c4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Build and Test +name: Test on: push: @@ -9,6 +9,7 @@ on: - 'stress/*' - 'performance/*' - '.github/FUNDING.YML' + - '.github/workflows/build.yml' - '**/*.md' - '**/*.d.ts' - '**/*.bat' @@ -34,93 +35,49 @@ on: env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true # required to setup CSC DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_NOLOGO: 1 jobs: - build-test: + test: runs-on: ${{ matrix.os }} - name: build-test-${{ matrix.os }}-node-${{ matrix.node }} + name: test-${{ matrix.os }}-node-${{ matrix.node }} strategy: + fail-fast: false matrix: - # os: [macos-latest, ubuntu-latest, windows-2019] - os: [macos-14] - node: [20, 22] + # os: [macos-13, macos-14, ubuntu-22.04, windows-2022] + os: [macos-14, windows-2022] + node: [18, 20, 22] + steps: + - name: Checkout code uses: actions/checkout@v4 - - name: Setup NodeJS - uses: actions/setup-node@v4 - with: - node-version: '${{ matrix.node }}' - cache: 'npm' - cache-dependency-path: package-lock.json - - - name: Cache node modules - id: cache-nodemodules - uses: actions/cache@v4 - env: - cache-name: cache-node-modules - with: - path: node_modules - key: ${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }} - - # - if: runner.os == 'Windows' - # name: Setup CSC for Windows - # uses: yoavain/Setup-CSC@v5 - - - name: Setup dotnet - uses: actions/setup-dotnet@v4 + - name: Setup env + uses: ./.github/actions/setup-env with: - dotnet-version: '8.0.x' # SDK Version to use; x will use the latest version of the 8.0 channel - - - name: Versions - run: node -v && npm -v && dotnet --version && node -p process.platform && node -p process.arch - - # - if: runner.os == 'macOS' - # name: Mono - # run: | - # which mono - # export PKG_CONFIG_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig":$PKG_CONFIG_PATH - # name: Remove Mono from macOS # Incomplete Mono install interferes with gyp compile - # run: | - # sudo rm -rf /Library/Frameworks/Mono.framework - # sudo pkgutil --forget com.xamarin.mono-MDK.pkg - # sudo rm /etc/paths.d/mono-commands + node: ${{ matrix.node }} + os: ${{ matrix.os }} # - if: runner.os == 'macOS' && matrix.node == '16.x' # name: Add missing packages for macOS NodeJs 16 # run: | # pip install setuptools - - name: npm install - run: npm i --no-audit - env: - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - - # - if: runner.os == 'Windows' - # name: Run .NET 4.5 tests - # run: node tools/test.js CI + - if: runner.os == 'Windows' + name: Run Windows tests + uses: ./.github/actions/test-windows + with: + node: ${{ matrix.node }} - name: "Run .net core tests" run: node tools/test.js CI env: EDGE_USE_CORECLR: 1 - - name: Upload artifacts - uses: actions/upload-artifact@v4.3.3 - if: success() - with: - name: ${{ matrix.os }}-${{ matrix.node }} - path: | - test-results.xml - mochawesome.json - - - name: Test Report - uses: phoenix-actions/test-reporting@v15 - if: success() + - name: Test report + uses: ./.github/actions/create-test-report with: - name: test-results-${{ matrix.os }}-node-${{ matrix.node }} - fail-on-error: true - path: mochawesome.json # Path to test results - reporter: mochawesome-json + node: ${{ matrix.node }} + os: ${{ matrix.os }} diff --git a/README.md b/README.md index fd459e1c..2e8c3a01 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build status][appveyor-image]][appveyor-url] [![CircleCI](https://dl.circleci.com/status-badge/img/gh/agracio/edge-js.svg?style=shield )](https://dl.circleci.com/status-badge/redirect/gh/agracio/edge-js/tree/master) -[![Actions Status](https://github.com/agracio/edge-js/workflows/Build%20and%20Test/badge.svg)](https://github.com/agracio/edge-js/actions) +[![Actions Status](https://github.com/agracio/edge-js/workflows/Test/badge.svg)](https://github.com/agracio/edge-js/actions) [![NPM Downloads][downloads-image]][downloads-url] [![Git Issues][issues-img]][issues-url] diff --git a/package-lock.json b/package-lock.json index 06742c50..b97689f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "edge-js", - "version": "22.1.2", + "version": "22.7.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "edge-js", - "version": "22.1.2", + "version": "22.7.0", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -14,7 +14,7 @@ "nan": "^2.20.0" }, "devDependencies": { - "follow-redirects": "^1.15.6", + "follow-redirects": "^1.15.9", "junit-report-merger": "7.0.0", "mocha": "10.7.3", "mocha-junit-reporter": "^2.2.1", @@ -508,9 +508,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", "dev": true, "funding": [ { @@ -518,6 +518,7 @@ "url": "https://github.com/sponsors/RubenVerborgh" } ], + "license": "MIT", "engines": { "node": ">=4.0" }, @@ -2150,9 +2151,9 @@ "dev": true }, "follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", "dev": true }, "fs-extra": { diff --git a/package.json b/package.json index 5a08dd4f..20130d57 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "nan": "^2.20.0" }, "devDependencies": { - "follow-redirects": "^1.15.6", + "follow-redirects": "^1.15.9", "junit-report-merger": "7.0.0", "mocha": "10.7.3", "mocha-junit-reporter": "^2.2.1", diff --git a/tools/test.js b/tools/test.js index 9432202a..babfa08d 100644 --- a/tools/test.js +++ b/tools/test.js @@ -12,6 +12,10 @@ const marge = require('mochawesome-report-generator') var runner = process.argv[2]; +if (process.platform !== 'win32') { + process.env.EDGE_USE_CORECLR = 1 +} + if(process.argv[3] === 'coreclr'){ process.env.EDGE_USE_CORECLR = 1 }