From 8b072ccc35748e513c27d392e33852f05ac740df Mon Sep 17 00:00:00 2001 From: Katsuya Hidaka Date: Wed, 10 Jul 2024 00:08:30 +0900 Subject: [PATCH 1/3] Define Redmine version environment variables --- action.yml | 6 ++++++ scripts/set-version-envs.sh | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 scripts/set-version-envs.sh diff --git a/action.yml b/action.yml index 96c5b37..7ca253d 100644 --- a/action.yml +++ b/action.yml @@ -45,6 +45,12 @@ runs: ref: ${{ inputs.version }} path: ${{ inputs.path }} + - name: Define Redmine version environment variables + run: ./scripts/set-version-envs.sh + shell: bash + env: + REDMINE_DIR: ${{ inputs.path }} + - name: Install dependencies run: | sudo apt-get update; \ diff --git a/scripts/set-version-envs.sh b/scripts/set-version-envs.sh new file mode 100755 index 0000000..f7d2b72 --- /dev/null +++ b/scripts/set-version-envs.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -eu + +file=$REDMINE_DIR/lib/redmine/version.rb + +version_major=$(grep -oE 'MAJOR *= *[0-9]+' $file | awk 'NR==1 {print $3}') +version_minor=$(grep -oE 'MINOR *= *[0-9]+' $file | awk 'NR==1 {print $3}') +version_tiny=$(grep -oE 'TINY *= *[0-9]+' $file | awk 'NR==1 {print $3}') +version_branch=$(grep -oE 'BRANCH *= *'\''.+?' $file | awk -F"'" 'NR==1 {print $2}') + +echo "Redmine Version: $version_major.$version_minor.$version_tiny.$version_branch" + +echo "REDMINE_VERSION_MAJOR=$version_major" >> $GITHUB_ENV +echo "REDMINE_VERSION_MINOR=$version_minor" >> $GITHUB_ENV +echo "REDMINE_VERSION_TINY=$version_tiny" >> $GITHUB_ENV +echo "REDMINE_VERSION_BRANCH=$version_branch" >> $GITHUB_ENV From 58abd9eb3c10f4a2248051524038b1230d8b1f6f Mon Sep 17 00:00:00 2001 From: Katsuya Hidaka Date: Wed, 10 Jul 2024 00:09:02 +0900 Subject: [PATCH 2/3] Use Redmine version environment variables --- .github/workflows/build.yml | 9 +++++++-- action.yml | 12 ++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e81ae54..4930574 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,6 +60,11 @@ jobs: database: ${{ matrix.redmine-database }} ruby-version: ${{ matrix.ruby-version }} + - name: Define Redmine version environment variables + run: ./scripts/set-version-envs.sh + env: + REDMINE_DIR: ${{ env.REDMINE_SRC }} + - name: Install a plugin for testing run: | cp -R ../.github/hello_world plugins/ @@ -76,8 +81,8 @@ jobs: - run: | bin/rails test test/unit/news_test.rb - # Run system test only when Zeitwerk is enabled (Redmine >= 5.0 or RedMica >= 2.1) - if grep -q zeitwerk config/application.rb ; then + # Run system test only if Redmine >= 5.0 or RedMica >= 2.1 + if [ $REDMINE_VERSION_MAJOR -ge 5 ]; then bin/rails test test/system/my_page_test.rb fi bin/rails redmine:plugins:test diff --git a/action.yml b/action.yml index 7ca253d..d79c655 100644 --- a/action.yml +++ b/action.yml @@ -142,14 +142,10 @@ runs: shell: bash working-directory: ${{ inputs.path }} - - name: Adjust Gemfile - run: | - # Ref: https://github.com/agileware-jp/redmine-plugin-orb/pull/70 - # https://www.redmine.org/issues/40802 - if grep -q "require 'blankslate'" lib/redmine/views/builders/structure.rb - then - echo 'gem "blankslate"' >> Gemfile - fi + # https://www.redmine.org/issues/40802 + - name: Fix LoadError in Redmine 4.2 + if: ${{ env.REDMINE_VERSION_MAJOR < 5 }} + run: echo "gem 'builder', '~> 3.2.4'" >> Gemfile.local shell: bash working-directory: ${{ inputs.path }} From 86ecd001b0822843aea3cdec5d6503060202ef09 Mon Sep 17 00:00:00 2001 From: Katsuya Hidaka Date: Wed, 10 Jul 2024 00:53:58 +0900 Subject: [PATCH 3/3] Separate steps for each test --- .github/workflows/build.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4930574..f8a20a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,8 @@ jobs: bin/rails redmine:plugins:migrate working-directory: ${{ env.REDMINE_SRC }} - - run: | + - name: Test Redmine environment + run: | about=$(bin/rails r "require 'redmine/version'; puts Redmine::Info.environment") echo "$about" echo "$about" | grep "${{ matrix.expected-about-db-adapter }}" @@ -79,11 +80,15 @@ jobs: echo "$about" | grep "hello_world" working-directory: ${{ env.REDMINE_SRC }} - - run: | - bin/rails test test/unit/news_test.rb - # Run system test only if Redmine >= 5.0 or RedMica >= 2.1 - if [ $REDMINE_VERSION_MAJOR -ge 5 ]; then - bin/rails test test/system/my_page_test.rb - fi - bin/rails redmine:plugins:test + - name: Run unit test + run: bin/rails test test/unit/news_test.rb + working-directory: ${{ env.REDMINE_SRC }} + + - name: Run system test if Redmine >= 5.0 + if: ${{ env.REDMINE_VERSION_MAJOR >= 5 }} + run: bin/rails test test/system/my_page_test.rb + working-directory: ${{ env.REDMINE_SRC }} + + - name: Run plugin test + run: bin/rails redmine:plugins:test working-directory: ${{ env.REDMINE_SRC }}