Skip to content

Commit 70e8f85

Browse files
authored
Merge pull request #977 from softworkz/submit_revertnet6
Combine and separate workflows
2 parents 33da428 + 5a7cbd9 commit 70e8f85

File tree

7 files changed

+119
-33
lines changed

7 files changed

+119
-33
lines changed
Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
1-
name: CI
1+
name: Build and Publish
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
env:
66
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
88

9-
jobs:
10-
# linux:
11-
# runs-on: ubuntu-latest
12-
# timeout-minutes: 10
13-
14-
# steps:
15-
# - uses: actions/checkout@v4
9+
concurrency:
10+
group: build-publish-${{ github.ref }}
11+
cancel-in-progress: true
1612

17-
# - name: Setup dotnet
18-
# uses: actions/setup-dotnet@v4
19-
# with:
20-
# dotnet-version: |
21-
# 6.0.x
22-
# 8.0.x
23-
# 10.0.x
24-
25-
# - name: Build
26-
# run: ./build.sh
13+
jobs:
14+
Integration-Tests:
15+
uses: ./.github/workflows/integration-tests.yml
16+
name: '1'
2717

28-
windows:
18+
Publish:
19+
needs: [Integration-Tests]
2920
runs-on: windows-latest
3021
timeout-minutes: 10
22+
name: '2 / Publish'
3123

3224
steps:
3325
- uses: actions/checkout@v4
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: PR Validation
2+
3+
on: [pull_request]
4+
5+
concurrency:
6+
group: pr-validation-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
Whitespace-Check:
11+
uses: ./.github/workflows/trailing-whitespace-check.yml
12+
secrets: inherit
13+
name: '1'
14+
15+
Tests:
16+
needs: Whitespace-Check
17+
uses: ./.github/workflows/integration-tests.yml
18+
secrets: inherit
19+
name: '2'
20+
21+
build:
22+
needs: [Whitespace-Check, Tests]
23+
runs-on: windows-latest
24+
timeout-minutes: 10
25+
name: '3 / Build'
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Setup dotnet
31+
uses: actions/setup-dotnet@v4
32+
with:
33+
dotnet-version: |
34+
6.0.x
35+
8.0.x
36+
10.0.x
37+
38+
- name: Build
39+
run: .\build.ps1

.github/workflows/integration-tests.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
name: Tests
1+
name: Tests
22

33
on:
4-
push:
5-
branches: [ develop, main ]
6-
pull_request:
7-
branches: [ develop, main ]
4+
workflow_call:
85

96
concurrency:
107
group: integration-tests-${{ github.ref }}
118
cancel-in-progress: true
129

1310
jobs:
1411
tests:
15-
name: Integration Tests (${{ matrix.os }} / Electron ${{ matrix.electronVersion }})
12+
name: ${{ matrix.os }} API-${{ matrix.electronVersion }}
1613
runs-on: ${{ matrix.os }}
1714
strategy:
1815
fail-fast: false
@@ -45,6 +42,13 @@ jobs:
4542
- name: Checkout
4643
uses: actions/checkout@v4
4744

45+
- name: Random delay (0-20 seconds)
46+
shell: bash
47+
run: |
48+
DELAY=$((RANDOM % 21))
49+
echo "Waiting for $DELAY seconds..."
50+
sleep $DELAY
51+
4852
- name: Setup .NET
4953
uses: actions/setup-dotnet@v4
5054
with:

.github/workflows/pr-comment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Create PR Comments
22

33
on:
44
workflow_run:
5-
workflows: ["Tests"]
5+
workflows: [ "PR Validation" ]
66
types: [completed]
77

88
permissions:
@@ -14,7 +14,7 @@ jobs:
1414
pr-comment:
1515
name: Post Test Result as PR comment
1616
runs-on: ubuntu-24.04
17-
if: github.event.workflow_run.event == 'pull_request'
17+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion != 'cancelled'
1818

1919
steps:
2020
- name: Download CTRF artifact
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Tests auto-rerun
2+
3+
on:
4+
workflow_run:
5+
workflows: [ "PR Validation", "Build and Publish" ]
6+
types: [ completed ]
7+
8+
jobs:
9+
rerun-failed-matrix-jobs-once:
10+
if: >
11+
${{
12+
github.event.workflow_run.conclusion == 'failure' &&
13+
github.event.workflow_run.run_attempt == 1
14+
}}
15+
runs-on: ubuntu-24.04
16+
17+
permissions:
18+
actions: write
19+
contents: read
20+
21+
steps:
22+
- name: Decide whether to rerun (only if matrix jobs failed)
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
REPO: ${{ github.repository }}
26+
RUN_ID: ${{ github.event.workflow_run.id }}
27+
run: |
28+
echo "Inspecting jobs of workflow run $RUN_ID in $REPO"
29+
30+
jobs_json="$(gh api repos/$REPO/actions/runs/$RUN_ID/jobs)"
31+
32+
echo "Jobs and conclusions:"
33+
echo "$jobs_json" | jq '.jobs[] | {name: .name, conclusion: .conclusion}'
34+
35+
failed_matrix_jobs=$(echo "$jobs_json" | jq '
36+
[ .jobs[]
37+
| select(.conclusion == "failure"
38+
and (.name | contains(" API-")))
39+
]
40+
| length
41+
')
42+
43+
echo "Failed Integration Tests matrix jobs: $failed_matrix_jobs"
44+
45+
if [ "$failed_matrix_jobs" -gt 0 ]; then
46+
echo "Detected failing Integration Tests jobs – re-running failed jobs for this run."
47+
gh run rerun "$RUN_ID" --failed
48+
else
49+
echo "Only non-matrix jobs (like Test Results) failed – not auto-rerunning."
50+
fi

.github/workflows/trailing-whitespace-check.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
name: Trailing Whitespace Check
1+
name: Whitespace Check
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened]
4+
workflow_call:
65

76
jobs:
8-
check-trailing-whitespace:
7+
check-whitespace:
98
runs-on: ubuntu-latest
109
permissions:
1110
contents: read

src/ElectronNET.sln

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test Apps", "Test Apps", "{
4141
EndProject
4242
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{985D39A7-5216-4945-8167-2FD0CB387BD8}"
4343
ProjectSection(SolutionItems) = preProject
44-
..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml
44+
..\.github\workflows\Build and Publish.yml = ..\.github\workflows\Build and Publish.yml
4545
..\.github\workflows\integration-tests.yml = ..\.github\workflows\integration-tests.yml
46+
..\.github\workflows\PR Validation.yml = ..\.github\workflows\PR Validation.yml
4647
..\.github\workflows\pr-comment.yml = ..\.github\workflows\pr-comment.yml
4748
..\.github\workflows\publish-wiki.yml = ..\.github\workflows\publish-wiki.yml
49+
..\.github\workflows\retry-test-jobs.yml = ..\.github\workflows\retry-test-jobs.yml
4850
..\.github\workflows\trailing-whitespace-check.yml = ..\.github\workflows\trailing-whitespace-check.yml
4951
EndProjectSection
5052
EndProject

0 commit comments

Comments
 (0)