Skip to content

Commit 2937c64

Browse files
fix: adjusting the pipeline file
1 parent e347841 commit 2937c64

2 files changed

Lines changed: 72 additions & 29 deletions

File tree

.github/workflows/k6-test.yml

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,92 @@ on:
77
pull_request:
88

99
jobs:
10-
k6-tests:
10+
build:
11+
name: Build
1112
runs-on: ubuntu-latest
12-
1313
steps:
1414
- name: Checkout repository
1515
uses: actions/checkout@v4
1616

17-
- name: Install k6 v1.2.2
18-
run: |
19-
K6_VERSION=1.2.2
20-
URL="https://github.com/grafana/k6/releases/download/v${K6_VERSION}/k6-v${K6_VERSION}-linux-amd64.tar.gz"
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '18'
2121

22-
echo "Downloading $URL"
23-
curl -sLo k6.tar.gz "$URL"
22+
- name: Install project dev dependencies
23+
run: |
24+
npm ci
2425
25-
echo "Extracting..."
26-
tar -xzf k6.tar.gz
27-
sudo mv "k6-v${K6_VERSION}-linux-amd64/k6" /usr/local/bin/k6
28-
sudo chmod +x /usr/local/bin/k6
29-
rm -rf k6.tar.gz "k6-v${K6_VERSION}-linux-amd64"
26+
- name: Upload node_modules
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: node_modules
30+
path: node_modules
3031

31-
echo "k6 version:"
32-
k6 version
32+
test:
33+
name: Test
34+
runs-on: ubuntu-latest
35+
needs: build
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
3339

34-
- name: Setup Node.js
35-
uses: actions/setup-node@v4
40+
- name: Download node_modules from build
41+
uses: actions/download-artifact@v3
3642
with:
37-
node-version: "18"
43+
name: node_modules
44+
path: ./
3845

39-
- name: Install project dev dependencies
46+
- name: Verify npm
4047
run: |
41-
npm install
48+
node --version || true
49+
npm --version || true
4250
43-
- name: Run k6 tests (direct .ts)
51+
- name: Install k6 v1.2.2
52+
run: |
53+
sudo apt-get update
54+
sudo apt-get install -y ca-certificates curl tar
55+
K6_VERSION=1.2.2
56+
curl -sLo k6.tar.gz "https://dl.k6.io/releases/v${K6_VERSION}/k6-v${K6_VERSION}-linux64.tar.gz"
57+
tar -xzf k6.tar.gz
58+
sudo mv "k6-v${K6_VERSION}-linux64/k6" /usr/local/bin/k6
59+
rm -rf k6.tar.gz "k6-v${K6_VERSION}-linux64"
60+
61+
- name: Run k6 tests
4462
run: |
4563
mkdir -p results
46-
# Run the test suite using the same command you use locally.
47-
# Pass through k6 args after `--` to npm so we can capture results JSON.
48-
npm run test:suite -- --out json=results/output.json
49-
if [ -f report.html ]; then mv report.html results/; fi
64+
npm run test:suite -- --out json=results/output.json || true
65+
# Copy any generated HTML reports from src/tests into results/
66+
if [ -d src/tests ] && ls src/tests/*.html 1> /dev/null 2>&1; then cp src/tests/*.html results/ || true; fi
67+
# Also capture any report.html in the workspace root
68+
if [ -f report.html ]; then cp report.html results/; fi
5069
5170
- name: Upload results
5271
uses: actions/upload-artifact@v4
5372
with:
5473
name: k6-results
5574
path: results/
75+
76+
deploy:
77+
name: Deploy
78+
runs-on: ubuntu-latest
79+
needs: test
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@v4
83+
84+
- name: Download test results
85+
uses: actions/download-artifact@v3
86+
with:
87+
name: k6-results
88+
path: results
89+
90+
- name: List results
91+
run: |
92+
echo "Files in results:" && ls -la results || true
93+
94+
- name: Upload final artifacts (results + report)
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: final-results
98+
path: results/

src/tests/suite.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export let options = {
1818
preAllocatedVUs: 5,
1919
maxVUs: 10,
2020
stages: [
21-
{ target: 10, duration: '30s' },
22-
{ target: 0, duration: '10s' }
21+
{ target: 10, duration: '15s' },
22+
{ target: 5, duration: '10s' }
2323
],
2424
},
2525

@@ -30,8 +30,8 @@ export let options = {
3030
preAllocatedVUs: 5,
3131
maxVUs: 10,
3232
stages: [
33-
{ target: 10, duration: '30s' },
34-
{ target: 0, duration: '10s' }
33+
{ target: 10, duration: '15s' },
34+
{ target: 5, duration: '10s' }
3535
],
3636
},
3737
},

0 commit comments

Comments
 (0)