Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPIKE] Improve CLI documentation and implement git tag operations as thor subcommands #311

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# URISchemes: http, https
Layout/LineLength:
Exclude:
- 'bin/sdr'
- 'lib/sdr_cli.rb'

# Offense count: 7
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
Metrics/AbcSize:
Exclude:
- 'bin/sdr'
- 'lib/sdr_cli.rb'
- 'lib/auditor.rb'
- 'lib/cocina_checker.rb'
- 'lib/deployer.rb'
Expand All @@ -28,20 +28,20 @@ Metrics/AbcSize:
# Configuration parameters: CountComments, Max, CountAsOne.
Metrics/ClassLength:
Exclude:
- 'bin/sdr'
- 'lib/sdr_cli.rb'

# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/CyclomaticComplexity:
Exclude:
- 'bin/sdr'
- 'lib/sdr_cli.rb'
- 'lib/cocina_checker.rb'

# Offense count: 7
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Exclude:
- 'bin/sdr'
- 'lib/sdr_cli.rb'
- 'lib/auditor.rb'
- 'lib/cocina_checker.rb'
- 'lib/deployer.rb'
Expand All @@ -51,11 +51,11 @@ Metrics/MethodLength:
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
Metrics/PerceivedComplexity:
Exclude:
- 'bin/sdr'
- 'lib/sdr_cli.rb'
- 'lib/cocina_checker.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'bin/sdr'
- 'lib/sdr_cli.rb'
134 changes: 89 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Make sure that:
* You have properly configured your local SSH setup (see below)
* You have logged into `sdr-infra.stanford.edu` and cloned this repository.
* You have previously `ssh`-ed into all servers.
* NOTE: If you are unsure about this, run `bin/sdr check_ssh -e [qa|stage|prod]` and watch the output for any errors!
* NOTE: if you run `bin/sdr check_cocina`, you may need to ensure that you have the contribsys gem credentials available for google-books to install the sidekiq-pro gem locally (the credential is already on our deploy target VMs).
* NOTE: If you are unsure about this, run `sdr check_ssh -e [qa|stage|prod]` and watch the output for any errors!
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assume the developer has set up their PATH variable so this just works

* NOTE: if you run `sdr check_cocina`, you may need to ensure that you have the contribsys gem credentials available for google-books to install the sidekiq-pro gem locally (the credential is already on our deploy target VMs).
* The credentials are set to an environment variable on the server via puppet from values stored in vault (vault info: https://consul.stanford.edu/display/systeam/Vault+for+Developers). To fetch without digging into vault, go to a server that has them set via puppet and view the environment variable. See below under "Configure bundler for your local path" for an example.
* NOTE: You *may* invoke the `bin/` scripts via `bundle exec`.

Expand Down Expand Up @@ -80,20 +80,22 @@ user123:pass678

```
Usage:
bin/sdr check_ssh -e, --environment=ENVIRONMENT
sdr check_ssh -e, --environment=ENVIRONMENT

Options:
[--only=one two three] # Update only these repos
[--except=one two three] # Update all except these repos
-s, [--skip-update], [--no-skip-update] # Skip update repos
-e, --environment=ENVIRONMENT # Environment (["qa", "prod", "stage"])
# Possible values: qa, prod, stage
[--skip-control-master] # Skip checking for active SSH control master connection
[--only=one two three] # Check connections only to these services
[--except=one two three] # Check connections except for these services
-s, [--skip-update] # Skip refreshing the local git repository cache
# Default: false
-e, --environment=ENVIRONMENT # Check connections in the given environment
# Possible values: qa, prod, stage
[--skip-control-master] # Skip checking for an active SSH controlmaster connection
# Default: false

check SSH connections
Check SSH connections

Example:
bin/sdr check_ssh -s -e qa --except sul-dlss/technical-metadata-service sul-dlss/argo
sdr check_ssh -s -e qa --except sul-dlss/technical-metadata-service sul-dlss/argo
```

NOTE: Watch the output for any errors
Expand All @@ -102,42 +104,78 @@ NOTE: Watch the output for any errors

```
Usage:
bin/sdr check_cocina
sdr check_cocina

Options:
-s, [--skip-update], [--no-skip-update] # Skip update repos
-t, --branch, [--tag=TAG] # Check cocina version in the given tag or branch instead of the default branch
-s, [--skip-update] # Skip refreshing the local git repository cache
# Default: false
-t, --branch, [--tag=TAG] # Check cocina version in the given tag or branch instead of the default branch

check for cocina-models version mismatches
Check for Cocina data model mismatches

Example:
bin/sdr check_cocina -s -t rel-2022-08-01
bin/sdr check_cocina -t my-wip-branch
sdr check_cocina -s -t rel-2022-08-01
sdr check_cocina -t my-wip-branch
```

This will let you know which versions of cocina-models are used by each project with it in Gemfile.lock.

### Create repository tags
### Manage repository tags

This command tags repositories in parallel.
This command performs tag operations on repositories in parallel.

**NOTE**: We conventionally name tags `rel-{YYYY}-{MM}-{DD}`.

#### Create a tag

```
Usage:
sdr tag create TAG_NAME

Options:
-m, [--message=MESSAGE] # Message to describe a newly created tag
-c, [--skip-non-cocina] # Include only repos depending on new Cocina models releases
# Default: false

Create a git tag locally and remotely

Examples:
sdr tag -m 'coordinating the deploy of dependency updates' rel-2022-09-05
sdr tag -c -m 'coordinating the release of cocina-models 0.66.6' rel-2022-09-14
```

#### Verify a tag

```
Usage:
bin/sdr tag TAG_NAME
sdr tag verify TAG_NAME

Options:
-m, [--message=TAG MESSAGE] # Message to describe a newly created tag
-d, [--delete=DELETE], [--no-delete] # Delete the tag locally and remotely
-v, [--verify] # Verify the tags exist remotely
-c, [--cocina], [--no-cocina] # Only update repos affected by new cocina-models gem release
-c, [--skip-non-cocina] # Include only repos depending on new Cocina models releases
# Default: false

create, delete, or verify a tag named TAG_NAME
Verify a git tag exists remotely

Examples:
bin/sdr tag -m 'coordinating the deploy of dependency updates' rel-2022-09-05
bin/sdr tag -c -m 'coordinating the release of cocina-models 0.66.6' rel-2022-09-14
sdr tag verify rel-2022-09-05
sdr tag verify --skip-non-cocina rel-2022-09-14
```

#### Delete a tag

```
Usage:
sdr tag delete TAG_NAME

Options:
-c, [--skip-non-cocina] # Include only repos depending on new Cocina models releases
# Default: false

Delete a git tag locally and remotely

Examples:
sdr tag delete rel-2022-09-05
sdr tag delete --skip-non-cocina rel-2022-09-14
```

### Run the deploys
Expand All @@ -146,23 +184,27 @@ This command deploys repositories in parallel.

```
Usage:
bin/sdr deploy -e, --environment=ENVIRONMENT
sdr deploy -e, --environment=ENVIRONMENT

Options:
[--only=one two three] # Update only these repos
[--except=one two three] # Update all except these repos
-c, [--cocina], [--no-cocina] # Only update repos affected by new cocina-models gem release
-b, [--before-command=BEFORE_COMMAND] # Run this command on each host before deploying
-t, --branch, [--tag=TAG] # Deploy the given tag or branch instead of the default branch
-s, [--skip-update], [--no-skip-update] # Skip update repos
-e, --environment=ENVIRONMENT # Deployment environment
# Possible values: qa, prod, stage
[--skip-control-master] # Skip checking for active SSH control master connection
deploy all the services in an environment
[--only=one two three] # Deploy only these services
[--except=one two three] # Deploy all except these services
-c, [--skip-non-cocina] # Deploy only services depending on new Cocina models releases
# Default: false
-b, [--before-command=BEFORE_COMMAND] # Run this command on each host before deploying
-t, --branch, [--tag=TAG] # Deploy the given tag or branch instead of the default branch
-s, [--skip-update] # Skip refreshing the local git repository cache
# Default: false
-e, --environment=ENVIRONMENT # Deployment environment
# Possible values: qa, prod, stage
[--skip-control-master] # Skip checking for active SSH control master connection
# Default: false

Deploy services to a given environment

Examples:
bin/sdr deploy -s -e qa -t my-wip-branch --only=sul-dlss/technical-metadata-service
bin/sdr deploy -c -e qa -t rel-2022-09-14
sdr deploy -s -e qa -t my-wip-branch --only=sul-dlss/technical-metadata-service
sdr deploy -c -e qa -t rel-2022-09-14
```

**NOTE 0**:
Expand All @@ -187,7 +229,7 @@ If there is a problem, you can use `SKIP_UPDATE_STRSCAN` env var for an individu
You can update a gem for all apps for a given environment, like this:

```
bin/sdr deploy -e stage -b 'gem install io-wait'
sdr deploy -e stage -b 'gem install io-wait'
```

Or you can update a gem for a specific app like this:
Expand Down Expand Up @@ -236,7 +278,7 @@ Then

```
# -e can be qa or stage or prod
bin/sdr deploy -e stage -c
sdr deploy -e stage -c
```

### Only Refresh Repositories
Expand All @@ -245,11 +287,13 @@ If you have a need to pull main for all of the repositories without checking ssh

```
Usage:
bin/sdr refresh_repos
sdr refresh_repos

Options:
[--only=one two three] # Update only these repos
[--except=one two three] # Update all except these repos
[--only=one two three] # Update the cache only for these repos
[--except=one two three] # Update the cache except for these repos

Refresh the local git repository cache
```

### Notes and tips:
Expand Down
Loading