How to test with GitHub Actions

Hello,

I’m wondering what the best practice is for QA as part of your CI/CD.

Following the docs on unit testing with Python (link pending), I can get rcc run --robot test_robot.yaml to work locally. Also, following the docs on github actions (link pending), I can get some workflows going.

My question is whether I should aim to have github actions do the rcc run --robot test_robot.yaml step, maybe spinning up some windows-latest, installing rcc in it, and then running the above command? Or should I just be trying to run pytest directly in a github actions runner and forget about the above command?

To clarify, specifically for the testing portion of my pipeline, should I be making use of the upload-robot and trigger-process actions? I understand that if all tests pass I will ultimately want to upload the bot automatically and maybe also trigger some process, but are any of these 2 actions necessary in the QA phase?

Thanks

Here are the links that @jaime.salazar is referring in the above post.

1 Like

With some helpful guidance from Robocorp on slack, the following workflow is able to test a bot in github actions:

name: Run tests with Pytest

on:
  push:
    branches:
      - dev

jobs:
  run-tests-with-pytest:
    runs-on: windows-latest
    name: Run tests with Pytest
    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js 16
        uses: actions/setup-node@v3
        with:
          node-version: 16
      - name: Install RCC
        shell: powershell
        run: curl -o rcc.exe https://downloads.robocorp.com/rcc/releases/v13.6.3/windows64/rcc.exe; ./rcc.exe --version
      - name: Connect to Control Room Vault
        shell: powershell
        run: ./rcc.exe task script -- python set-robocorp-vault.py ${{ secrets.ROBOCORP_WORKSPACE_ID }} ${{ secrets.ROBOCORP_ACCESS_CREDS }}
      - name: RCC run tests
        shell: powershell
        run: ./rcc.exe run -e devdata/env.json --robot test_robot.yaml

Note that the direct answer to my question can omit the Connect to Control Room Vault step. However, in my particular case, the bot I was using happens to require some vault secrets so a bonus here has been figuring out how to do that in github actions as well.

I had to create the set-robocorp-vault.py in order to imitate the interactions required by use-robocorp-vault set, which is a commandline script that used to be helpful for connecting to the CR vault. My script is basically a very barebones version of the set_command() found at github DOT com/robocorp/rpaframework/blob/master/packages/main/src/RPA/scripts/robocorp_cloud.py , which is invoked by use-robocorp-vault set. You may find and use my script in this gist and I’m open to feedback.

PS. I’m pretty sure use-robocorp-vault set requires rcc v13.6.3 and rpaframework==22.0.0, I’m assuming my script does as well.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.