Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hidakatsuya committed Jul 21, 2024
1 parent 9e177bf commit 19ce0fe
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 12 deletions.
80 changes: 69 additions & 11 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Test
description: Test the image
description: Test the image and the redmined

runs:
using: composite
Expand All @@ -17,22 +17,80 @@ runs:
ref: master
path: redmine-src

- run: |
docker volume create redmine-bundle-cache
- name: Set up redmined
run: |
chmod +x redmined
mkdir $HOME/.local/bin
cp redmined $HOME/.local/bin
cd redmine-src
echo "REDMINED_IMAGE=redmined:test" >> $GITHUB_ENV
echo 'REDMINED_CONTAINER_ENVS="CUSTOM_ENV1=1 CUSTOM_ENV2=2"' >> $GITHUB_ENV
echo "REDMINED_REDMINE_PORT=3001" >> $GITHUB_ENV
shell: bash

- name: Set up Redmine
run: |
chmod a+w -R .
cat <<EOS > config/database.yml
development:
adapter: sqlite3
database: db/development.sqlite3
test:
adapter: sqlite3
database: db/development.sqlite3
EOS
docker run --rm \
-v ${PWD}:/redmine \
-v redmine-bundle-cache:/bundle \
-u root:root --entrypoint "" \
redmined:test \
bash -c "bundle install && bin/rails db:prepare && RAILS_ENV=development bin/about"
shell: bash
redmined bundle install
redmined bin/rails db:prepare
shell: script -q -e -c "bash {0}"
working-directory: redmine-src

- name: Test
run: |
docker volume ls
redmined cat /etc/os-release
redmined env RAILS_ENV=development bin/about
redmined printenv | grep CUSTOM_ENV1=9 || exit 1
# redmined ruby -e "ENV['CUSTOM_ENV1'] == '9' || exit(1)"
# redmined ruby -e "ENV['CUSTOM_ENV2'] == '2' || exit(1)"
# redmined ruby -e "ENV['PORT'] == '3001' || exit(1)"
redmined bin/rails test test/unit/news_test.rb
redmined bin/rails test test/system/my_page_test.rb
shell: script -q -e -c "bash {0}"
working-directory: redmine-src

- name: Test the indivisual settings
run: |
cat <<EOS > .redmined.json
{
"default": {
"name": "default",
"port": "4000",
"env": {
"DEFAULT_ENV": "1"
}
},
"other1": {
"name": "other1",
"port": "4001",
"env": {
"OTHER1_ENV": "1"
}
}
}
EOS
# Test against default
redmined ruby -e "ENV['DEFAULT_ENV'] == '1' || exit(1)"
redmined ruby -e "ENV['PORT'] == '4000' || exit(1)"
# Test against other1
redmined -n other1 ruby -e "ENV['OTHER1_ENV'] == '1' || exit(1)"
redmined -n other1 ruby -e "ENV['PORT'] == '4001' || exit(1)"
shell: script -q -e -c "bash {0}"
working-directory: redmine-src
2 changes: 1 addition & 1 deletion .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and publish
name: main

on:
push:
Expand Down

0 comments on commit 19ce0fe

Please sign in to comment.