From e8cebd5668b9b4605b359fec922b6981f53fb67f Mon Sep 17 00:00:00 2001 From: Andy <70534960+as-herzog@users.noreply.github.com> Date: Fri, 7 May 2021 16:04:17 -0600 Subject: [PATCH] CLI-140: integration tests on ci (#263) * chore: initial try at workflow change * chore: add env vars * chore: remove path * chore: add mocks * chore: try build before integration * chore: revert * chore: build all platforms * test: fix * test: run with verbose * test: skipped * test: remove verbose * test: echo path * test: add verbose flag back * test: build before integration * test: try bash * test: switch order * test: remove redundant build * test: add to path * fix: config generator include scopes * fix makefile * fix: config gen tenant name * fix: config generated token * test: remove verbose * test: failure * fix: revert fialure * test: cleanup even with failure * test: use bash * test: cleanup * fix: test Co-authored-by: Rita Zerrizuela Co-authored-by: Jorge L. Fatta --- .github/workflows/go.yml | 13 +++++++ Makefile | 12 +++---- integration/test-cleanup.sh | 3 +- internal/cli/apps.go | 2 +- pkg/auth0-cli-config-generator/main.go | 48 ++++++++++++++++++-------- 5 files changed, 55 insertions(+), 23 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index eb3cbbb2e..7f83dfa02 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,3 +22,16 @@ jobs: - name: ci run: PATH=$(go env GOPATH)/bin:$PATH make ci + + - name: integration + # skip running this action if the PR is coming from a fork: + if: github.event.pull_request.head.repo.full_name == github.repository + shell: bash + run: PATH=$(go env GOPATH)/bin:$PATH make integration + env: + AUTH0_CLI_CLIENT_NAME: ${{ secrets.AUTH0_CLI_CLIENT_NAME }} + AUTH0_CLI_CLIENT_DOMAIN: ${{ secrets.AUTH0_CLI_CLIENT_DOMAIN }} + AUTH0_CLI_CLIENT_ID: ${{ secrets.AUTH0_CLI_CLIENT_ID }} + AUTH0_CLI_CLIENT_SECRET: ${{ secrets.AUTH0_CLI_CLIENT_SECRET }} + AUTH0_CLI_REUSE_CONFIG: ${{ secrets.AUTH0_CLI_REUSE_CONFIG }} + AUTH0_CLI_OVERWRITE: ${{ secrets.AUTH0_CLI_OVERWRITE }} diff --git a/Makefile b/Makefile index d65c8b1c5..a70e37b1d 100644 --- a/Makefile +++ b/Makefile @@ -38,11 +38,7 @@ lint: # Build for the native platform build: - go build -ldflags "$(CTIMEVAR)" -o auth0 cmd/auth0/main.go -.PHONY: build - -# Build for the native platform -build: + go build -ldflags "$(CTIMEVAR)" -o $(GOBIN)/auth0 cmd/auth0/main.go .PHONY: build # Build a beta version of auth0-cli for all supported platforms @@ -78,5 +74,9 @@ integration-cleanup: ./integration/test-cleanup.sh .PHONY: integration-cleanup -integration: $(GOBIN)/auth0-cli-config-generator $(GOBIN)/commander run-integration integration-cleanup +integration: build $(GOBIN)/auth0-cli-config-generator $(GOBIN)/commander + $(MAKE) run-integration; \ + ret=$$?; \ + $(MAKE) integration-cleanup; \ + exit $$ret .PHONY: integration diff --git a/integration/test-cleanup.sh b/integration/test-cleanup.sh index df36daf1d..691f62829 100755 --- a/integration/test-cleanup.sh +++ b/integration/test-cleanup.sh @@ -9,7 +9,8 @@ for app in $( echo "${apps}" | jq -r '.[] | @base64' ); do clientid=$(_jq '.ClientID') name=$(_jq '.Name') - + # TODO(jfatta): should remove only those + # created during the same test session if [[ $name = integration-test-* ]] then echo deleting "$name" diff --git a/internal/cli/apps.go b/internal/cli/apps.go index bce1b9c50..c3ba11412 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -416,7 +416,7 @@ auth0 apps create -n myapp -t [native|spa|regular|m2m] --description