-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
188 lines (179 loc) · 7.81 KB
/
action.yml
File metadata and controls
188 lines (179 loc) · 7.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: 'Run RapiseLauncher on Windows'
description: 'Install Rapise & Run Spira Test Sets using RapiseLauncher on Windows'
author: 'Inflectra'
branding:
icon: 'play-circle'
color: 'blue'
inputs:
spira_config:
description: 'Path to existing RepositoryConnection.xml config file. When provided, spira_url/spira_username/spira_api_key/spira_automation_host are not needed.'
required: false
default: ''
spira_url:
description: 'Spira server URL. Short form: https://server/ (requires spira_project_id and spira_test_set_id). Full form: https://server/9/TestSet/925.aspx (project_id and test_set_id extracted automatically).'
required: true
default: 'https://myserver.spiraservice.net/'
spira_username:
description: 'Spira username. Not needed if spira_config is set.'
required: true
default: 'myuser'
spira_api_key:
description: 'Spira API key (RSS Token). Not needed if spira_config is set.'
required: true
default: '{00000000-0000-0000-0000-000000000000}'
spira_project_id:
description: 'Spira Product/Project ID. Optional.'
required: false
default: ''
spira_test_set_id:
description: 'Spira Test Set ID. May be an array, i.e. "1,3,15" to execute several test sets. Not needed if spira_url contains the full test set path.'
required: true
default: ''
spira_automation_host:
description: 'Automation Host Token defined for a given project'
required: true
default: 'GHA'
install_rapise:
description: 'Whether Rapise needs to be installed'
required: false
default: 'true'
rapise_version:
description: 'Rapise version to install'
required: false
default: '9.0.35.37'
set_screen_size:
description: 'Set screen resolution for test execution'
required: false
default: 'false'
screen_width:
description: 'Screen width (1024..7680)'
required: false
default: '1920'
screen_height:
description: 'Screen height (768..4320)'
required: false
default: '1080'
record_video:
description: 'Record video of execution and upload to Spira Test Run'
required: false
default: 'false'
record_video_options:
description: 'Video recording options'
required: false
default: '-noaudio -bitRate 512 -frameRate 2'
capture_screenshots:
description: 'Capture screenshots before and after test execution'
required: false
default: 'true'
upload_artifacts:
description: 'Upload artifacts (screenshots, logs, trp/tap files) after execution'
required: false
default: 'true'
timeout_minutes:
description: 'Timeout in minutes for RapiseLauncher execution. 0 means no timeout.'
required: false
default: '0'
git_root:
description: 'Path to Git project (for Spira tests stored in Git)'
required: false
default: ''
report:
description: 'Path to file for JUnit XML results output'
required: false
default: 'rapise-test-results.xml'
runs:
using: 'composite'
steps:
- name: Screenshot before Rapise
if: inputs.capture_screenshots == 'true'
shell: pwsh
run: |
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
$bmp = New-Object System.Drawing.Bitmap($bounds.Width, $bounds.Height)
$graphics = [System.Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size)
$graphics.Dispose()
$bmp.Save("$env:RUNNER_TEMP\screenshot-before.png")
$bmp.Dispose()
- name: Install Rapise
if: inputs.install_rapise == 'true'
shell: pwsh
run: |
& "${{ github.action_path }}/scripts/RapiseInstall.ps1" -RapiseVersion "${{ inputs.rapise_version }}"
- name: Run Rapise Test Set
shell: pwsh
run: |
& "${{ github.action_path }}/scripts/task.ps1"
env:
INPUT_SPIRA_CONFIG: ${{ inputs.spira_config }}
INPUT_SPIRA_URL: ${{ inputs.spira_url }}
INPUT_SPIRA_USERNAME: ${{ inputs.spira_username }}
INPUT_SPIRA_API_KEY: ${{ inputs.spira_api_key }}
INPUT_SPIRA_PROJECT_ID: ${{ inputs.spira_project_id }}
INPUT_SPIRA_TEST_SET_ID: ${{ inputs.spira_test_set_id }}
INPUT_SPIRA_AUTOMATION_HOST: ${{ inputs.spira_automation_host }}
INPUT_SET_SCREEN_SIZE: ${{ inputs.set_screen_size }}
INPUT_SCREEN_WIDTH: ${{ inputs.screen_width }}
INPUT_SCREEN_HEIGHT: ${{ inputs.screen_height }}
INPUT_RECORD_VIDEO: ${{ inputs.record_video }}
INPUT_RECORD_VIDEO_OPTIONS: ${{ inputs.record_video_options }}
INPUT_TIMEOUT_MINUTES: ${{ inputs.timeout_minutes }}
INPUT_GIT_ROOT: ${{ inputs.git_root }}
INPUT_REPORT: ${{ inputs.report }}
- name: Screenshot after Rapise
if: always() && inputs.capture_screenshots == 'true'
shell: pwsh
run: |
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
$bmp = New-Object System.Drawing.Bitmap($bounds.Width, $bounds.Height)
$graphics = [System.Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size)
$graphics.Dispose()
$bmp.Save("$env:RUNNER_TEMP\screenshot-after.png")
$bmp.Dispose()
- name: Collect artifacts
if: always() && inputs.upload_artifacts == 'true'
shell: pwsh
run: |
$artifactDir = "$env:RUNNER_TEMP\rapise-results"
New-Item -ItemType Directory -Path $artifactDir -Force
Copy-Item "$env:RUNNER_TEMP\screenshot-before.png" $artifactDir -ErrorAction SilentlyContinue
Copy-Item "$env:RUNNER_TEMP\screenshot-after.png" $artifactDir -ErrorAction SilentlyContinue
# Copy the JUnit XML report
$reportPath = "${{ inputs.report }}"
if ($reportPath -and (Test-Path $reportPath)) {
Copy-Item $reportPath $artifactDir -ErrorAction SilentlyContinue
}
if (Test-Path "C:\ProgramData\Inflectra\Rapise\Logs") {
Copy-Item "C:\ProgramData\Inflectra\Rapise\Logs\*" $artifactDir -Recurse -ErrorAction SilentlyContinue
}
# Using dynamic GitHub workspace path
if (Test-Path "$env:GITHUB_WORKSPACE") {
# We copy to a subfolder named 'workspace_files' to keep the artifact clean
$destDir = "$artifactDir\workspace_files"
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
Get-ChildItem -Path "$env:GITHUB_WORKSPACE" -Recurse -Include *.trp, *.tap, *.log, *.wmv -File | ForEach-Object {
$relativePath = $_.FullName.Substring("$env:GITHUB_WORKSPACE".Length)
$targetPath = Join-Path $destDir $relativePath
$targetDir = Split-Path $targetPath -Parent
if (-not (Test-Path $targetDir)) { New-Item -ItemType Directory -Path $targetDir -Force | Out-Null }
Copy-Item $_.FullName $targetPath -ErrorAction SilentlyContinue
}
}
if (Test-Path "$env:ALLUSERSPROFILE\Inflectra\Rapise\Temp") {
# We copy to a subfolder named 'temp_files' to keep the artifact clean
$destDir = "$artifactDir\temp_files"
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
Copy-Item "$env:ALLUSERSPROFILE\Inflectra\Rapise\*" $destDir -Recurse -ErrorAction SilentlyContinue
}
- name: Upload artifacts
if: always() && inputs.upload_artifacts == 'true'
uses: actions/upload-artifact@v4
with:
name: rapise-results
path: ${{ runner.temp }}/rapise-results
if-no-files-found: warn