From 45529018cebfe912137e46f291d30508a69fe079 Mon Sep 17 00:00:00 2001 From: Katsuya Hidaka Date: Sun, 12 May 2024 17:58:27 +0900 Subject: [PATCH] Add GitHub Actions workflow for building the project --- .github/workflows/build.yml | 25 +++++++++++++ action.yml | 74 ++++++++++++++++++++----------------- 2 files changed, 66 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ccd2edf --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/action.yml b/action.yml index 6b0bfe0..2825f0d 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,6 @@ name: Setup Redmine description: Setup Redmine or its distribution for testing +author: hidakatsuya inputs: repository: @@ -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 @@ -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 @@ -67,27 +74,28 @@ runs: key: ${{ inputs.repository }}-${{ inputs.version }}-${{ github.sha }} - run: | - case ${{ inputs.database }} in + case "${{ inputs.database }}" in sqlite3) cat < config/database.yml - test: - adapter: sqlite3 - database: db/test.sqlite3 - EOS + test: + adapter: sqlite3 + database: db/test.sqlite3 + EOS ;; postgresql) - cat < config/database.yml - test: - adapter: postgresql - encoding: utf8 - host: postgres - port: 5432 - username: postgres - password: postgres - EOS + cat < 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