Continous Integration

Overview

CodeMaker AI code generation features can be integrated directly into GitHub Action workflow. CodeMaker Action can be executed on the checkout source code and will only make changes to the working directory tree, because of that either a commit or pull request needs to be created as a separate step.

The action defines the following properties:

  • api-key - unique API Key needed to invoke the service. Should be stored as a secret.

  • mode - the code generation mode. Supported modes are code, docs.

  • path - the path to a directory or file to process. Supports glob wildcard patterns, for instance, path **/*.js will match the JavaScript file in any subdirectory of the working directory.

The GitHub Action can be easily integrated with automated workflow that can be triggered on pull request push or commit to any of the branches. Alternatively, it can be triggered manually on demand.

Example

Create a new GitHub workflow under ./github/workflows named codemaker.yml with the following content.

on: [push]

jobs:
  codemakerai_code_generation:
    runs-on: ubuntu-latest
    name: A job to run codemakerai code generation
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Code generation
        uses: codemakerai/codemaker-action@v1.5.0
        with:
          api-key: ${{ secrets.CODEMAKER_API_KEY }}
          mode: code
          path: src/**/*.java
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v6
        with:
          commit-message: Code generated by codemaker
          title: Changes by codemaker-action
          body: This pull request contains code generated by codemaker.
          branch: codemakerai-generate

The above configuration defines the workflow that is going to be triggered on git push. The workflow checkouts the latest revision of the source code and executes code generation tasks on any Java file located anywhere in the directory tree under the src directory.

Last updated