Skip to content

Commit 05f80bd

Browse files
authored
Refactor command handler and tests workflow (#161)
test(github-action): refactor command handler Refactor command handler workflow to use bot name from secrets. refactor(codeowners): add more codeowners for '.github' folder test(validation): replace `yml` validation script Replace `.pubnub.yml` validation script with call of custom validation action. refactor(workflow): refactor tests workflow Unify integration and acceptance test workflow files into one. build(release): upload test results Upload test results for feature analysis. test(github-action): add fast failure Add ability to cancel whole test workflow if any of jobs failed.
1 parent a4df5d4 commit 05f80bd

File tree

9 files changed

+168
-222
lines changed

9 files changed

+168
-222
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* @budgetpreneur @MikeDobrzan @mohitpubnub
1+
* @budgetpreneur @MikeDobrzan @mohitpubnub
2+
.github @parfeon @budgetpreneur @MikeDobrzan @mohitpubnub
23
README.md @techwritermat
3-
.github @parfeon
44

.github/workflows/commands-handler.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,41 @@ name: Commands processor
33
on:
44
issue_comment:
55
types: [created]
6+
defaults:
7+
run:
8+
shell: bash
69

710
jobs:
811
process:
912
name: Process command
10-
if: ${{ github.event.issue.pull_request && endsWith(github.repository, '-private') != true && startsWith(github.event.comment.body, '@client-engineering-bot ') }}
13+
if: github.event.issue.pull_request && endsWith(github.repository, '-private') != true
1114
runs-on: ubuntu-latest
1215
steps:
16+
- name: Check referred user
17+
id: user-check
18+
env:
19+
CLEN_BOT: ${{ secrets.CLEN_BOT }}
20+
run: echo "expected-user=${{ startsWith(github.event.comment.body, format('@{0} ', env.CLEN_BOT)) }}" >> $GITHUB_OUTPUT
21+
- name: Regular comment
22+
if: steps.user-check.outputs.expected-user != 'true'
23+
run: echo -e "\033[38;2;19;181;255mThis is regular commit which should be ignored.\033[0m"
1324
- name: Checkout repository
14-
uses: actions/checkout@v2
25+
if: steps.user-check.outputs.expected-user == 'true'
26+
uses: actions/checkout@v3
27+
with:
28+
token: ${{ secrets.GH_TOKEN }}
1529
- name: Checkout release actions
16-
uses: actions/checkout@v2
30+
if: steps.user-check.outputs.expected-user == 'true'
31+
uses: actions/checkout@v3
1732
with:
1833
repository: pubnub/client-engineering-deployment-tools
1934
ref: v1
2035
token: ${{ secrets.GH_TOKEN }}
2136
path: .github/.release/actions
2237
- name: Process changelog entries
38+
if: steps.user-check.outputs.expected-user == 'true'
2339
uses: ./.github/.release/actions/actions/commands
2440
with:
2541
token: ${{ secrets.GH_TOKEN }}
26-
listener: client-engineering-bot
42+
listener: ${{ secrets.CLEN_BOT }}
2743
jira-api-key: ${{ secrets.JIRA_API_KEY }}

.github/workflows/release.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ jobs:
1010
check-release:
1111
name: Check release required
1212
runs-on: ubuntu-latest
13-
if: ${{ github.event.pull_request.merged && endsWith(github.repository, '-private') != true }}
13+
if: github.event.pull_request.merged && endsWith(github.repository, '-private') != true
1414
outputs:
1515
release: ${{ steps.check.outputs.ready }}
1616
steps:
1717
- name: Checkout actions
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919
with:
2020
repository: pubnub/client-engineering-deployment-tools
2121
ref: v1
@@ -30,40 +30,36 @@ jobs:
3030
name: Publish to NuGet
3131
runs-on: windows-2019
3232
needs: check-release
33-
if: ${{ needs.check-release.outputs.release == 'true' }}
33+
if: needs.check-release.outputs.release == 'true'
34+
defaults:
35+
run:
36+
shell: powershell
3437
steps:
3538
- name: Checkout repository
36-
uses: actions/checkout@v2
39+
uses: actions/checkout@v3
3740
with:
3841
# This should be the same as the one specified for on.pull_request.branches
3942
ref: master
4043
- name: Add msbuild to PATH
4144
uses: microsoft/[email protected]
42-
- name: Setup .NET 2.1.519
43-
uses: actions/setup-dotnet@v1
44-
with:
45-
dotnet-version: 2.1.519
46-
- name: Setup .NET 5.0.x
47-
uses: actions/setup-dotnet@v1
45+
- name: Setup .NET
46+
uses: actions/setup-dotnet@v3
4847
with:
49-
dotnet-version: 5.0.x
50-
- name: Setup .NET 6.0.x
51-
uses: actions/setup-dotnet@v1
52-
with:
53-
dotnet-version: 6.0.x
48+
dotnet-version: |
49+
2.1.519
50+
5.0.x
51+
6.0.x
5452
- name: Build packages
5553
env:
5654
WORKSPACE_PATH: ${{ github.workspace }}
5755
run: .\\.github\\workflows\\release\\build-packages.ps1
58-
shell: powershell
5956
- name: Publish packages
6057
env:
6158
WORKSPACE_PATH: ${{ github.workspace }}
6259
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
6360
run: .\\.github\\workflows\\release\\publish-packages.ps1
64-
shell: powershell
6561
- name: Upload artifacts
66-
uses: actions/upload-artifact@v2
62+
uses: actions/upload-artifact@v3
6763
with:
6864
name: nuget-packages
6965
path: ${{ github.workspace }}\.github\.release\artifacts\*.nupkg
@@ -72,22 +68,21 @@ jobs:
7268
name: Publish package
7369
runs-on: ubuntu-latest
7470
needs: publish-nuget
75-
if: ${{ needs.check-release.outputs.release == 'true' }}
7671
steps:
7772
- name: Checkout repository
78-
uses: actions/checkout@v2
73+
uses: actions/checkout@v3
7974
with:
8075
# This should be the same as the one specified for on.pull_request.branches
8176
ref: master
8277
- name: Checkout actions
83-
uses: actions/checkout@v2
78+
uses: actions/checkout@v3
8479
with:
8580
repository: pubnub/client-engineering-deployment-tools
8681
ref: v1
8782
token: ${{ secrets.GH_TOKEN }}
8883
path: .github/.release/actions
8984
- name: Download artifacts
90-
uses: actions/download-artifact@v2
85+
uses: actions/download-artifact@v3
9186
with:
9287
name: nuget-packages
9388
path: ${{ github.workspace }}/.github/.release/artifacts
@@ -97,3 +92,8 @@ jobs:
9792
token: ${{ secrets.GH_TOKEN }}
9893
jira-api-key: ${{ secrets.JIRA_API_KEY }}
9994
last-service: true
95+
- name: Upload test reports
96+
uses: ./.github/.release/actions/actions/test-reports/upload
97+
with:
98+
token: ${{ secrets.GH_TOKEN }}
99+
acceptance-tests-workflow: Tests

.github/workflows/release/build-packages.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ $githubWorkspace = $env:WORKSPACE_PATH
44
# Create required directory structure.
55
$RELEASES_PATH = "$githubWorkspace\.github\.release"
66
$ARTIFACTS_PATH = "$RELEASES_PATH\artifacts"
7-
mkdir "$RELEASES_PATH"
8-
mkdir "$ARTIFACTS_PATH"
7+
if (!(Test-Path "$RELEASES_PATH")) {
8+
mkdir "$RELEASES_PATH"
9+
}
10+
if (!(Test-Path "$ARTIFACTS_PATH")) {
11+
mkdir "$ARTIFACTS_PATH"
12+
}
913

1014
# Build Api package.
1115
echo "Build Api package"

.github/workflows/run-tests.yml

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,99 @@ name: Tests
22

33
on:
44
push:
5-
branches-ignore:
6-
- 'master'
75
workflow_dispatch:
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
89

910
jobs:
1011
tests:
11-
name: NuGet packages build
12+
name: Integration and Unit tests
1213
runs-on: windows-2019
14+
defaults:
15+
run:
16+
shell: powershell
1317
steps:
1418
- name: Checkout repository
1519
uses: actions/checkout@v2
16-
- name: Add msbuild to PATH
17-
uses: microsoft/[email protected]
18-
- name: Setup .NET 2.1.519
19-
uses: actions/setup-dotnet@v1
20-
with:
21-
dotnet-version: 2.1.519
22-
- name: Setup .NET 5.0.x
23-
uses: actions/setup-dotnet@v1
20+
- name: Checkout actions
21+
uses: actions/checkout@v3
2422
with:
25-
dotnet-version: 5.0.x
26-
- name: Setup .NET 6.0.x
27-
uses: actions/setup-dotnet@v1
23+
repository: pubnub/client-engineering-deployment-tools
24+
ref: v1
25+
token: ${{ secrets.GH_TOKEN }}
26+
path: .github/.release/actions
27+
- name: Add msbuild to PATH
28+
uses: microsoft/setup-msbuild@v1
29+
- name: Setup .NET
30+
uses: actions/setup-dotnet@v3
2831
with:
29-
dotnet-version: 6.0.x
32+
dotnet-version: |
33+
2.1.519
34+
5.0.x
35+
6.0.x
3036
- name: Build packages
3137
env:
3238
WORKSPACE_PATH: ${{ github.workspace }}
3339
run: .\\.github\\workflows\\release\\build-packages.ps1
40+
- name: Cancel workflow runs for commit on error
41+
if: failure()
42+
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
43+
acceptance-tests:
44+
name: Acceptance tests
45+
runs-on: windows-2019
46+
defaults:
47+
run:
3448
shell: powershell
49+
working-directory: ./src
50+
steps:
51+
- name: Checkout Project
52+
uses: actions/checkout@v3
53+
- name: Checkout mock-server action
54+
uses: actions/checkout@v3
55+
with:
56+
repository: pubnub/client-engineering-deployment-tools
57+
ref: v1
58+
token: ${{ secrets.GH_TOKEN }}
59+
path: .github/.release/actions
60+
- name: Run mock server action
61+
uses: ./.github/.release/actions/actions/mock-server
62+
with:
63+
token: ${{ secrets.GH_TOKEN }}
64+
- name: Setup .NET 6.0.x
65+
uses: actions/setup-dotnet@v1
66+
with:
67+
dotnet-version: 6.0.x
68+
- name: Restore dependencies
69+
run: dotnet restore
70+
- name: Build Projects
71+
run: |
72+
cd ./UnitTests/AcceptanceTests
73+
dotnet build --no-restore
74+
- name: Run acceptance tests
75+
env:
76+
PN_PUB_KEY: ${{ secrets.PN_PUB_KEY }}
77+
PN_SUB_KEY: ${{ secrets.PN_SUB_KEY }}
78+
PN_SEC_KEY: ${{ secrets.PN_SEC_KEY }}
79+
run: |
80+
Copy-Item -Path "${{ github.workspace }}/sdk-specifications/features/access/*" -Destination "${{ github.workspace }}/src/UnitTests/AcceptanceTests/Features" -Recurse
81+
cd ./UnitTests/AcceptanceTests
82+
dotnet test --no-build --verbosity normal --logger trx --results-directory ./results
83+
- name: Upload acceptance tests reports
84+
if: always()
85+
uses: actions/upload-artifact@v3
86+
with:
87+
name: acceptance-test-reports
88+
path: |
89+
${{ github.workspace }}/src/UnitTests/AcceptanceTests/Features/
90+
${{ github.workspace }}/src/UnitTests/AcceptanceTests/results/
91+
- name: Cancel workflow runs for commit on error
92+
if: failure()
93+
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
94+
all-tests:
95+
name: Tests
96+
runs-on: ubuntu-latest
97+
needs: [tests, acceptance-tests]
98+
steps:
99+
- name: Tests summary
100+
run: echo -e "\033[38;2;95;215;0m\033[1mAll tests successfully passed"

.github/workflows/run-validations.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Validations
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
pubnub-yml:
12+
name: "Validate .pubnub.yml"
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout project
16+
uses: actions/checkout@v3
17+
- name: Checkout validator action
18+
uses: actions/checkout@v3
19+
with:
20+
repository: pubnub/client-engineering-deployment-tools
21+
ref: v1
22+
token: ${{ secrets.GH_TOKEN }}
23+
path: .github/.release/actions
24+
- name: "Run '.pubnub.yml' file validation"
25+
uses: ./.github/.release/actions/actions/validators/pubnub-yml
26+
with:
27+
token: ${{ secrets.GH_TOKEN }}
28+
- name: Cancel workflow runs for commit on error
29+
if: failure()
30+
uses: ./.github/.release/actions/actions/utils/fast-jobs-failure
31+
all-validations:
32+
name: Validations
33+
runs-on: ubuntu-latest
34+
needs: [pubnub-yml]
35+
steps:
36+
- name: Validations summary
37+
run: echo -e "\033[38;2;95;215;0m\033[1mAll validations passed"

.github/workflows/run_acceptance_tests.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)