-
Notifications
You must be signed in to change notification settings - Fork 28
155 lines (132 loc) · 4.3 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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 22 LTS
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Set up Node packages cache
uses: actions/cache@v4
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-node-22-${{ 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