|
8 | 8 |
|
9 | 9 | jobs: |
10 | 10 | build: |
11 | | - name: Build |
12 | 11 | runs-on: ubuntu-latest |
| 12 | + |
13 | 13 | steps: |
14 | 14 | - name: Checkout repository |
15 | 15 | uses: actions/checkout@v4 |
16 | 16 |
|
17 | 17 | - name: Setup Node.js |
18 | 18 | uses: actions/setup-node@v4 |
19 | 19 | with: |
20 | | - node-version: '18' |
21 | | - |
22 | | - - name: Install project dev dependencies |
23 | | - run: | |
24 | | - npm ci |
| 20 | + node-version: "18" |
25 | 21 |
|
26 | | - - name: Upload node_modules |
| 22 | + - name: Install dependencies |
| 23 | + run: npm install |
| 24 | + - name: Upload build artifacts |
27 | 25 | uses: actions/upload-artifact@v4 |
28 | 26 | with: |
29 | | - name: node_modules |
30 | | - path: node_modules |
| 27 | + name: build-artifacts |
| 28 | + path: | |
| 29 | + node_modules |
| 30 | + dist |
| 31 | + src/tests |
31 | 32 |
|
32 | 33 | test: |
33 | | - name: Test |
34 | 34 | runs-on: ubuntu-latest |
35 | 35 | needs: build |
| 36 | + |
36 | 37 | steps: |
37 | 38 | - name: Checkout repository |
38 | 39 | uses: actions/checkout@v4 |
39 | 40 |
|
40 | | - - name: Download node_modules from build |
| 41 | + - name: Download build artifacts |
41 | 42 | uses: actions/download-artifact@v4 |
42 | 43 | with: |
43 | | - name: node_modules |
44 | | - path: ./ |
45 | | - |
46 | | - - name: Verify npm |
47 | | - run: | |
48 | | - node --version || true |
49 | | - npm --version || true |
| 44 | + name: build-artifacts |
50 | 45 |
|
51 | 46 | - name: Install k6 v1.2.2 |
52 | 47 | run: | |
53 | | - sudo apt-get update |
54 | | - sudo apt-get install -y ca-certificates curl tar |
55 | 48 | 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" |
| 49 | + URL="https://github.com/grafana/k6/releases/download/v${K6_VERSION}/k6-v${K6_VERSION}-linux-amd64.tar.gz" |
| 50 | +
|
| 51 | + echo "Downloading $URL" |
| 52 | + curl -sLo k6.tar.gz "$URL" |
| 53 | +
|
| 54 | + echo "Extracting..." |
57 | 55 | 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" |
| 56 | + sudo mv "k6-v${K6_VERSION}-linux-amd64/k6" /usr/local/bin/k6 |
| 57 | + sudo chmod +x /usr/local/bin/k6 |
| 58 | + rm -rf k6.tar.gz "k6-v${K6_VERSION}-linux-amd64" |
60 | 59 |
|
61 | | - - name: Run k6 tests |
| 60 | + echo "k6 version:" |
| 61 | + k6 version |
| 62 | +
|
| 63 | + - name: Run k6 tests |
62 | 64 | run: | |
63 | 65 | mkdir -p results |
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 |
| 66 | + npm run test:suite -- --out json=results/output.json |
| 67 | +
|
| 68 | + # Relatório HTML dentro de src/tests |
| 69 | + if [ -f src/tests/report.html ]; then |
| 70 | + mv src/tests/report.html results/ |
| 71 | + fi |
69 | 72 |
|
70 | | - - name: Upload results |
| 73 | + - name: Upload test results |
71 | 74 | uses: actions/upload-artifact@v4 |
72 | 75 | with: |
73 | 76 | name: k6-results |
74 | | - path: results/ |
| 77 | + path: results |
75 | 78 |
|
76 | 79 | deploy: |
77 | | - name: Deploy |
78 | 80 | runs-on: ubuntu-latest |
79 | 81 | needs: test |
80 | | - steps: |
81 | | - - name: Checkout repository |
82 | | - uses: actions/checkout@v4 |
83 | 82 |
|
84 | | - - name: Download test results |
| 83 | + steps: |
| 84 | + - name: Download results |
85 | 85 | uses: actions/download-artifact@v4 |
86 | 86 | with: |
87 | 87 | name: k6-results |
88 | 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