Skip to content

Latest commit

 

History

History
141 lines (91 loc) · 4.25 KB

File metadata and controls

141 lines (91 loc) · 4.25 KB

Getting started

This repo contains multiple packages used to generate Azure SDK's for Go:

  • The autorest.go package generates client code using autorest.
  • The typespec-go package generates client code from typespec.
  • The codegen.go package contains code used common by both autorest.go and typespec-go

This guide outlines the getting started steps to contributing to these generators.

Table of Contents

Prerequisites

Step 1: Clone the repo

To set up your local development environment, we recommend forking this repo then cloning.

git clone https://github.com/<your-github-username>/autorest.go.git

Step 2: Build the code

Once you have the code locally, you can build it.

First, install all dependencies.

pnpm install

Then, build the code.

To build a specific package, navigate to that directory and run the command from there.

pnpm build

Step 3: Regenerate tests and samples

After making changes, build the code again, then run a regeneration command to see how your change has affected client code generation.

For autorest.go

From the autorest.go/packages/autorest.go directory, run the following command:

pnpm regenerate

To regenerate a specific test:

pnpm regenerate --filter=TestName

For typespec-go

From the autorest.go/packages/typespec-go directory, run the following command:

pnpm tspcompile

To regenerate a specific test:

pnpm tspcompile --filter=TestName

Step 4: Test your changes

Verify changes made result in the output you expect.

For typespec-go, you can run tests using spector.

pnpm spector --start
~ run tests~
pnpm spector --stop

Debug

To debug the code generator:

  1. Set a break point
  2. In the TypeScript debug terminal in VSCode, run one of the regeneration commands from step 3

Built in commands

There are a number of custom pnpm commands to help with development. See the .scripts folder for more. Add the -w switch when executing the script from a directory other than the repo root.

NOTE: by default, the script will run against the entire repo. To limit its scope, pass a directory argument. E.g. when working from the /packages/autorest.go directory, to execute modtidy for only go.mod files under /packages/autorest.go, execute pnpm -w modtidy $pwd

To run go build and go vet on every generated module:

pnpm -w buildvet

To run go mod tidy on every generated module:

pnpm -w modtidy

Step 5: Update emitter documentation

If you have made changes to the emitter options in typespec-go, you need to update the documentation in typespec-azure repo.

  1. Run pnpm run regen-docs from the packages/typespec-go directory to generate the documentation.
  2. Copy the generated documentation folder packages/typespec-go/website to the root folder of typespec-azure repo.
  3. Commit the changes in the typespec-azure repo and make a PR in the repo.

Step 6: Make a PR

Once you're satisfied with your changes, it's time to make a PR in the repo.

Before you do, make sure to:

  1. Format your code using the Prettier configuration file in the root of the repo
  2. Don't forget to rebuild and regenerate everything before pushing your changes