From 04f546f485212e1e22849848feecc651bf665ddb Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Mon, 11 Nov 2024 21:52:05 +0000 Subject: Run tests on Github as secondary CI environment using the following matrix: * ruby: 3.1, 3.2, 3.3 * database mysql 8, postgresql 13 (#30069) git-svn-id: https://svn.redmine.org/redmine/trunk@23254 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .github/workflows/linters.yml | 21 +++++++++ .github/workflows/rubyonrails.yml | 17 ------- .github/workflows/tests.yml | 96 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/linters.yml delete mode 100644 .github/workflows/rubyonrails.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 000000000..297e28116 --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,21 @@ +name: Lint + +on: + push: + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + bundler-cache: true + + - name: Lint code for consistent style + run: bundle exec rubocop --parallel diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml deleted file mode 100644 index 07882bdc8..000000000 --- a/.github/workflows/rubyonrails.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: "Ruby on Rails CI" -on: - push: - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Ruby and gems - uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 - with: - ruby-version: 3.2 - bundler-cache: true - - name: Lint Ruby files - run: bundle exec rubocop --parallel diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..6a61051c5 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,96 @@ +name: Tests + +on: + push: + +jobs: + tests: + name: test ${{matrix.db}} ruby-${{ matrix.ruby }} + runs-on: ubuntu-latest + + strategy: + matrix: + ruby: ['3.1', '3.2', '3.3'] + db: ['postgresql', 'mysql'] + fail-fast: false + + services: + postgres: + image: postgres:13 + env: + POSTGRES_DB: redmine_test + POSTGRES_USER: root + POSTGRES_PASSWORD: root + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + mysql: + image: mysql:8.0 + env: + MYSQL_DATABASE: redmine_test + MYSQL_ROOT_PASSWORD: 'root' + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install package dependencies + run: > + sudo apt-get install --yes --quiet + ghostscript + gsfonts + + - name: Allow imagemagick to read PDF files + run: | + echo '' > policy.xml + echo '' >> policy.xml + echo '' >> policy.xml + sudo rm /etc/ImageMagick-6/policy.xml + sudo mv policy.xml /etc/ImageMagick-6/policy.xml + + - name: Install Ruby and gems + uses: ruby/setup-ruby@v1.176.0 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Prepare Redmine configuration for PostgreSQL + run: | + cp config/database.yml.example config/database.yml + sed -i -e "s/mysql2$/postgresql/g" config/database.yml + sed -i -e "s/host:.*$/host: localhost/g" config/database.yml + sed -i -e "s/password:.*$/password: root/g" config/database.yml + sed -i -e "41,43d" config/database.yml + if: matrix.db == 'postgresql' + + - name: Prepare Redmine configuration for MySQL + run: | + cp config/database.yml.example config/database.yml + sed -i -e "s/host:.*$/host: 127.0.0.1/g" config/database.yml + sed -i -e "s/password:.*$/password: root/g" config/database.yml + if: matrix.db == 'mysql' + + - name: Install dependencies + env: + RAILS_ENV: test + run: bundle install --jobs=4 --retry=3 + + - name: Run DB migration + env: + RAILS_ENV: test + run: bundle exec rake db:migrate + + - name: Run tests + run: bin/rails test -- cgit v1.2.3