Skip to content

Commit

Permalink
Use scripts in workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kastl <daniel@georepublic.de>
  • Loading branch information
dkastl committed Jun 7, 2024
1 parent 628fec8 commit 6d6ed26
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 63 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/adjust_gem_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

case "${{ matrix.redmine_version }}" in
master)
echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=9.0.1" >> ${GITHUB_ENV}
;;
esac
4 changes: 4 additions & 0 deletions .github/workflows/install_ruby_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

bundle config set --local without 'development'
bundle install --jobs=4 --retry=3
4 changes: 4 additions & 0 deletions .github/workflows/prepare_plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

yarn
npx webpack
11 changes: 11 additions & 0 deletions .github/workflows/prepare_redmine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cat <<EOF > config/database.yml
test:
adapter: postgis
database: redmine
host: postgres
username: postgres
password: postgres
encoding: utf8
EOF
4 changes: 4 additions & 0 deletions .github/workflows/run_rake_tasks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

bundle exec rake generate_secret_token
bundle exec rake db:create db:migrate redmine:plugins:migrate
8 changes: 8 additions & 0 deletions .github/workflows/run_tests.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .github/workflows/run_uninstall_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

bundle exec rake redmine:plugins:migrate NAME=${{ env.PLUGIN_NAME }} VERSION=0
18 changes: 18 additions & 0 deletions .github/workflows/setup_environment.sh
Original file line number Diff line number Diff line change
@@ -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
74 changes: 11 additions & 63 deletions .github/workflows/test-postgis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF > 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
5 changes: 5 additions & 0 deletions .github/workflows/zeitwerk_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

if grep -q zeitwerk config/application.rb ; then
bundle exec rake zeitwerk:check
fi

0 comments on commit 6d6ed26

Please sign in to comment.