0

I have a shell script which runs k6 scenarios. This shell script successfully runs locally as well as on TeamCity via Docker.

I m trying to setup github actions to run the Docker which runs the script so that each time a PR is merged, it runs. But without giving any error the script is not really running as the logs from github action is not printing any echo statement from the script neither is it printing any K6 logs.

Custom action - action.yml:

name: 'k6 Load Test'
description: 'K6 action created similar to grafana for running load test with k6 in Antman project.'
inputs:
  cloud:
    description: |
      To run in the k6 cloud, provide your k6 cloud token as a secret to the input `token`.
    required: false
    default: false
  token:
    description: |
      k6 Cloud Token. Only required for using the cloud service.
    required: false
    default: ''
  filename:
    description: |
      Path to the test script to execute, relative to the workspace.
    required: true
    default: './src/scenarios/full-card-visa/index.js'
  flags:
    description: |
      Additional argument, flags and environment variables to provide to the k6 CLI.
    required: false
    default: ''
runs:
  using: 'docker'
  image: 'Dockerfile'
  env:
    K6_CLOUD_TOKEN: ${{ inputs.token }}
  args:
    - ${{ inputs.cloud }}
    - ${{ inputs.filename || './src/scenarios/full-card-visa/index.js' }}
    - ${{ inputs.flags }}

Github action that uses action.yml:

name: K6 Local Cloud test
on:
  push:
      branches:
        - 'main'
        - 'task/ANT-4-github-action'
  pull_request:
    types: [opened]
jobs:
  k6_load_test:
    name: k6 Load Test
    runs-on: ubuntu-latest

    steps:
      - name: Checkout branch
        uses: actions/checkout@v3
        with:
          ref: task/ANT-4-github-action

      - name: Run load test using action code from commit
        uses: ./
        with:
          filename: ./src/scenarios/full-card-visa/index.js
          cloud: true
          token: <my token>

Dockerfile:

FROM loadimpact/k6:0.34.1
COPY ./src/lib /lib
COPY ./src/scenarios /scenarios
COPY ./src/k6-run-all.sh /k6-run-all.sh
WORKDIR /
ENTRYPOINT []
CMD ["sh", "-c", "./src/k6-run-all.sh"]

Sample github action run (runs successfully but doesn't really run k6): enter image description here

Please note, I do not have permission to use grafana/k6 directly hence created my own action from their code.

Sonali Agrawal
  • 303
  • 4
  • 14

0 Answers0