Skip to content

Commit 7d08a94

Browse files
added cicd docs (#102)
1 parent bc1bd31 commit 7d08a94

File tree

4 files changed

+245
-3
lines changed

4 files changed

+245
-3
lines changed
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
---
2+
sidebar_position: 6
3+
---
4+
5+
# CI/CD
6+
**qavajs**, is CI/CD agnostic and can be executed in any environment that satisfies following requirements:
7+
- [nodejs](https://nodejs.org/en) with npm > 18
8+
- installed browsers (for UI testing)
9+
10+
## General Approach for qavajs in CI/CD:
11+
The core idea for integrating qavajs into any CI/CD pipeline is to execute a command that runs your qavajs tests. This usually involves:
12+
13+
- Checkout Code: Get your qavajs project from the repository.
14+
- Install Dependencies: Run npm install (or yarn install) to install all project dependencies, including qavajs and its related packages.
15+
- Set up Environment (if needed): Configure any environment variables required for your tests (e.g., BASE_URL, API keys).
16+
- Run Tests: Execute the qavajs test command, typically defined in your package.json scripts (e.g., npm test).
17+
- Generate Reports: Configure qavajs to generate reports (e.g., HTML, JUnit XML) that can be published or viewed within the CI/CD system.
18+
- Publish Test Results (optional but recommended): Upload generated reports to the CI/CD platform's test reporting features for better visibility.
19+
20+
## GitHub Actions
21+
GitHub Actions uses YAML files (.github/workflows/*.yml) to define workflows.
22+
23+
Example qavajs-tests.yml workflow:
24+
25+
```yaml
26+
name: qavajs E2E Tests
27+
28+
on:
29+
workflow-dispatch:
30+
31+
jobs:
32+
run-qavajs-tests:
33+
runs-on: ubuntu-latest # Or windows-latest, macos-latest
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Set up Node.js
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: '22' # Use your preferred Node.js version
43+
44+
- name: Install dependencies
45+
run: npm install
46+
47+
- name: Install Google Chrome (for UI tests)
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get install -y google-chrome-stable
51+
52+
- name: Run qavajs tests
53+
run: npm test # Or whatever script you define in package.json to run your qavajs tests
54+
env:
55+
# Example of setting environment variables
56+
# BASE_URL: ${{ secrets.BASE_URL }}
57+
# Some other variable: 'value'
58+
59+
- name: Upload test results (e.g., JUnit XML)
60+
if: always() # Run this step even if previous steps fail
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: qavajs-test-results
64+
path: ./reports/junit-report.xml # Adjust path to your generated report
65+
```
66+
67+
## Azure DevOps Pipelines
68+
Azure DevOps uses YAML files (azure-pipelines.yml) for pipelines.
69+
70+
Example azure-pipelines.yml:
71+
72+
```yaml
73+
trigger:
74+
- main
75+
- develop
76+
77+
pool:
78+
vmImage: 'ubuntu-latest' # Or 'windows-latest', 'macOS-latest'
79+
80+
steps:
81+
- task: NodeTool@0
82+
inputs:
83+
versionSpec: '22.x' # Use your preferred Node.js version
84+
displayName: 'Install Node.js'
85+
86+
- script: |
87+
npm install
88+
displayName: 'Install Dependencies'
89+
90+
- script: |
91+
sudo apt-get update
92+
sudo apt-get install -y google-chrome-stable
93+
displayName: 'Install Google Chrome'
94+
condition: eq(variables['Agent.OS'], 'Linux') # Only run on Linux agents
95+
96+
- script: |
97+
npm test # Or your qavajs test command
98+
displayName: 'Run qavajs Tests'
99+
env:
100+
# Example of setting environment variables
101+
# BASE_URL: $(BASE_URL) # Use pipeline variables or variable groups
102+
# Some other variable: 'value'
103+
104+
- task: PublishTestResults@2
105+
inputs:
106+
testResultsFormat: 'JUnit'
107+
testResultsFiles: '**/junit-report.xml' # Adjust path to your generated report
108+
mergeResults: true
109+
failTaskOnFailedTests: true # Fail the pipeline if tests fail
110+
displayName: 'Publish Test Results'
111+
112+
- task: PublishBuildArtifacts@1
113+
inputs:
114+
pathToPublish: 'reports' # Path to your reports directory
115+
artifactName: 'qavajsTestReports'
116+
displayName: 'Publish qavajs Reports'
117+
```
118+
119+
## GitLab CI/CD
120+
GitLab CI/CD uses a .gitlab-ci.yml file at the root of your repository.
121+
122+
Example .gitlab-ci.yml:
123+
124+
```yaml
125+
stages:
126+
- test
127+
128+
variables:
129+
# Example of setting global environment variables
130+
# BASE_URL: "http://your-app.com"
131+
132+
test_qavajs:
133+
stage: test
134+
image: node:22 # Use a Node.js image
135+
before_script:
136+
- apt-get update && apt-get install -y google-chrome-stable # Install Chrome if needed
137+
- npm install
138+
script:
139+
- npm test # Your qavajs test command
140+
artifacts:
141+
when: always
142+
reports:
143+
junit: "**/junit-report.xml" # Path to your JUnit report
144+
paths:
145+
- reports/ # Path to your reports directory (e.g., HTML reports)
146+
```
147+
148+
## Jenkins
149+
Jenkins uses a Jenkinsfile (Groovy script) for Pipeline as Code.
150+
151+
Example Jenkinsfile (Declarative Pipeline):
152+
153+
```groovy
154+
pipeline {
155+
agent {
156+
docker {
157+
image 'node:22' // Use a Node.js Docker image
158+
args '-v /tmp:/tmp' // Mount host volume if needed for browser setup
159+
}
160+
}
161+
// Alternatively, for a Freestyle project, configure build steps directly in the UI.
162+
// For a traditional agent:
163+
// agent any
164+
165+
environment {
166+
# Example of setting environment variables
167+
# BASE_URL = 'http://your-app.com'
168+
}
169+
170+
stages {
171+
stage('Checkout') {
172+
steps {
173+
checkout scm
174+
}
175+
}
176+
177+
stage('Install Dependencies') {
178+
steps {
179+
script {
180+
sh 'npm install'
181+
}
182+
}
183+
}
184+
185+
stage('Install Chrome (if needed)') {
186+
steps {
187+
script {
188+
// Commands to install Google Chrome on the agent
189+
// This will depend on the base OS of your Jenkins agent or Docker image
190+
// For Debian/Ubuntu based systems in a Docker image:
191+
sh '''
192+
apt-get update && apt-get install -y \
193+
wget \
194+
gnupg \
195+
apt-transport-https \
196+
ca-certificates && \
197+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
198+
echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
199+
apt-get update && \
200+
apt-get install -y google-chrome-stable
201+
'''
202+
// For other OS, adapt the commands.
203+
}
204+
}
205+
}
206+
207+
stage('Run qavajs Tests') {
208+
steps {
209+
script {
210+
sh 'npm test' // Your qavajs test command
211+
}
212+
}
213+
}
214+
215+
stage('Publish Test Results') {
216+
steps {
217+
script {
218+
// Assuming qavajs generates a JUnit XML report
219+
junit '**/junit-report.xml' // Path to your JUnit report
220+
}
221+
// Publish other artifacts like HTML reports
222+
archiveArtifacts artifacts: 'reports/**/*', fingerprint: true
223+
}
224+
}
225+
}
226+
227+
post {
228+
always {
229+
// Clean up any temporary files or directories if needed
230+
script {
231+
echo 'Cleaning up workspace...'
232+
}
233+
}
234+
success {
235+
echo 'qavajs tests completed successfully!'
236+
}
237+
failure {
238+
echo 'qavajs tests failed!'
239+
}
240+
}
241+
}
242+
```

versioned_docs/version-2x/Guides/vscode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 7
2+
sidebar_position: 28
33
---
44
# Visual Studio Code
55

versioned_docs/version-2x/Guides/wdio-adapter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 4
2+
sidebar_position: 29
33
---
44

55
# WDIO Adapter

versioned_docs/version-2x/Guides/webstorm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 6
2+
sidebar_position: 30
33
---
44
# Webstorm
55
qavajs can be integrated with Webstorm using built-in cucumberjs plugin.

0 commit comments

Comments
 (0)