Skip to content

Run Ballerina By Examples using the Go tool

praneesha edited this page Jun 28, 2022 · 1 revision

After writing a Ballerina By Example, you can also run it to test and verify if the output is accurate. Follow the instructions below to do this.

  1. Create a directory with the BBE directories, which you want to test and the index.json file (e.g., /examples).

  2. In the CLI, navigate to the master branch of the ballerina-release GitHub repo (i.e., <BALLERINA_RELEASE_REPO_HOME>).

  3. Execute the command below to build the BBEs.

    Info: You need to change the properties of the above command accordingly. Also, the <GEN_PLAYGROUND_LINKS> property can be set to false while testing BBEs locally since with true it takes a longer time to run the tool. In the final run, you can set this to true.

    go run ballerinaByExample/tools/generate.go “<SOURCE-OF-THE-BBES>” “<RELEASE-VERSION>” “<OUTPUT-FOLDER>” “<WITH-OR-WITHOUT-FRONT-MATTER>” “<IF-LATEST-VERSION>” “<GEN_PLAYGROUND_LINKS>

    For example,

    go run ballerinaByExample/tools/generate.go "/Documents/examples" "1.2" "by-example" "true" "true" "true"
  4. Copy the generated <BALLERINA_RELEASE_REPO_HOME>/by-example directory.

  5. Replace the <BALLERINA_DEV_WEBSITE_REPO_HOME>/<VERSION>/learn/by-exampledirectory with the directory you copied.

  6. In the CLI, navigate to the master branch of the ballerina-dev-website GitHub repo (i.e., <BALLERINA_DEV_WEBSITE_REPO_HOME>).

  7. Execute the bundle exec jekyll serve command to build the website locally.

    Note: Alternatively, execute the command below if you do not have Jekyll configured locally.

    docker run -p 4000:4000 --volume="/home/shaf/Documents/source/public/ballerina-dev-website:/srv/jekyll" jekyll/builder:3.8 jekyll serve
  8. Navigate to the Ballerina By Examples in the dev website built locally and test the BBE updates you did.