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 c9be49b
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 60 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
126 changes: 66 additions & 60 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,84 @@ inputs:
required: true
default: 'sqlite3'

env:
REDMINE_SRC: redmine-src

runs:
using: composite

pre-if: ${{ runner.os == 'Linux' }}
steps:
- run: |
echo "$GITHUB_ACTION_PATH" >> $GITHUB_PATH
echo "$REDMINE_SRC" >> $GITHUB_ENV
shell: bash
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
REDMINE_SRC: redmine-src
services:
chrome:
image: selenium/standalone-chrome
ports:
- 4444:4444
postgres:
image: postgres:14
- run: |
echo "$RAILS_ENV" >> $GITHUB_ENV
shell: bash
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
RAILS_ENV: test
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.version }}
path: ${{ env.REDMINE_SRC }}

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 \
libnss3-dev \
; \
rm -rf /var/lib/apt/lists/*; \
sed -ri 's/(rights)="none" (pattern="PDF")/\1="read" \2/' /etc/ImageMagick-6/policy.xml;
libnss3-dev;
- uses: actions/cache/restore@v4
id: cache-source-restore
with:
path: .
key: ${{ inputs.repository }}-${{ inputs.version }}-${{ github.sha }}
sudo sed -ri 's/(rights)="none" (pattern="PDF")/\1="read" \2/' /etc/ImageMagick-6/policy.xml;
shell: bash
- uses: actions/checkout@v4
if: steps.cache-source-restore.outputs.cache-hit != 'true'
with:
repository: ${{ inputs.repository }}-${{ github.sha }}
ref: ${{ inputs.version }}
- run: |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get update && apt-get install -y --no-install-recommends google-chrome-stable; \
- uses: actions/cache/save@v4
id: cache-source
with:
path: .
key: ${{ inputs.repository }}-${{ inputs.version }}-${{ github.sha }}
echo GOOGLE_CHROME_OPTS_ARGS="headless,disable-gpu,no-sandbox,disable-dev-shm-usage" >> $GITHUB_ENV
shell: bash
- run: |
case ${{ inputs.database }} in
sqlite3)
cat <<EOS > config/database.yml
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
;;
*)
echo "Unknown database: ${{ inputs.database }}"
exit 1
;;
esac
- if: ${{ inputs.database == 'postgresql' }}
run: |
sudo apt-get install libpq-dev
docker run \
--name redmine-postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
-d postgres:14
cat <<EOS > config/database.yml
test:
adapter: postgresql
encoding: utf8
host: localhost
port: 5432
username: postgres
password: postgres
EOS
shell: bash
working-directory: ${{ env.REDMINE_SRC }}

- if: ${{ inputs.database == 'sqlite3' }}
run: |
sudo apt-get install libsqlite3-dev
cat <<EOS > config/database.yml
test:
adapter: sqlite3
database: db/test.sqlite3
EOS
shell: bash
working-directory: ${{ env.REDMINE_SRC }}

0 comments on commit c9be49b

Please sign in to comment.