Skip to content

Instantly share code, notes, and snippets.

@davidmukiibi
Last active November 18, 2019 03:19
Show Gist options
  • Save davidmukiibi/4846a40e897c196e4b6a4ee8bc89b28c to your computer and use it in GitHub Desktop.
Save davidmukiibi/4846a40e897c196e4b6a4ee8bc89b28c to your computer and use it in GitHub Desktop.
This is the circleci config file that implements running k6 performance tests in the cloud mode.
default: &defaults
parallelism: 1
docker:
- image: loadimpact/k6:latest
run_any_tests_here: &run_any_tests_here
run:
name: Run Tests
command: |
cd tests_folder
npm run test
deploy_to_staging: &deploy_to_staging
run:
name: Deploy to the staging environment on Google Kubernetes Engine
command: |
docker build -t gcr.io/loadimpact/k6-tutorial:$CIRCLE_SHA1 .
docker push gcr.io/loadimpact/k6-tutorial:$CIRCLE_SHA1
kubectl set image loadimpact/k6-tutorial:latest staging-api=gcr.io/loadimpact/k6-tutorial:$CIRCLE_SHA1
k6_performance_tests: &k6_performance_tests
run:
name: Running Load Tests Using K6
command: |
k6 cloud tests/cloud-test.js
deploy_to_production: &deploy_to_production
run:
name: Deploy to the production environment on Google Kubernetes Engine
command: |
docker build -t gcr.io/loadimpact/k6-tutorial:$CIRCLE_SHA1 .
docker push gcr.io/loadimpact/k6-tutorial:$CIRCLE_SHA1
kubectl set image loadimpact/k6-tutorial:latest production-api=gcr.io/loadimpact/k6-tutorial:$CIRCLE_SHA1
version: 2
jobs:
run_any_tests:
<<: *defaults
steps:
- checkout
- *run_any_tests_here
deploy_to_staging_environment:
<<: *defaults
steps:
- checkout
- *deploy_to_staging
run_perfomance_tests:
<<: *defaults
steps:
- checkout
- *k6_performance_tests
deploy_to_production_environment:
<<: *defaults
steps:
- checkout
- *deploy_to_production
workflows:
version: 2
build-and-test:
jobs:
- run_any_tests
- deploy_to_staging_environment:
requires:
- run_any_tests
- run_perfomance_tests:
requires:
- deploy_to_staging_environment
- deploy_to_production_environment:
requires:
- run_perfomance_tests
@ppcano
Copy link

ppcano commented Nov 16, 2019

@davidmukiibi, I don't think you need this command if you have set the environment variable properly.

This was NOT required in the past instructions https://loadimpact.com/integrations/performance-testing-circleci/

login_loadimpact: &login_loadimpact
  run:
    name: Logging into loadimpact
    command: |
      k6 login cloud --token $K6_CLOUD_TOKEN

Can you check out and confirm it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment