K6 browser and github actions

Hi,

I’ve been trying to get our K6 browser tests running inside our CI pipeline using github actions.

I initially tried the documented way on the K6 site using: uses: grafana/k6-action@v0.2.0 .Obviously this did not work as that’s not installing the K6 browser so I have now got the following set-up:

jobs:
  k6_transpile_bundle_test:
    name: Transpile, bundle and run
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Install dependencies
        working-directory: ./qa/performance
        run: |
          npm ci
          go install go.k6.io/xk6/cmd/xk6@latest
          xk6 build --output xk6-browser --with github.com/grafana/xk6-browser

      - name: Run load test
        working-directory: ./qa/performance
        run: | 
          ./xk6-browser run tests/performance-test.js
   

but this returns:

go: downloading go.k6.io/xk6 v0.8.1
go: downloading github.com/Masterminds/semver/v3 v3.1.1
/home/runner/work/_temp/8c43b3f6-25e4-464b-ba9f-a2c6341234fb.sh: line 3: xk6: command not found
Error: Process completed with exit code 127.

Can anybody advise the best way to work with github actions and K6 browser?

TIA

Hi @Meg42! Welcome to the forum! :slightly_smiling_face:

You can take a look at the xk6-browser workflows which actually also build xk6-browser binary and run some test scripts. For example, take a look at our e2e workflow.

There will be some differences on the steps, for example when using xk6 to build the binary you will have to use the same syntax used in your workflow:

xk6 build --output xk6-browser --with github.com/grafana/xk6-browser

But overall it should be a good guide on the process.

I hope that helps you to set up for pipeline.
Regards.

2 Likes

Thanks @Daniel.J this is exactly the help I needed. Up and running in our CI pipeline now :slight_smile:

2 Likes