From 8da4efe4049d44d8f8c072ade9ebbebf89b414da Mon Sep 17 00:00:00 2001 From: Rene Cunningham Date: Wed, 17 Mar 2021 09:26:14 +1100 Subject: [PATCH] wip --- .gitignore | 2 -- commander.yaml | 9 +++++++++ docs/ci.md | 23 +++++++++++++++++++++++ pkg/auth0-cli-config-generator/main.go | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 docs/ci.md diff --git a/.gitignore b/.gitignore index 8995d2775..879ca564a 100644 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,3 @@ tags .vscode .DS_Store -# integration test helper -auth0-cli-config-generator diff --git a/commander.yaml b/commander.yaml index e578b66a2..f300216fd 100644 --- a/commander.yaml +++ b/commander.yaml @@ -5,5 +5,14 @@ tests: auth0 apis list: exit-code: 0 + auth0 apps list: + exit-code: 0 + auth0 logs: exit-code: 0 + + auth0 actions list: + exit-code: 0 + + auth0 completion bash: + exit-code: 0 diff --git a/docs/ci.md b/docs/ci.md new file mode 100644 index 000000000..609a968e2 --- /dev/null +++ b/docs/ci.md @@ -0,0 +1,23 @@ +# Continuous Integration + +## Integration Tests + +Integration tests can be run with: +```bash +make integration +``` + +`make integration` will build and run the `auth0-cli-config-generator` command which is responsible for ensuring that a valid auth0-cli config file exists before the integration tests run. + +`make integration` will then use [commander](https://github.com/commander-cli/commander) to run tests defined in [commander.yaml](./commander.yaml) + +To run intergration tests as part of a CI pipeline, several environment variables need to be exported first. When these variables are set, `auth0-cli-config-generator` will generate a valid auth0-cli config file being retrieving a token for the client, removing the need to run `auth0 login`: +```bash +export AUTH0_CLI_CLIENT_NAME="integration" \ + AUTH0_CLI_CLIENT_DOMAIN="example-test-domain.au.auth0.com" \ + AUTH0_CLI_CLIENT_ID="example-client-id" \ + AUTH0_CLI_CLIENT_SECRET="example-client-secret" \ + AUTH0_CLI_REUSE_CONFIG="false" \ + AUTH0_CLI_OVERWRITE="true" +make integration +``` diff --git a/pkg/auth0-cli-config-generator/main.go b/pkg/auth0-cli-config-generator/main.go index 9f4cbf419..9ba4ee745 100644 --- a/pkg/auth0-cli-config-generator/main.go +++ b/pkg/auth0-cli-config-generator/main.go @@ -127,6 +127,7 @@ func persistConfig(filePath string, c config, overwrite bool) error { func main() { var cmd = &cobra.Command{ Use: "auth0-cli-config-generator", + Short: "A tool that generates valid auth0-cli config files", SilenceErrors: true, SilenceUsage: true, RunE: func(command *cobra.Command, args []string) error {