Skip to content

Commit

Permalink
Add GitHub Actions workflow for building the project
Browse files Browse the repository at this point in the history
  • Loading branch information
hidakatsuya committed May 12, 2024
1 parent 708ccf9 commit 4552901
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 33 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build

on:
push:
paths-ignore:
- '*.md'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: ./

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

- run: |
bin/rails db:prepare
bin/rails test test/unit/news_test.rb
bin/rails test test/system/my_page_test.rb
74 changes: 41 additions & 33 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Setup Redmine
description: Setup Redmine or its distribution for testing
author: hidakatsuya

inputs:
repository:
Expand All @@ -15,38 +16,44 @@ inputs:
required: true
default: 'sqlite3'

services:
chrome:
image: selenium/standalone-chrome
ports:
- 4444:4444
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432

runs:
using: composite

pre-if: ${{ runner.os == 'Linux' }}

services:
chrome:
image: selenium/standalone-chrome
ports:
- 4444:4444
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
env:
CAPYBARA_SERVER_HOST: chrome
CAPYBARA_SERVER_PORT: 4444
RAILS_ENV: test

steps:
- run: |
apt-get update; \
apt-get install -y --no-install-recommends \
echo $RAILS_ENV
sudo apt-get update; \
sudo apt-get install -y --no-install-recommends \
sudo build-essential curl wget vim \
bzr git mercurial subversion cvs \
ghostscript \
gsfonts \
imagemagick libmagick++-dev \
libsqlite3-dev \
libpgsql-dev \
libpq-dev \
libnss3-dev \
; \
rm -rf /var/lib/apt/lists/*; \
sed -ri 's/(rights)="none" (pattern="PDF")/\1="read" \2/' /etc/ImageMagick-6/policy.xml;
sudo rm -rf /var/lib/apt/lists/*; \
sudo sed -ri 's/(rights)="none" (pattern="PDF")/\1="read" \2/' /etc/ImageMagick-6/policy.xml;
shell: bash
- uses: actions/cache/restore@v4
id: cache-source-restore
Expand All @@ -57,7 +64,7 @@ runs:
- uses: actions/checkout@v4
if: steps.cache-source-restore.outputs.cache-hit != 'true'
with:
repository: ${{ inputs.repository }}-${{ github.sha }}
repository: ${{ inputs.repository }}
ref: ${{ inputs.version }}

- uses: actions/cache/save@v4
Expand All @@ -67,27 +74,28 @@ runs:
key: ${{ inputs.repository }}-${{ inputs.version }}-${{ github.sha }}

- run: |
case ${{ inputs.database }} in
case "${{ inputs.database }}" in
sqlite3)
cat <<EOS > config/database.yml
test:
adapter: sqlite3
database: db/test.sqlite3
EOS
test:
adapter: sqlite3
database: db/test.sqlite3
EOS
;;
postgresql)
cat <<EOF > config/database.yml
test:
adapter: postgresql
encoding: utf8
host: postgres
port: 5432
username: postgres
password: postgres
EOS
cat <<EOS > config/database.yml
test:
adapter: postgresql
encoding: utf8
host: postgres
port: 5432
username: postgres
password: postgres
EOS
;;
*)
echo "Unknown database: ${{ inputs.database }}"
exit 1
;;
esac
shell: bash

0 comments on commit 4552901

Please sign in to comment.