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

'cache prepare' command #67

Merged
merged 39 commits into from
May 18, 2022
Merged

'cache prepare' command #67

merged 39 commits into from
May 18, 2022

Conversation

CodeMouse92
Copy link
Contributor

This implements the following features:

  • --cache-dir global option
  • cache command (cannot be directly executed)
  • cache prepare subcommand, which idempotently creates or verifies the existence of a fully migrated SQLite3 database in the --cache-dir.
  • Improves architecture to make it easier to add subcommands.

Closes #49.

@github-actions
Copy link
Contributor

github-actions bot commented May 17, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@mscottford
Copy link
Member

I have read the CLA Document and I hereby sign the CLA

@mscottford
Copy link
Member

recheck

Copy link
Member

@mscottford mscottford left a comment

Choose a reason for hiding this comment

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

Overall this looks really good, especially when you consider that you're not used to working with C#. You've picked up a ton of stuff to pull this PR together. 🎉

I do have some suggestions here and there. I could have done many of them myself, but I wanted to take the opportunity to share some C# knowledge where it makes sense.

features/help.feature Outdated Show resolved Hide resolved
Corgibytes.Freshli.Cli.Test/Commands/CacheCommandTest.cs Outdated Show resolved Hide resolved
features/step_definitions/database.rb Show resolved Hide resolved
.codeclimate.yml Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
features/cache.feature Show resolved Hide resolved
Corgibytes.Freshli.Cli/Functionality/Cache.cs Outdated Show resolved Hide resolved
Corgibytes.Freshli.Cli/Functionality/Cache.cs Outdated Show resolved Hide resolved
Corgibytes.Freshli.Cli/Functionality/Cache.cs Outdated Show resolved Hide resolved
Corgibytes.Freshli.Cli/Functionality/Cache.cs Outdated Show resolved Hide resolved
@CodeMouse92 CodeMouse92 force-pushed the cache_prepare branch 3 times, most recently from 2448a5b to 4ba9193 Compare May 17, 2022 22:25
CodeMouse92 and others added 20 commits May 18, 2022 08:59
Configures the project for BDD-based acceptance testing with Aruba
and Cucumber.
...because, Freshli should be fresh, no? ;)
Also updates GitHub Action tooling.
Eliminates some now-unnecessary inheritance with commands,
wherein all commands would include the --output and
--format options. Also updates more dependencies to the
latest versions.
Implements the 'cache' command, which has a 'prepare'
subcommand. At present, this does nothing.
Adds a --cache-dir global option with a default value of
$HOME/.freshli, for storing temporary files.
The ScanCommandRunner.Run() function returns an integer
return code (0 if successful), and the invocation of
ScanCommand.Run() expects a return code, but ScanCommand.Run()
incorrectly is 'void'. This changes the return of Run()
so it no longer drops this return code.
Creates the database file at the user-specified
(or default) location for the cache, and/or
migrates the existing file. If the file is corrupt,
the command fails with a non-zero exit code.
Tests for other commands will need to use the logic in VerifyAlias.
This moves VerifyAlias to a new TestHelpers class, and makes the
function generic, so it can be used with any System.CommandLine.Command
class.
Tests for --cache-dir global option. This can only be tested on
MainCommand directly, since the normal command building does not
take place in the tests.
The main command should not be runnable directly. Instead, one of its
subcommands must be run instead. This test confirms that as true.
Confirms the following:
* 'cache' is not directly runnable (no handler)
* 'cache prepare' is runnable (has handler)
Cucumber now tests more specific statements within the --help
output, rather than expecting a large exact block.
Ensures that 'cache prepare' creates the expected default folder,
and generates an SQLite database file that passes SQLite's
"PRAGMA integrity_check".

NOTE: It is not feasible to test for pending migrations with cucumber.
--format and --output are no longer shared between all commands,
so all mentions of that are removed. Shows the correct inheritance
for Commands now that BaseCommand<> has been removed. Adds mention
of --cache-dir global argument. Documents the new cache command.
Fixes misspelled words in README.md and CONTRIBUTING.md.
Improves alignment of columns on Markdown representation of tables
(thanks to JetBrains). Improves readability of command list in
Program.cs, to make it easier for future developers to add
their own. Reordered methods in Program.cs from outermost to
innermost to make navigating the file a bit easier.
CodeMouse92 and others added 8 commits May 18, 2022 09:00
Adds in Ruby 3.1 using the same setup that's used to build the official
Docker container.
https://github.com/docker-library/ruby/blob/master/3.1/bullseye/Dockerfile
Also changes the name of the methods to make it more clear that a value is being retrieved, not an option/argument.
Switches to using `MethodData` and `TheoryData` to represent the set of data to test.

This approach is used instead of the `[InlineData]` attribute because the `ArgumentArity` values are not technically constants, and only constant values can be parameters to attributes.
@mscottford
Copy link
Member

I'm confused about why this pull request is now reporting conficts.

Environment variables on Linux do not persist between process
executions, so this was not actually enabling the 'dotnet ef'
tool to work with non-standard locations. Removing all use
of the environment variable to simplify code.
@codeclimate
Copy link

codeclimate bot commented May 18, 2022

Code Climate has analyzed commit 07de1d8 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 24.7% (50% is the threshold).

This pull request will bring the total coverage in the repository to 40.1%.

View more on Code Climate.

Copy link
Member

@mscottford mscottford left a comment

Choose a reason for hiding this comment

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

Yay! First command in the bag!

@mscottford mscottford merged commit fe16e04 into main May 18, 2022
@mscottford mscottford deleted the cache_prepare branch May 18, 2022 20:54
@github-actions github-actions bot locked and limited conversation to collaborators May 18, 2022
@mscottford mscottford added the enhancement New feature or request label May 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add cache prepare command
3 participants