Skip to content

A platform for community discussion. Free, open, simple.

DEV: Run system tests for official themes (#24378)

Alan Guo Xiang Tan6ce55e53479d
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index baa96095260..ccb1f270c72 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -41,11 +41,17 @@ jobs:
matrix:
build_type: [backend, frontend, system, annotations]
- target: [core, plugins]
+ target: [core, plugins, themes]
ruby: ["3.2"]
exclude:
- build_type: annotations
target: plugins
+ - build_type: annotations
+ target: themes
+ - build_type: frontend
+ target: themes
+ - build_type: backend
+ target: themes
- build_type: frontend
target: core # Handled by core_frontend_tests job (below)
include:
@@ -113,6 +119,10 @@ jobs:
if: matrix.target == 'plugins'
run: bin/rake plugin:pull_compatible_all
+ - name: Checkout official themes
+ if: matrix.target == 'themes'
+ run: bin/rake themes:clone_all_official
+
- name: Add hosts to /etc/hosts, otherwise Chrome cannot reach minio
run: |
echo "127.0.0.1 minio.local" | sudo tee -a /etc/hosts
@@ -237,12 +247,19 @@ jobs:
LOAD_PLUGINS=1 RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error PARALLEL_TEST_PROCESSORS=4 bin/turbo_rspec --use-runtime-info --profile=50 --verbose --format documentation plugins/*/spec/system
shell: bash
timeout-minutes: 30
-
+
- name: Chat System Tests
if: matrix.build_type == 'system' && matrix.target == 'chat'
run: LOAD_PLUGINS=1 RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error PARALLEL_TEST_PROCESSORS=4 bin/turbo_rspec --use-runtime-info --profile=50 --verbose --format documentation plugins/chat/spec/system
timeout-minutes: 30
+ - name: Theme System Tests
+ if: matrix.build_type == 'system' && matrix.target == 'themes'
+ run: |
+ RAILS_ENABLE_TEST_LOG=1 RAILS_TEST_LOG_LEVEL=error PARALLEL_TEST_PROCESSORS=4 bin/turbo_rspec --profile=50 --verbose --format documentation tmp/themes/*/spec/system
+ shell: bash
+ timeout-minutes: 30
+
- name: Upload failed system test screenshots
uses: actions/upload-artifact@v3
if: matrix.build_type == 'system' && failure()
diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake
index e1fc052ac54..58c7b5d93be 100644
--- a/lib/tasks/themes.rake
+++ b/lib/tasks/themes.rake
@@ -194,3 +194,26 @@ ensure
db&.remove
redis&.remove
end
+
+desc "Clones all official themes."
+task "themes:clone_all_official" do |task, args|
+ require "theme_metadata"
+ FileUtils.rm_rf("tmp/themes")
+
+ official_themes =
+ ThemeMetadata::OFFICIAL_THEMES.each do |theme_name|
+ repo = "https://github.com/discourse/#{theme_name}"
+ path = File.expand_path("tmp/themes/#{theme_name}")
+
+ attempts = 0
+
+ begin
+ attempts += 1
+ system("git clone #{repo} #{path}", exception: true)
+ rescue StandardError
+ abort("Failed to clone #{repo}") if attempts >= 3
+ STDERR.puts "Failed to clone #{repo}... trying again..."
+ retry
+ end
+ end
+end
diff --git a/lib/theme_metadata.rb b/lib/theme_metadata.rb
new file mode 100644
index 00000000000..c6d3df4ae0d
--- /dev/null
+++ b/lib/theme_metadata.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class ThemeMetadata
+ OFFICIAL_THEMES =
+ Set.new(
+ %w[
+ discourse-brand-header
+ discourse-category-banners
+ discourse-clickable-topic
+ discourse-color-scheme-toggle
+ discourse-custom-header-links
+ Discourse-easy-footer
+ discourse-gifs
+ discourse-topic-thumbnails
+ discourse-search-banner
+ discourse-unanswered-filter
+ discourse-versatile-banner
+ DiscoTOC
+ unformatted-code-detector
+ ],
+ ).to_a
+end