From 85d3b9f6a966740f1e03b3aa5606ba7b3758a0d5 Mon Sep 17 00:00:00 2001 From: Siddhartha Basu Date: Thu, 3 Aug 2023 11:30:06 -0500 Subject: [PATCH 1/4] refactor(flag.go): extract ArangoFlags function to improve code organization and reusability The ArangoFlags function is extracted from the main code to improve code organization and reusability. It returns a []cli.Flag containing the flags required for configuring the connection to an ArangoDB database. These flags include arangodb-pass, arangodb-user, arangodb-host, arangodb-port, and is-secure. The function also provides example usage and documentation for each flag. --- command/flag/flag.go | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/command/flag/flag.go b/command/flag/flag.go index eed5e09..d7cfe3e 100644 --- a/command/flag/flag.go +++ b/command/flag/flag.go @@ -4,6 +4,72 @@ import ( "github.com/urfave/cli" ) +/* +The ArangoFlags function returns a []cli.Flag containing the following flags: + + - arangodb-pass: The password for the ArangoDB database. + + This flag is required and can be set using the ARANGODB_PASS environment variable. + + - arangodb-user: The user for the ArangoDB database. + + This flag is required and can be set using the ARANGODB_USER environment variable. + + - arangodb-host: The host for the ArangoDB database. + + The default value is "arangodb" and can be overridden using the ARANGODB_SERVICE_HOST + environment variable. This flag is required. + + - arangodb-port: The port for the ArangoDB database. + + The default value is "8529" and can be overridden using the ARANGODB_SERVICE_PORT environment variable. + + - is-secure: A boolean flag indicating whether the ArangoDB endpoint is secured or unsecured. + +Example usage: + + flags := ArangoFlags() + app := cli.NewApp() + app.Flags = flags + ... + err := app.Run(os.Args) + +The ArangoFlags function can be used in a command-line application to easily configure ArangoDB connection details. +*/ +func ArangoFlags() []cli.Flag { + return []cli.Flag{ + cli.StringFlag{ + Name: "arangodb-pass, pass", + EnvVar: "ARANGODB_PASS", + Usage: "arangodb database password", + Required: true, + }, + cli.StringFlag{ + Name: "arangodb-user, user", + EnvVar: "ARANGODB_USER", + Usage: "arangodb database user", + Required: true, + }, + cli.StringFlag{ + Name: "arangodb-host, host", + Value: "arangodb", + EnvVar: "ARANGODB_SERVICE_HOST", + Usage: "arangodb database host", + Required: true, + }, + cli.StringFlag{ + Name: "arangodb-port", + EnvVar: "ARANGODB_SERVICE_PORT", + Usage: "arangodb database port", + Value: "8529", + }, + cli.BoolFlag{ + Name: "is-secure", + Usage: "flag for secured or unsecured arangodb endpoint", + }, + } +} + // ArangodbFlags returns the cli based flag slice that includes // command line arguments for connecting to an arangodb instance. func ArangodbFlags() []cli.Flag { From c26f5ac93ea927e0390d89be6fcb861f4ce88253 Mon Sep 17 00:00:00 2001 From: Siddhartha Basu Date: Thu, 3 Aug 2023 11:32:08 -0500 Subject: [PATCH 2/4] chore(create-pull-request.yml): update workflow to use latest version of Ubuntu and GitHub CLI for creating pull requests The workflow has been updated to use the "ubuntu-latest" runner instead of "ubuntu-20.04" for better compatibility and future-proofing. The "actions/checkout@v2" action has been replaced with "actions/checkout@v3" for improved functionality. The workflow now uses the GitHub CLI to create pull requests, passing the current branch name as the title and a predefined body message. --- .github/workflows/create-pull-request.yml | 26 +++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/create-pull-request.yml b/.github/workflows/create-pull-request.yml index 9081d0f..771cd34 100644 --- a/.github/workflows/create-pull-request.yml +++ b/.github/workflows/create-pull-request.yml @@ -1,19 +1,17 @@ name: Create Pull Request on: create jobs: - create-pr: - runs-on: ubuntu-20.04 - if: github.actor != 'dependabot[bot]' + create-pull-request: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: get branch name - id: vars + - name: Checkout code + uses: actions/checkout@v3 + - name: Create Pull Request + env: + GH_TOKEN: ${{ github.token }} run: | - branch=$(echo ${{ github.ref }} | sed -r 's/refs\/heads\///') - echo ::set-output name=branch::${branch} - - name: pull-request - uses: repo-sync/pull-request@v2 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - destination_branch: develop - pr_title: Pulling ${{ steps.vars.outputs.branch }} into develop + # Get current branch name + branch_name=$(git symbolic-ref --short HEAD) + # Create pull request using GitHub CLI + gh pr create --base develop --title "Auto-generated Pull Request for $branch_name" --body "Pulling '$branch_name into develop. Please review and merge." + From d16d95e021fd7c8b0ddb79f9777aa690d0b67443 Mon Sep 17 00:00:00 2001 From: Siddhartha Basu Date: Thu, 3 Aug 2023 11:33:36 -0500 Subject: [PATCH 3/4] chore(testcov.yml): update workflow to use latest version of ArangoDB and Go The testcov.yml workflow has been updated to use the latest version of ArangoDB (3.10.9) and Go (version 1.20.6). This ensures that the workflow is using the most up-to-date versions of these dependencies, which may include bug fixes and performance improvements. --- .github/workflows/testcov.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/testcov.yml b/.github/workflows/testcov.yml index 1228752..4295335 100644 --- a/.github/workflows/testcov.yml +++ b/.github/workflows/testcov.yml @@ -1,33 +1,31 @@ name: Test coverage -on: - pull_request: - types: [edited, labeled, opened, synchronize, reopened] +on: [pull_request] jobs: test: - name: Unit tests - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest services: arangodb: - image: arangodb:3.8.7 + image: arangodb:3.10.9 env: ARANGO_ROOT_PASSWORD: rootpass ports: - 8529/tcp steps: - name: set up golang - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.18 + go-version: '~1.20.6' + - run: go version - name: check out code uses: actions/checkout@v3 - name: unit test - run: go test -covermode=atomic -coverprofile=profile.cov -cpu 4 -v ./... + run: go test -covermode=atomic -coverprofile=profile.cov -v ./... env: - GOPROXY: https://proxy.golang.org ARANGO_USER: root ARANGO_PASS: rootpass ARANGO_HOST: localhost ARANGO_PORT: ${{ job.services.arangodb.ports[8529] }} + GOPROXY: https://proxy.golang.org - name: upload coverage to codecov uses: codecov/codecov-action@v3 with: From e8d4e55f450931f164bf0ffe1982c6f34be6d06a Mon Sep 17 00:00:00 2001 From: Siddhartha Basu Date: Thu, 3 Aug 2023 11:35:56 -0500 Subject: [PATCH 4/4] chore(ci.yml): update setup-go action to version 4 and set go-version to ~1.20.6 The ArangoDB image version has been updated to 3.10.9 to ensure compatibility and take advantage of any bug fixes or improvements. The setup-go action has been updated to version 4 and the go-version has been set to ~1.20.6 to use the latest stable version of Go for the unit tests. --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94cb3f1..493f9d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,21 +5,21 @@ on: - develop jobs: test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest services: arangodb: - image: arangodb:3.8.7 + image: arangodb:3.10.9 env: ARANGO_ROOT_PASSWORD: rootpass ports: - 8529/tcp steps: - - name: set up golang - uses: actions/setup-go@v3 - with: - go-version: 1.18 - name: check out code uses: actions/checkout@v3 + - name: set up golang + uses: actions/setup-go@v4 + with: + go-version: '~1.20.6' - name: unit test run: go test -covermode=atomic -coverprofile=profile.cov -cpu 4 -v ./... env: