diff --git a/.github/workflows/ci.yml b/.github/workflows/Build and Publish.yml similarity index 63% rename from .github/workflows/ci.yml rename to .github/workflows/Build and Publish.yml index a9b81df7..17bd8ca0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/Build and Publish.yml @@ -1,33 +1,25 @@ -name: CI +name: Build and Publish -on: [push, pull_request] +on: [push] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} -jobs: - # linux: - # runs-on: ubuntu-latest - # timeout-minutes: 10 - - # steps: - # - uses: actions/checkout@v4 +concurrency: + group: build-publish-${{ github.ref }} + cancel-in-progress: true - # - name: Setup dotnet - # uses: actions/setup-dotnet@v4 - # with: - # dotnet-version: | - # 6.0.x - # 8.0.x - # 10.0.x - - # - name: Build - # run: ./build.sh +jobs: + Integration-Tests: + uses: ./.github/workflows/integration-tests.yml + name: '1' - windows: + Publish: + needs: [Integration-Tests] runs-on: windows-latest timeout-minutes: 10 + name: '2 / Publish' steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/PR Validation.yml b/.github/workflows/PR Validation.yml new file mode 100644 index 00000000..540db15b --- /dev/null +++ b/.github/workflows/PR Validation.yml @@ -0,0 +1,39 @@ +name: PR Validation + +on: [pull_request] + +concurrency: + group: pr-validation-${{ github.ref }} + cancel-in-progress: true + +jobs: + Whitespace-Check: + uses: ./.github/workflows/trailing-whitespace-check.yml + secrets: inherit + name: '1' + + Tests: + needs: Whitespace-Check + uses: ./.github/workflows/integration-tests.yml + secrets: inherit + name: '2' + + build: + needs: [Whitespace-Check, Tests] + runs-on: windows-latest + timeout-minutes: 10 + name: '3 / Build' + + steps: + - uses: actions/checkout@v4 + + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 8.0.x + 10.0.x + + - name: Build + run: .\build.ps1 diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index d801df2e..89ad3c95 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,10 +1,7 @@ -name: Tests +name: Tests on: - push: - branches: [ develop, main ] - pull_request: - branches: [ develop, main ] + workflow_call: concurrency: group: integration-tests-${{ github.ref }} @@ -12,7 +9,7 @@ concurrency: jobs: tests: - name: Integration Tests (${{ matrix.os }} / Electron ${{ matrix.electronVersion }}) + name: ${{ matrix.os }} API-${{ matrix.electronVersion }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -45,6 +42,13 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Random delay (0-20 seconds) + shell: bash + run: | + DELAY=$((RANDOM % 21)) + echo "Waiting for $DELAY seconds..." + sleep $DELAY + - name: Setup .NET uses: actions/setup-dotnet@v4 with: diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 862f1c75..23dac1fc 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -2,7 +2,7 @@ name: Create PR Comments on: workflow_run: - workflows: ["Tests"] + workflows: [ "PR Validation" ] types: [completed] permissions: @@ -14,7 +14,7 @@ jobs: pr-comment: name: Post Test Result as PR comment runs-on: ubuntu-24.04 - if: github.event.workflow_run.event == 'pull_request' + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion != 'cancelled' steps: - name: Download CTRF artifact diff --git a/.github/workflows/retry-test-jobs.yml b/.github/workflows/retry-test-jobs.yml new file mode 100644 index 00000000..1fd0342c --- /dev/null +++ b/.github/workflows/retry-test-jobs.yml @@ -0,0 +1,50 @@ +name: Tests auto-rerun + +on: + workflow_run: + workflows: [ "PR Validation", "Build and Publish" ] + types: [ completed ] + +jobs: + rerun-failed-matrix-jobs-once: + if: > + ${{ + github.event.workflow_run.conclusion == 'failure' && + github.event.workflow_run.run_attempt == 1 + }} + runs-on: ubuntu-24.04 + + permissions: + actions: write + contents: read + + steps: + - name: Decide whether to rerun (only if matrix jobs failed) + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + RUN_ID: ${{ github.event.workflow_run.id }} + run: | + echo "Inspecting jobs of workflow run $RUN_ID in $REPO" + + jobs_json="$(gh api repos/$REPO/actions/runs/$RUN_ID/jobs)" + + echo "Jobs and conclusions:" + echo "$jobs_json" | jq '.jobs[] | {name: .name, conclusion: .conclusion}' + + failed_matrix_jobs=$(echo "$jobs_json" | jq ' + [ .jobs[] + | select(.conclusion == "failure" + and (.name | contains(" API-"))) + ] + | length + ') + + echo "Failed Integration Tests matrix jobs: $failed_matrix_jobs" + + if [ "$failed_matrix_jobs" -gt 0 ]; then + echo "Detected failing Integration Tests jobs – re-running failed jobs for this run." + gh run rerun "$RUN_ID" --failed + else + echo "Only non-matrix jobs (like Test Results) failed – not auto-rerunning." + fi diff --git a/.github/workflows/trailing-whitespace-check.yml b/.github/workflows/trailing-whitespace-check.yml index 299bb98f..9b8c7799 100644 --- a/.github/workflows/trailing-whitespace-check.yml +++ b/.github/workflows/trailing-whitespace-check.yml @@ -1,11 +1,10 @@ -name: Trailing Whitespace Check +name: Whitespace Check on: - pull_request: - types: [opened, synchronize, reopened] + workflow_call: jobs: - check-trailing-whitespace: + check-whitespace: runs-on: ubuntu-latest permissions: contents: read diff --git a/src/ElectronNET.sln b/src/ElectronNET.sln index 961cf9ce..eb20f10e 100644 --- a/src/ElectronNET.sln +++ b/src/ElectronNET.sln @@ -41,10 +41,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test Apps", "Test Apps", "{ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{985D39A7-5216-4945-8167-2FD0CB387BD8}" ProjectSection(SolutionItems) = preProject - ..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml + ..\.github\workflows\Build and Publish.yml = ..\.github\workflows\Build and Publish.yml ..\.github\workflows\integration-tests.yml = ..\.github\workflows\integration-tests.yml + ..\.github\workflows\PR Validation.yml = ..\.github\workflows\PR Validation.yml ..\.github\workflows\pr-comment.yml = ..\.github\workflows\pr-comment.yml ..\.github\workflows\publish-wiki.yml = ..\.github\workflows\publish-wiki.yml + ..\.github\workflows\retry-test-jobs.yml = ..\.github\workflows\retry-test-jobs.yml ..\.github\workflows\trailing-whitespace-check.yml = ..\.github\workflows\trailing-whitespace-check.yml EndProjectSection EndProject