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

DEV: Pull compatible themes in tests workflow #27093

Merged
merged 1 commit into from
May 21, 2024

Conversation

tgxworld
Copy link
Contributor

This commit adds a step in our tests workflow on Github actions to update the themes to
use the compatible version when not running aginast the main branch.
This is to ensure that we are not running
the tests for themes against an incompatible version of Discourse.

@tgxworld tgxworld force-pushed the pull_compatible_theme_main branch from fbfec8d to bd6f652 Compare May 21, 2024 02:05
Comment on lines +239 to +252
# Checkout value of the version compat
if checkout_version
puts "checking out compatible #{theme_name} version: #{checkout_version}"

update_status =
system(
"git -C '#{theme_path}' cat-file -e #{checkout_version} || git -C '#{theme_path}' fetch --depth 1 $(git -C '#{theme_path}' rev-parse --symbolic-full-name @{upstream} | awk -F '/' '{print $3}') #{checkout_version}; git -C '#{theme_path}' reset --hard #{checkout_version}",
)

abort("Unable to checkout a compatible theme version") unless update_status
else
puts "#{theme_name} is already at latest compatible version"
end
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is adapted from

checkout_version = Discourse.find_compatible_git_resource(plugin_path)
# Checkout value of the version compat
if checkout_version
puts "checking out compatible #{plugin} version: #{checkout_version}"
update_status =
system(
"git -C '#{plugin_path}' cat-file -e #{checkout_version} || git -C '#{plugin_path}' fetch --depth 1 $(git -C '#{plugin_path}' rev-parse --symbolic-full-name @{upstream} | awk -F '/' '{print $3}') #{checkout_version}; git -C '#{plugin_path}' reset --hard #{checkout_version}",
)
abort("Unable to checkout a compatible plugin version") unless update_status
else
puts "#{plugin} is already at latest compatible version"
end
but the use case is so specific to our use in Github actions that I don't think it is a huge deal for us to just duplicate code here.

This commit adds a step in our tests workflow on Github actions to update the themes to
use the compatible version when not running aginast the `main` branch.
This is to ensure that we are not running
the tests for themes against an incompatible version of Discourse.
@tgxworld tgxworld force-pushed the pull_compatible_theme_main branch from bd6f652 to e877642 Compare May 21, 2024 02:17
Copy link
Contributor

@martin-brennan martin-brennan left a comment

Choose a reason for hiding this comment

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

LGTM, I also think the duplication is fine for this 👍

.glob(File.expand_path("#{Rails.root}/tmp/themes/*"))
.select { |f| File.directory? f }
.each do |theme_path|
next unless File.directory?(theme_path + "/.git")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
next unless File.directory?(theme_path + "/.git")
next if !File.directory?(theme_path + "/.git")

:P

"git -C '#{theme_path}' cat-file -e #{checkout_version} || git -C '#{theme_path}' fetch --depth 1 $(git -C '#{theme_path}' rev-parse --symbolic-full-name @{upstream} | awk -F '/' '{print $3}') #{checkout_version}; git -C '#{theme_path}' reset --hard #{checkout_version}",
)

abort("Unable to checkout a compatible theme version") unless update_status
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
abort("Unable to checkout a compatible theme version") unless update_status
abort("Unable to checkout a compatible theme version") if !update_status

@tgxworld tgxworld merged commit 34c527d into main May 21, 2024
16 checks passed
@tgxworld tgxworld deleted the pull_compatible_theme_main branch May 21, 2024 02:38
@tgxworld
Copy link
Contributor Author

Thank you @martin-brennan 👍

CvX pushed a commit that referenced this pull request May 21, 2024
This commit adds a step in our tests workflow on Github actions to update the themes to
use the compatible version when not running aginast the `main` branch.
This is to ensure that we are not running
the tests for themes against an incompatible version of Discourse.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants