diff --git a/.github/actions/create-test-report/action.yml b/.github/actions/create-test-report/action.yml new file mode 100644 index 0000000..1dd1259 --- /dev/null +++ b/.github/actions/create-test-report/action.yml @@ -0,0 +1,34 @@ +name: 'Test report' +description: 'Create test report' +inputs: + electron: + description: 'Electron version' + required: true + os: + description: 'runs-on' + required: true + +runs: + using: "composite" + steps: + - name: "Merge test files" + shell: bash + run: node tools/mergeTests.js + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + if: success() + with: + name: ${{ inputs.os }}-${{ inputs.electron }} + path: | + test/mochawesome-report/mochawesome.json + test/mochawesome-report/mochawesome.html + + - name: Create test report + uses: phoenix-actions/test-reporting@v15 + if: success() + with: + name: test-results-${{ inputs.os }}-v${{ inputs.electron }} + fail-on-error: true + path: test/mochawesome-report/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 index 5792648..7365a17 100644 --- a/.github/actions/setup-env/action.yml +++ b/.github/actions/setup-env/action.yml @@ -1,12 +1,12 @@ -name: 'Checkout and setup' -description: 'Checks out code and sets up environment' +name: 'Setup environment' +description: 'Sets up environment' inputs: node: description: 'Node.js version' required: false default: '20' - runs-on: - description: 'Runner OS' + os: + description: 'runs-on' required: false default: 'windows-2022' electron: @@ -20,8 +20,6 @@ inputs: runs: using: "composite" steps: - # - name: Checkout code - # uses: actions/checkout@v4 - name: Setup NodeJS uses: actions/setup-node@v4 @@ -29,29 +27,9 @@ runs: 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.runs-on }}-${{ inputs.electron }}-${{ 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: "Read JSON" + - name: Read package.json uses: actions/github-script@v7 - id: check-env with: result-encoding: string script: | @@ -70,25 +48,28 @@ runs: if: ${{ inputs.replace-version == 'true' }} run: | sed -i -e 's/${{ env.json_electron_version}}/=${{ inputs.electron }}/g' package.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.electron }}-${{ hashFiles('package.json') }} - # - if: runner.os == 'Windows' - # uses: agracio/github-substring-action@v1.0.0 - # id: electron_version - # with: - # value: "${{ matrix.electron }}" - # length_from_start: 2 + - 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 - # - if: runner.os == 'Windows' - # name: Check electron-edge-js Windows pre-built files - # id: check_windows_build - # uses: andstor/file-existence-action@v3 - # with: - # files: "lib/native/win32/${{ runner.arch }}/${{ steps.electron_version.outputs.substring }}.0.0/edge_coreclr.node, lib/native/win32/${{ runner.arch }}/${{ steps.electron_version.outputs.substring }}.0.0/edge_nativeclr.node" - # fail: true - # ignore_case: true + - 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 + run: npm i env: DOTNET_CLI_TELEMETRY_OPTOUT: 1 \ No newline at end of file diff --git a/.github/actions/test-windows/action.yml b/.github/actions/test-windows/action.yml new file mode 100644 index 0000000..c0d7311 --- /dev/null +++ b/.github/actions/test-windows/action.yml @@ -0,0 +1,33 @@ +name: 'Test Windows' +description: 'Runs Windows tests' +inputs: + electron: + description: 'Electron version' + required: true + +runs: + using: "composite" + steps: + - uses: agracio/github-substring-action@v1.0.0 + id: electron_version + with: + value: "${{ inputs.electron }}" + length_from_start: 2 + + - name: Check electron-edge-js Windows pre-built files + uses: andstor/file-existence-action@v3 + with: + files: "lib/native/win32/${{ runner.arch }}/${{ steps.electron_version.outputs.substring }}.0.0/edge_coreclr.node, lib/native/win32/${{ runner.arch }}/${{ steps.electron_version.outputs.substring }}.0.0/edge_nativeclr.node" + fail: true + ignore_case: true + + - name: Run .NET 4.5 tests Windows + shell: bash + run: node tools/test.js CI + + - if: runner.os == 'Windows' + shell: bash + name: "Run .net core tests Windows" + run: node tools/test.js CI + env: + EDGE_USE_CORECLR: 1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58a3e9b..913a842 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,23 +26,7 @@ jobs: uses: ./.github/actions/setup-env with: electron: ${{ matrix.electron }} - replace-version: true - - - name: Read package.json - uses: actions/github-script@v7 - with: - result-encoding: string - script: | - try { - const fs = require('fs') - const jsonString = fs.readFileSync('package.json') - var json = JSON.parse(jsonString); - core.setFailed(json.devDependencies.electron.toString()) - } catch(err) { - core.error("Error while reading or parsing package.json") - core.setFailed(err) - } - + - name: install node-gyp run: npm i -g node-gyp @@ -60,17 +44,19 @@ jobs: - name: Build ia32 timeout-minutes: 30 + shell: cmd run: | node-gyp configure build --target=${{ matrix.electron }} --disturl=https://electronjs.org/headers --runtime=electron --release --arch=ia32 - cmd /c copy /y build\Release\edge_*.node release\ia32\${{ matrix.electron }} - cmd /c rmdir /S /Q build + copy /y build\Release\edge_*.node release\ia32\${{ matrix.electron }} + rmdir /S /Q build - name: Build x64 timeout-minutes: 30 + shell: cmd run: | node-gyp configure build --target=${{ matrix.electron }} --disturl=https://electronjs.org/headers --runtime=electron --release --arch=x64 - cmd /c copy /y build\Release\edge_*.node release\x64\${{ matrix.electron }} - cmd /c rmdir /S /Q build + copy /y build\Release\edge_*.node release\x64\${{ matrix.electron }} + rmdir /S /Q build - name: Build arm64 timeout-minutes: 30 @@ -123,17 +109,35 @@ jobs: length_from_start: 2 - name: Create release folder + shell: cmd run: | - cmd /c if not exist "lib\native\win32\ia32\${{ steps.electron_version.outputs.substring }}.0.0" mkdir "lib\native\win32\ia32\${{ steps.electron_version.outputs.substring }}.0.0" - cmd /c if not exist "lib\native\win32\x64\${{ steps.electron_version.outputs.substring }}.0.0" mkdir "lib\native\win32\x64\${{ steps.electron_version.outputs.substring }}.0.0" - cmd /c if not exist "lib\native\win32\arm64\${{ steps.electron_version.outputs.substring }}.0.0" mkdir "lib\native\win32\arm64\${{ steps.electron_version.outputs.substring }}.0.0" + if not exist "lib\native\win32\ia32\${{ steps.electron_version.outputs.substring }}.0.0" mkdir "lib\native\win32\ia32\${{ steps.electron_version.outputs.substring }}.0.0" + if not exist "lib\native\win32\x64\${{ steps.electron_version.outputs.substring }}.0.0" mkdir "lib\native\win32\x64\${{ steps.electron_version.outputs.substring }}.0.0" + if not exist "lib\native\win32\arm64\${{ steps.electron_version.outputs.substring }}.0.0" mkdir "lib\native\win32\arm64\${{ steps.electron_version.outputs.substring }}.0.0" - name: Download artifacts uses: actions/download-artifact@v4 with: path: release pattern: ${{ steps.electron_version.outputs.substring }}.0.0* + - run: ls -R release - - run: ls -R + + - name: Copy artifacts + shell: cmd + run: | + copy /y release\${{ steps.electron_version.outputs.substring }}.0.0\x64\${{ steps.electron_version.outputs.substring }}.0.0\edge_*.node lib\native\win32\arm64\${{ steps.electron_version.outputs.substring }}.0.0 + + - name: Test + timeout-minutes: 10 + uses: ./.github/actions/test-windows + with: + electron: ${{ matrix.electron }} + + - name: Test report + uses: ./.github/actions/create-test-report + with: + electron: ${{ matrix.electron }} + \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f757ac..1393fed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,9 +42,10 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-13, macos-14, ubuntu-22.04, windows-2022] - # os: [ windows-2019] - electron: [29.4.6, 30.5.1, 31.6.0] + # os: [macos-13, macos-14, ubuntu-22.04, windows-2022] + os: [ windows-2022, ubuntu-22.04] + electron: [30.5.1] + # electron: [29.4.6, 30.5.1, 31.6.0] # electron: [31.6.0, 32.1.0] name: test-${{ matrix.os }}-v${{ matrix.electron }} @@ -52,56 +53,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup NodeJS - uses: actions/setup-node@v4 + - name: Setup env + uses: ./.github/actions/setup-env with: - node-version: '20' - 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.electron }}-${{ 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 - run: | - node -v && npm -v && dotnet --version && node -p process.platform && node -p process.arch - - - name: setup electron version - shell: bash - run: | - sed -i -e 's/"electron": "=31.6.0"/"electron": "=${{ matrix.electron }}"/g' package.json - - - if: runner.os == 'Windows' - uses: agracio/github-substring-action@v1.0.0 - id: electron_version - with: - value: "${{ matrix.electron }}" - length_from_start: 2 - - - if: runner.os == 'Windows' - name: Check electron-edge-js Windows pre-built files - id: check_windows_build - uses: andstor/file-existence-action@v3 - with: - files: "lib/native/win32/${{ runner.arch }}/${{ steps.electron_version.outputs.substring }}.0.0/edge_coreclr.node, lib/native/win32/${{ runner.arch }}/${{ steps.electron_version.outputs.substring }}.0.0/edge_nativeclr.node" - fail: true - ignore_case: true - - - name: npm install - run: npm i --no-audit - env: - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + electron: ${{ matrix.electron }} + replace-version: true - if: runner.os == 'macOS' || runner.os == 'Linux' name: Check electron-edge-js build file @@ -112,24 +68,11 @@ jobs: fail: true ignore_case: true - # - if: (runner.os == 'macOS' || runner.os == 'Linux') && steps.check_build.outputs.files_exists == 'false' - # name: electron-edge-js build failed - # run: | - # echo "::error file=app.js::Failed to build electron-edge-js for Electron ${{ matrix.electron }}" - # exit 1 - # continue-on-error: true - - - if: runner.os == 'Windows' - name: Run .NET 4.5 tests Windows - timeout-minutes: 10 - run: node tools/test.js CI - - if: runner.os == 'Windows' - name: "Run .net core tests Windows" - timeout-minutes: 10 - run: node tools/test.js CI - env: - EDGE_USE_CORECLR: 1 + name: Run Windows tests + uses: ./.github/actions/test-windows + with: + electron: ${{ matrix.electron }} - if: runner.os == 'macOS' name: "Run .net core tests macOS" @@ -150,24 +93,30 @@ jobs: # env: # EDGE_USE_CORECLR: 1 - - name: "Merge test files" - run: node tools/mergeTests.js - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - if: success() - with: - name: ${{ matrix.os }}-${{ matrix.electron }} - path: | - test/mochawesome-report/mochawesome.json - test/mochawesome-report/mochawesome.html - - - name: Create 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 }}-v${{ matrix.electron }} - fail-on-error: true - path: test/mochawesome-report/mochawesome.json # Path to test results - reporter: mochawesome-json + electron: ${{ matrix.electron }} + os: ${{ matrix.os }} + + # - name: "Merge test files" + # run: node tools/mergeTests.js + + # - name: Upload artifacts + # uses: actions/upload-artifact@v4 + # if: success() + # with: + # name: ${{ matrix.os }}-${{ matrix.electron }} + # path: | + # test/mochawesome-report/mochawesome.json + # test/mochawesome-report/mochawesome.html + + # - name: Create test report + # uses: phoenix-actions/test-reporting@v15 + # if: success() + # with: + # name: test-results-${{ matrix.os }}-v${{ matrix.electron }} + # fail-on-error: true + # path: test/mochawesome-report/mochawesome.json # Path to test results + # reporter: mochawesome-json