build #7187
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: | |
- master | |
- development | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+-*' | |
pull_request: | |
branches: | |
- master | |
- development | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
build: | |
if: | | |
!( | |
contains(github.event.head_commit.message, '[ci skip]') || | |
contains(github.event.head_commit.message, '[ci-skip]') || | |
contains(github.event.head_commit.message, '[skip ci]') || | |
contains(github.event.head_commit.message, '[skip-ci]') | |
) | |
env: | |
PGHOST: 127.0.0.1 | |
PGUSER: postgres | |
RAILS_ENV: test | |
CROSSREF_EMAIL: ${{ secrets.CROSSREF_EMAIL }} | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
worker: [0, 1, 2, 3] | |
services: | |
db: | |
image: postgis/postgis:16-3.5 | |
ports: ['5432:5432'] | |
env: | |
POSTGRES_HOST_AUTH_METHOD: trust | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Get startup date | |
id: datetime | |
run: | | |
echo "iso_date=$(date --iso-8601 -u)" >> $GITHUB_OUTPUT | |
echo "year_week=$(date -u +'%Y-%U')" >> $GITHUB_OUTPUT | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
- name: Set up Ruby Bundler gems cache | |
uses: actions/cache@v4 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('.ruby-version', '**/Gemfile', '**/Gemfile.lock', 'exe/install-imagemagick7.sh') }} | |
- name: Set up Node 18 LTS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Set up Node packages cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.npm | |
**/node_modules | |
key: ${{ runner.os }}-node-18-${{ hashFiles('**/package-lock.json') }} | |
- name: Set up assets cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
tmp/cache/shakapacker | |
public/assets | |
public/packs-test | |
key: ${{ runner.os }}-assets-${{ steps.datetime.outputs.iso_date }}-${{ hashFiles('app/javascript/**', 'app/assets/**') }} | |
restore-keys: | | |
${{ runner.os }}-assets-${{ steps.datetime.outputs.iso_date }} | |
- name: Set up VCR cache | |
uses: actions/cache@v4 | |
with: | |
path: spec/fixtures/vcr_cassettes | |
key: ${{ runner.os }}-vcr-rev2-${{ steps.datetime.outputs.year_week }}-${{ hashFiles('**/Gemfile.lock') }}-${{ matrix.worker }} | |
- name: Install apt packages | |
run: | | |
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list | |
sudo apt-get update | |
sudo apt-get install -y tesseract-ocr libgeos-dev libproj-dev | |
- name: Change ownership of /usr/src to runner user to allow cache to be restored | |
run: sudo chown $(id -u) /usr/src | |
- name: Set up imagemagick cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
/usr/src/libheif-* | |
/usr/src/libde265-* | |
/usr/src/ImageMagick-7* | |
key: ${{ runner.os }}-imagemagick-${{ hashFiles('**/Gemfile.lock', 'exe/install-imagemagick7.sh') }} | |
- name: Change ownership of /usr/src back to root | |
run: | | |
sudo chown root /usr/src | |
sudo chown -R root /usr/src/libheif-* /usr/src/libde265-* /usr/src/ImageMagick-7* || true | |
- name: Install imagemagick | |
run: | | |
sudo apt-get purge -y imagemagick | |
sudo exe/install-imagemagick7.sh | |
- name: Set up TaxonWorks config files | |
run: | | |
cp config/application_settings.yml.ci config/application_settings.yml | |
cp config/secrets.yml.example config/secrets.yml | |
cp config/database.yml.ci config/database.yml | |
- name: Install Ruby gems | |
run: | | |
gem install bundler | |
bundle config path vendor/bundle | |
bundle install --jobs 4 --retry 3 | |
- name: Install Node packages | |
run: | | |
npm install | |
- name: Set up database | |
run: | | |
bundle exec rails db:create | |
bundle exec rails db:migrate | |
- name: Precompile assets | |
run: bundle exec rails assets:precompile | |
- name: Run tests | |
env: | |
TEST_WORKER: ${{ matrix.worker }} | |
TEST_WORKERS: 4 | |
run: .github/spec_runner.sh |