Skip to content

Commit

Permalink
Merge pull request #3 from gonkunkun/create-scneario-for-smoke-test
Browse files Browse the repository at this point in the history
add CI
  • Loading branch information
gonkunkun committed Mar 30, 2024
2 parents c7ee6a3 + 2beb1dd commit 9d08d19
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AMOUNT_OF_INDEX_SIZE_FOR_TEST_DATA=10000
DEBUG=true
ENV=local
SAMPLE_PRODUCT_ENDPOINT=http://localhost:3005
REDIS_ENDPOINT=redis://localhost:6379
76 changes: 76 additions & 0 deletions .github/workflows/mockTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: mockTest

on: [pull_request]

jobs:
mockTestForSampleApp:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 21
cache: 'npm'

- name: Cache npm directory
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install npm dependencies for k6
run: npm install

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
cache-dependency-path: '**/*.sum'
- name: Install xk6
run: go install go.k6.io/xk6/cmd/xk6@latest

- name: Cache k6 binary
uses: actions/cache@v4
id: cache-k6-binary
with:
path: k6
key: ${{ runner.os }}-k6-${{ hashFiles('**/k6.*') }}
restore-keys: |
${{ runner.os }}-k6-
- name: Build k6 with plugins
if: steps.cache-k6-binary.outputs.cache-hit != 'true'
run: |
xk6 build \
--with github.com/LeonAdato/xk6-output-statsd@latest \
--with github.com/grafana/xk6-dashboard@latest \
--with github.com/szkiba/xk6-enhanced@latest \
--with github.com/szkiba/xk6-dotenv@latest
- name: Set up environment variables
run: cp .env.ci .env
- name: Start mock endpoint
run: |
cd mock
npm install
npx ts-node ./src/index.ts 3005 &
- name: Cache k6 bundle files
uses: actions/cache@v4
id: cache-k6-bundle-files
with:
path: dist
key: ${{ runner.os }}-dist-${{ hashFiles('dist/**') }}
restore-keys: |
${{ runner.os }}-dist-
- name: Bundle k6 scripts
if: steps.cache-k6-bundle-files.outputs.cache-hit != 'true'
run: npm run bundle
- name: Run k6 smoke test
run: npm run smoke:sample-product

0 comments on commit 9d08d19

Please sign in to comment.