DEV Community

Cover image for RASA - Continuous integration using GitHub Actions
Petr Janik
Petr Janik

Posted on

RASA - Continuous integration using GitHub Actions

To be sure, that the new code that we write does not break the behaviour of our assistant, we have written a few tests for happy and unhappy paths. But we still have to run those tests manually every time we make any changes.
To automate this process, we will create a GitHub Action, that will train our assistant and run the tests every time we push any changes to GitHub.

Create a new file in folder .github/workflows/ named continuous-integration.yml.

# .github/workflows/continuous-integration.yml
name: Train and test Rasa

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  training-testing:
    name: Training and Testing
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Rasa Train and Test GitHub Action
        uses: RasaHQ/rasa-train-test-gha@main
        with:
          data_validate: true # Validates domain and data files to check for possible mistakes
          rasa_train: true # Run rasa train
          rasa_test: true # Run rasa test
          test_args: --fail-on-prediction-errors # Fail pipeline when test fails
          test_type: all # Run both 'core' and 'nlu' tests
      - name: Upload model
        if: github.ref == 'refs/heads/master'
        uses: actions/upload-artifact@master
        with:
          name: model
          path: models
      - name: Store test results
        uses: actions/upload-artifact@v2
        with:
          name: test-results
          path: |
            results
            reports

Enter fullscreen mode Exit fullscreen mode

The file reads as follows:

  • This action is run when anyone pushes to master of creates a pull request to master branch.
  • It contains one job, named Training and Testing that is made of several steps.
  • First, the repository is checked-out.
  • Second, a premade Rasa Train and Test GitHub Action is run with a configuration. The configuration options are described in the comments. You can learn about more configuration options in their README.
  • During this step:
    • domain and data files are validated to check for possible mistakes. You can learn more about data validation in the documentation.
    • a model is trained
    • a model is tested
  • At the end we store the trained model as an artifact.
  • We also store test results and reports. The reports contain various metrics of our model, both in .json and .csv format.

I have also simplified requirements.txt to install only rasa package. Its dependencies are resolved automatically.
Contents of requirements.txt:

rasa==2.3.1
Enter fullscreen mode Exit fullscreen mode

You can learn more about GitHub Actions here.

You can learn more about continuous integration for Rasa in the documentation.

In the next chapter, we will look at checkpoints.

Repository for this tutorial:

You can checkout the state of the repository at the end of this tutorial by running:

git clone --branch 12-continuous-integration git@github.com:petr7555/rasa-dev-tutorial.git
Enter fullscreen mode Exit fullscreen mode

Top comments (0)