diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..63920a7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Check Generated Files +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + verify-generation: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v5 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Add Go bin to PATH + run: echo "$HOME/go/bin" >> $GITHUB_PATH + - name: Run commands generation command + run: make gen + - name: Verify no changes were generated + run: | + # Check if there are any uncommitted changes in the working directory + if [ -z "$(git status --porcelain)" ]; then + echo "::notice::Generated files are up to date. No changes detected." + else + echo "::error::Detected uncommitted changes after running the generation command. Please run the generator and commit the changes." + git status + git diff + exit 1 + fi + build: + runs-on: ubuntu-latest + needs: verify-generation + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v5 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Build the cli binary + run: make build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6803914 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +.PHONY: all install gen build test + +# Load .env file if it exists (for local development) +# In CI/CD, environment variables are provided by the environment +-include .env +ifneq (,$(wildcard .env)) +export $(shell sed 's/=.*//' .env) +endif + +all: gen build test + +# we need to install gen-commands directly because gen-commands does not have its +# own go.mod +install: +rm -rf ./cli +git clone https://github.com/temporalio/cli && cd ./cli && go install ./cmd/gen-commands && cd .. +rm -rf ./cli + +gen: install +gen-commands -input ./temporalcloudcli/commands.yml -pkg temporalcloudcli > ./temporalcloudcli/commands.gen.go + +build: +go build ./cmd/temporal-cloud + +test-integration: +go test -tags=integration ./... + +test: +go test ./...