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 2be7542
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 43 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build

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

jobs:
build:
runs-on: ubuntu-latest

steps:
- run: pwd
- 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
107 changes: 64 additions & 43 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,79 +16,99 @@ inputs:
required: true
default: 'sqlite3'

services:
chrome:
image: selenium/standalone-chrome
options: >-
--shm-size=2g
--headless
--no-sandbox
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
steps:
- name: Set GitHub Path
run: echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
shell: bash
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
GITHUB_ACTION_PATH: ${{ github.action_path }}

- run: |
echo "CAPYBARA_SERVER_HOST=chrome" >> $GITHUB_ENV
echo "CAPYBARA_SERVER_PORT=4444" >> $GITHUB_ENV
echo "RAILS_ENV=test" >> $GITHUB_ENV
shell: bash
steps:
- run: |
apt-get update; \
apt-get install -y --no-install-recommends \
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
with:
path: .
key: ${{ inputs.repository }}-${{ inputs.version }}-${{ github.sha }}
# - uses: actions/cache/restore@v4
# id: cache-source-restore
# with:
# path: .
# key: ${{ inputs.repository }}-${{ inputs.version }}-${{ github.sha }}

- 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
id: cache-source
with:
path: .
key: ${{ inputs.repository }}-${{ inputs.version }}-${{ github.sha }}
# - uses: actions/cache/save@v4
# id: cache-source
# with:
# path: .
# 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
- run: |
ps aux | grep chrome
shell: bash

0 comments on commit 2be7542

Please sign in to comment.