diff --git a/.github/workflows/adjust_gem_env.sh b/.github/workflows/adjust_gem_env.sh new file mode 100644 index 0000000..640fe09 --- /dev/null +++ b/.github/workflows/adjust_gem_env.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +case "${{ matrix.redmine_version }}" in + master) + echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=9.0.1" >> ${GITHUB_ENV} + ;; +esac diff --git a/.github/workflows/install_ruby_dependencies.sh b/.github/workflows/install_ruby_dependencies.sh new file mode 100644 index 0000000..13e26e7 --- /dev/null +++ b/.github/workflows/install_ruby_dependencies.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +bundle config set --local without 'development' +bundle install --jobs=4 --retry=3 diff --git a/.github/workflows/prepare_plugin.sh b/.github/workflows/prepare_plugin.sh new file mode 100644 index 0000000..95408e7 --- /dev/null +++ b/.github/workflows/prepare_plugin.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +yarn +npx webpack diff --git a/.github/workflows/prepare_redmine.sh b/.github/workflows/prepare_redmine.sh new file mode 100644 index 0000000..148b05d --- /dev/null +++ b/.github/workflows/prepare_redmine.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +cat < config/database.yml + test: + adapter: postgis + database: redmine + host: postgres + username: postgres + password: postgres + encoding: utf8 +EOF diff --git a/.github/workflows/run_rake_tasks.sh b/.github/workflows/run_rake_tasks.sh new file mode 100644 index 0000000..ae05094 --- /dev/null +++ b/.github/workflows/run_rake_tasks.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +bundle exec rake generate_secret_token +bundle exec rake db:create db:migrate redmine:plugins:migrate diff --git a/.github/workflows/run_tests.sh b/.github/workflows/run_tests.sh new file mode 100644 index 0000000..aeca417 --- /dev/null +++ b/.github/workflows/run_tests.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +bundle exec rake redmine:plugins:test:units NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" +bundle exec rake redmine:plugins:test:functionals NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" +bundle exec rake redmine:plugins:test:integration NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" +if [ "${{ matrix.system_test }}" = "true" ]; then + bundle exec rake redmine:plugins:test:system NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" +fi diff --git a/.github/workflows/run_uninstall_test.sh b/.github/workflows/run_uninstall_test.sh new file mode 100644 index 0000000..1a27e07 --- /dev/null +++ b/.github/workflows/run_uninstall_test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +bundle exec rake redmine:plugins:migrate NAME=${{ env.PLUGIN_NAME }} VERSION=0 diff --git a/.github/workflows/setup_environment.sh b/.github/workflows/setup_environment.sh new file mode 100644 index 0000000..8c5dfa5 --- /dev/null +++ b/.github/workflows/setup_environment.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +apt-get update --yes --quiet +apt-get install --yes --quiet postgresql-client gcc libpq-dev make patch libgeos-dev curl + +# For system test +if [ "${{ matrix.system_test }}" = "true" ]; then + wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - + sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' + apt-get -y update + apt-get install -y google-chrome-stable +fi + +curl -sL https://deb.nodesource.com/setup_20.x | bash - +curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list +apt-get update --yes --quiet +apt-get install --yes --quiet --no-install-recommends nodejs yarn diff --git a/.github/workflows/test-postgis.yml b/.github/workflows/test-postgis.yml index 6e51c4e..7de80c9 100644 --- a/.github/workflows/test-postgis.yml +++ b/.github/workflows/test-postgis.yml @@ -60,97 +60,45 @@ jobs: with: path: redmine/plugins/${{ env.PLUGIN_NAME }} - - name: Update package archives - run: apt-get update --yes --quiet - - - name: Install package dependencies - run: | - apt-get install --yes --quiet \ - postgresql-client \ - gcc libpq-dev make patch libgeos-dev curl - # For system test - if [ ${{ matrix.system_test }} = "true" ]; then - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - - sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' - apt-get -y update - apt-get install -y google-chrome-stable - fi - - - name: Install Node/Yarn packages - run: | - curl -sL https://deb.nodesource.com/setup_20.x | bash - - curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list - apt-get update --yes --quiet - apt-get install --yes --quiet --no-install-recommends nodejs yarn + - name: Setup Environment + run: ./setup_environment.sh - name: Prepare Plugin - working-directory: redmine/plugins/redmine_gtt - run: | - yarn - npx webpack + working-directory: redmine/plugins/${{ env.PLUGIN_NAME }} + run: ./prepare_plugin.sh - name: Prepare Redmine source working-directory: redmine - run: | - cat < config/database.yml - test: - adapter: postgis - database: redmine - host: postgres - username: postgres - password: postgres - encoding: utf8 - EOF + run: ./prepare_redmine.sh - name: Adjust Gem environment - run: | - case "${{ matrix.redmine_version }}" in - master) - echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=9.0.1" >> ${GITHUB_ENV} - ;; - esac + run: ./adjust_gem_env.sh - name: Install Ruby dependencies working-directory: redmine - run: | - bundle config set --local without 'development' - bundle install --jobs=4 --retry=3 + run: ./install_ruby_dependencies.sh - name: Run Redmine rake tasks env: RAILS_ENV: test working-directory: redmine - run: | - bundle exec rake generate_secret_token - bundle exec rake db:create db:migrate redmine:plugins:migrate + run: ./run_rake_tasks.sh - name: Zeitwerk check env: RAILS_ENV: test working-directory: redmine - run: | - if grep -q zeitwerk config/application.rb ; then - bundle exec rake zeitwerk:check - fi - shell: bash + run: ./zeitwerk_check.sh - name: Run tests env: RAILS_ENV: test - # For system test in plugin GOOGLE_CHROME_OPTS_ARGS: "headless,disable-gpu,no-sandbox,disable-dev-shm-usage" working-directory: redmine - run: | - bundle exec rake redmine:plugins:test:units NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" - bundle exec rake redmine:plugins:test:functionals NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" - bundle exec rake redmine:plugins:test:integration NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" - if [ ${{ matrix.system_test }} = "true" ]; then - bundle exec rake redmine:plugins:test:system NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0" - fi + run: ./run_tests.sh - name: Run uninstall test env: RAILS_ENV: test working-directory: redmine - run: bundle exec rake redmine:plugins:migrate NAME=${{ env.PLUGIN_NAME }} VERSION=0 + run: ./run_uninstall_test.sh diff --git a/.github/workflows/zeitwerk_check.sh b/.github/workflows/zeitwerk_check.sh new file mode 100644 index 0000000..a78117f --- /dev/null +++ b/.github/workflows/zeitwerk_check.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if grep -q zeitwerk config/application.rb ; then + bundle exec rake zeitwerk:check +fi