Refactor initialization logic after dropping support for Redmine 4 #412
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test with PostGIS | |
env: | |
PLUGIN_NAME: ${{ github.event.repository.name }} | |
on: | |
push: | |
branches: | |
- main | |
- next | |
pull_request: | |
branches: | |
- main | |
- next | |
workflow_dispatch: | |
jobs: | |
test: | |
name: redmine:${{ matrix.redmine_version }} ruby:${{ matrix.ruby_version }} postgis:${{ matrix.db_version }} | |
runs-on: ubuntu-22.04 | |
container: | |
image: ruby:${{ matrix.ruby_version }}-bullseye | |
strategy: | |
fail-fast: false | |
matrix: | |
redmine_version: [5.1-stable, 6.0-stable, master] | |
ruby_version: ['3.1', '3.2', '3.3'] | |
db_version: [13-3.4, 17-3.5] | |
include: | |
- system_test: true | |
redmine_version: 6.0-stable | |
ruby_version: '3.3' | |
exclude: | |
- redmine_version: 5.1-stable | |
ruby_version: '3.3' | |
- redmine_version: master | |
services: | |
postgres: | |
image: postgis/postgis:${{ matrix.db_version }} | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Checkout Redmine | |
uses: actions/checkout@v4 | |
with: | |
repository: redmine/redmine | |
ref: ${{ matrix.redmine_version }} | |
path: redmine | |
- name: Checkout Plugin | |
uses: actions/checkout@v4 | |
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: Prepare Plugin | |
working-directory: redmine/plugins/redmine_gtt | |
run: | | |
yarn | |
npx webpack | |
- name: Prepare Redmine source | |
working-directory: redmine | |
run: | | |
cat <<EOF > config/database.yml | |
test: | |
adapter: postgis | |
database: redmine | |
host: postgres | |
username: postgres | |
password: postgres | |
encoding: utf8 | |
EOF | |
- name: Adjust Gem environment | |
run: | | |
case "${{ matrix.redmine_version }}" in | |
5.1-stable) | |
echo "GEM_RGEO_ACTIVERECORD_VERSION=7.0.1" >> ${GITHUB_ENV} | |
echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=7.1.1" >> ${GITHUB_ENV} | |
;; | |
esac | |
- name: Install Ruby dependencies | |
working-directory: redmine | |
run: | | |
bundle config set --local without 'development' | |
bundle install --jobs=4 --retry=3 | |
- 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 | |
- 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 | |
- 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 rails test plugins/redmine_gtt/test/unit | |
bundle exec rails test plugins/redmine_gtt/test/functional | |
bundle exec rails test plugins/redmine_gtt/test/integration | |
if [ ${{ matrix.system_test }} = "true" ]; then | |
bundle exec rails test plugins/redmine_gtt/test/system | |
fi | |
- name: Run uninstall test | |
env: | |
RAILS_ENV: test | |
working-directory: redmine | |
run: bundle exec rake redmine:plugins:migrate NAME=${{ env.PLUGIN_NAME }} VERSION=0 |