|
7 | 7 | pull_request: |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - k6-tests: |
| 10 | + build: |
| 11 | + name: Build |
11 | 12 | runs-on: ubuntu-latest |
12 | | - |
13 | 13 | steps: |
14 | 14 | - name: Checkout repository |
15 | 15 | uses: actions/checkout@v4 |
16 | 16 |
|
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' |
21 | 21 |
|
22 | | - echo "Downloading $URL" |
23 | | - curl -sLo k6.tar.gz "$URL" |
| 22 | + - name: Install project dev dependencies |
| 23 | + run: | |
| 24 | + npm ci |
24 | 25 |
|
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 |
30 | 31 |
|
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 |
33 | 39 |
|
34 | | - - name: Setup Node.js |
35 | | - uses: actions/setup-node@v4 |
| 40 | + - name: Download node_modules from build |
| 41 | + uses: actions/download-artifact@v3 |
36 | 42 | with: |
37 | | - node-version: "18" |
| 43 | + name: node_modules |
| 44 | + path: ./ |
38 | 45 |
|
39 | | - - name: Install project dev dependencies |
| 46 | + - name: Verify npm |
40 | 47 | run: | |
41 | | - npm install |
| 48 | + node --version || true |
| 49 | + npm --version || true |
42 | 50 |
|
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 |
44 | 62 | run: | |
45 | 63 | 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 |
50 | 69 |
|
51 | 70 | - name: Upload results |
52 | 71 | uses: actions/upload-artifact@v4 |
53 | 72 | with: |
54 | 73 | name: k6-results |
55 | 74 | 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/ |
0 commit comments