Upload Redmine logs as test artifacts #23
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
# ------------------------------------------------------------------------------------------------------ # | |
# Redmine API Tests | |
# ------------------------------------------------------------------------------------------------------ # | |
name: 'Redmine API Tests' | |
# TODO: This should NOT run as often as everything else... perhaps a schedule? | |
on: | |
push | |
env: | |
# Location where Redmine instance must be installed | |
REDMINE_INSTALL_PATH: '${{ github.workspace }}/redmine' | |
# The default user for a new Redmine installation | |
# @see https://www.redmine.org/projects/redmine/wiki/RedmineInstall#Step-10-Logging-into-the-application | |
# REDMINE_USER: 'admin' # Should not be needed | |
# REDMINE_PASSWORD: 'admin' # Should not be needed | |
# Host, port and URL for Redmine instance | |
REDMINE_HOST: 'localhost' | |
REDMINE_PORT: 3000 | |
# REDMINE_URL: 'http://${{ env.REDMINE_HOST }}:${{ env.REDMINE_PORT }}' # Generated later... | |
# API Key (for testing only) | |
REDMINE_API_KEY: '${{ github.sha }}' | |
jobs: | |
redmine_api_tests: | |
name: "Redmine ${{ matrix.redmine-versions }} API Tests (using PHP ${{ matrix.php-versions }})" | |
runs-on: ${{ matrix.operating-system }} | |
strategy: | |
fail-fast: true | |
matrix: | |
# See OS and PHP version options on https://github.com/shivammathur/setup-php | |
operating-system: [ 'ubuntu-22.04' ] | |
php-versions: [ '8.2' ] | |
# Redmine versions (in this case branches) | |
redmine-versions: [ '5.0-stable' ] | |
steps: | |
# ------------------------------------------------------------------------------------------------------- # | |
# Setup & configure Redmine | |
# ------------------------------------------------------------------------------------------------------- # | |
- name: "Install Redmine" | |
uses: hidakatsuya/action-setup-redmine@v2 | |
with: | |
repository: 'redmine/redmine' | |
version: ${{ matrix.redmine-versions }} | |
database: 'sqlite3' | |
ruby-version: '3.1' | |
path: "${{ env.REDMINE_INSTALL_PATH }}" | |
# - name: "Debug: output redmine config dir" | |
# run: ls ${{ env.REDMINE_INSTALL_PATH }}/config | |
- name: "Enable REST Api" | |
uses: rmeneely/update-yaml@v1 | |
with: | |
infile: ${{ env.REDMINE_INSTALL_PATH }}/config/settings.yml | |
varlist: 'rest_api_enabled.default=1' | |
- name: "Set system API key" | |
uses: rmeneely/update-yaml@v1 | |
with: | |
infile: ${{ env.REDMINE_INSTALL_PATH }}/config/settings.yml | |
varlist: 'sys_api_key.default=${{ env.REDMINE_API_KEY }}' | |
# - name: "Debug: settings.xml" | |
# run: cat ${{ env.REDMINE_INSTALL_PATH }}/config/settings.yml | |
# @see https://guides.rubyonrails.org/command_line.html#bin-rails-server | |
- name: "Start Redmine" | |
run: | | |
cd ${{ env.REDMINE_INSTALL_PATH }} | |
nohup bundle exec rails server -e production -b ${{ env.REDMINE_HOST }} -p ${{ env.REDMINE_PORT }} & | |
- name: "Set Redmine URL variable" | |
run: | | |
echo "REDMINE_URL=http://${{ env.REDMINE_HOST }}:${{ env.REDMINE_PORT }}" >> $GITHUB_ENV | |
- name: "Check if Redmine is running" | |
run: curl --silent --show-error --head ${{ env.REDMINE_URL }} | |
- name: "Check if API is responding" | |
run: | | |
curl -H "X-Redmine-API-Key: ${{ env.REDMINE_API_KEY }}" --silent --show-error --head ${{ env.REDMINE_URL }}/issues.json | |
# ------------------------------------------------------------------------------------------------------- # | |
# Setup & configure PHP | |
# ------------------------------------------------------------------------------------------------------- # | |
- name: "Checkout Athenaeum" | |
uses: actions/checkout@v4 | |
- name: "Setup PHP" | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
# PHP Extensions are based on those that Laravel also uses.args: | |
# @see https://github.com/laravel/framework/blob/11.x/.github/workflows/tests.yml | |
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis-phpredis/[email protected], igbinary, msgpack, lzf, zstd, lz4, memcached, gmp | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2 | |
coverage: none | |
- name: "Install dependencies" | |
run: composer install --no-progress --prefer-dist --no-interaction --optimize-autoloader --ansi | |
# ------------------------------------------------------------------------------------------------------- # | |
# Run API Tests | |
# ------------------------------------------------------------------------------------------------------- # | |
- name: "Prepare test environment" | |
run: | | |
composer run test-env --ansi | |
vendor/bin/codecept build | |
- name: "Run API tests" | |
# Upload evt. error logs from Redmine as an artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: 'redmine_logs' | |
path: ${{ REDMINE_INSTALL_PATH }}/logs/ | |
# Ensure ENV are set... | |
# @see .testing.example | |
# @see https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsenv | |
env: | |
REDMINE_LIVE_TEST: true | |
REDMINE_API_URI: ${{ env.REDMINE_URL }} | |
REDMINE_TOKEN: ${{ env.REDMINE_API_KEY }} | |
run: vendor/bin/codecept run -g redmine --debug |