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

Fix regression related to require_relative and fix integration tests #65

Merged
merged 8 commits into from
Jun 13, 2024
Merged
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
34 changes: 27 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "tty-prompt"
require "tmpdir"

RSpec::Core::RakeTask.new(:spec)

Expand All @@ -14,21 +15,28 @@ task default: %i[spec rubocop]

desc "Generates Swift source code and run its unit tests."
task :test_swift do
sh("ARKANA_RUNNING_CI_INTEGRATION_TESTS=true bin/arkana --config-filepath spec/fixtures/swift-tests.yml --dotenv-filepath spec/fixtures/.env.fruitloops --include-environments dev,staging")
Dir.chdir("tests/MySecrets") do
config_file = File.absolute_path("spec/fixtures/swift-tests.yml")
dotenv_file = File.absolute_path("spec/fixtures/.env.fruitloops")
with_temp_dir do |temp_dir|
puts "Current working directory: #{temp_dir}"
sh("ARKANA_RUNNING_CI_INTEGRATION_TESTS=true arkana --config-filepath #{config_file} --dotenv-filepath #{dotenv_file} --include-environments dev,staging")
Dir.chdir("tests/MySecrets")
sh("swift test")
end
FileUtils.rm_rf("tests")
end

desc "Generates Kotlin source code and run its unit tests."
task :test_kotlin do
FileUtils.copy_entry("spec/fixtures/kotlin", "tests")
sh("ARKANA_RUNNING_CI_INTEGRATION_TESTS=true bin/arkana --lang kotlin --config-filepath spec/fixtures/kotlin-tests.yml --dotenv-filepath spec/fixtures/.env.fruitloops --include-environments dev,staging")
Dir.chdir("tests") do
config_file = File.absolute_path("spec/fixtures/kotlin-tests.yml")
dotenv_file = File.absolute_path("spec/fixtures/.env.fruitloops")
directory_to_copy = File.absolute_path("spec/fixtures/kotlin")
with_temp_dir do |temp_dir|
puts "Current working directory: #{temp_dir}"
FileUtils.copy_entry(directory_to_copy, "tests")
sh("ARKANA_RUNNING_CI_INTEGRATION_TESTS=true arkana --lang kotlin --config-filepath #{config_file} --dotenv-filepath #{dotenv_file} --include-environments dev,staging")
Dir.chdir("tests")
sh("./gradlew test")
end
FileUtils.rm_rf("tests")
end

desc "Sets lib version to the semantic version given, and push it to remote."
Expand All @@ -45,3 +53,15 @@ task :bump, [:v] do |_t, args|
sh("git commit -m 'Bump app version to v#{version}.'")
sh("git push origin")
end

# Utilities

# Run tests in a different folder because when running in the same root folder as the gem,
# there can be "relative_require" that happen to work in the test but wouldn't work when installing the gem in a different project.
def with_temp_dir
Dir.mktmpdir do |temp_dir|
Dir.chdir(temp_dir) do
yield temp_dir
end
end
end
4 changes: 2 additions & 2 deletions lib/arkana/templates/kotlin/arkana.kt.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% require_relative "lib/arkana/helpers/string" %>
<% require_relative "lib/arkana/helpers/kotlin_template_helper" %>
<% require "arkana/helpers/string" %>
<% require "arkana/helpers/kotlin_template_helper" %>
<% # TODO: Sort these import statements alphabetically %>
// DO NOT MODIFY
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)
Expand Down
4 changes: 2 additions & 2 deletions lib/arkana/templates/kotlin/arkana_protocol.kt.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% require_relative "lib/arkana/helpers/string" %>
<% require_relative "lib/arkana/helpers/kotlin_template_helper" %>
<% require "arkana/helpers/string" %>
<% require "arkana/helpers/kotlin_template_helper" %>
// DO NOT MODIFY
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)
package <%= @kotlin_package_name %>
Expand Down
4 changes: 2 additions & 2 deletions lib/arkana/templates/kotlin/arkana_tests.kt.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% require_relative "lib/arkana/helpers/string" %>
<% require_relative "lib/arkana/helpers/kotlin_template_helper" %>
<% require "arkana/helpers/string" %>
<% require "arkana/helpers/kotlin_template_helper" %>
// DO NOT MODIFY
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)
package <%= @kotlin_package_name %>
Expand Down
4 changes: 2 additions & 2 deletions lib/arkana/templates/swift/arkana.swift.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% require_relative "lib/arkana/helpers/string" %>
<% require_relative "lib/arkana/helpers/swift_template_helper" %>
<% require "arkana/helpers/string" %>
<% require "arkana/helpers/swift_template_helper" %>
<% # TODO: Sort these import statements alphabetically %>
// DO NOT MODIFY
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)
Expand Down
4 changes: 2 additions & 2 deletions lib/arkana/templates/swift/arkana_protocol.swift.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% require_relative "lib/arkana/helpers/string" %>
<% require_relative "lib/arkana/helpers/swift_template_helper" %>
<% require "arkana/helpers/string" %>
<% require "arkana/helpers/swift_template_helper" %>
// DO NOT MODIFY
// Automatically generated by Arkana (https://github.com/rogerluan/arkana)

Expand Down
Loading