-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (82 loc) · 2.74 KB
/
rails_ci_tests.yml
File metadata and controls
86 lines (82 loc) · 2.74 KB
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
name: Ruby and/or Rails static analyses
on:
workflow_call:
inputs:
ruby-version:
description: "Ruby version to install"
type: string
required: false
default: ""
jobs:
specs:
runs-on: [ self-hosted, shgar-ubuntu20 ]
env:
RAILS_ENV: test
DATABASE_URL: 'mysql2://127.0.0.1' # shogo82148/actions-setup-mysql@v1 doesn't work with socket
steps:
- uses: tedconf/setup-ruby@1.1.0
with:
ssh-private-key: ${{ secrets.TEDCONF_GH_ACTIONS_JENKINS_PRIV_SSH_KEY }}
rubygems-key: ${{ secrets.BUNDLE_RUBYGEMS__TED__COM }}
ruby-version: ${{ inputs.ruby-version }}
- name: Check for coyote gem
shell: bash
run: |
echo "coyote_count=$(grep coyote Gemfile.lock | wc -l)" >> $GITHUB_ENV
- name: Configure sysctl limits on localhost to be able to run Elasticsearch
# Required to get Elasticsearch container to run on shgar host
shell: bash
if: env.coyote_count > 0
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Setup and start Elasticsearch
uses: tedconf/elasticsearch-github-actions@lee-self_hosted
if: env.coyote_count > 0
with:
stack-version: 6.8.23
plugins: 'analysis-icu analysis-phonetic'
- name: Elasticsearch is reachable
if: env.coyote_count > 0
run: |
curl --verbose --show-error http://localhost:9200
- name: Check if database is needed
shell: bash
run: |
has_db_yml=0
if [ -f "./config/database.yml" ]; then
has_db_yml=1
fi
echo "uses_db=$has_db_yml" >> $GITHUB_ENV
- name: Set up test secrets
if: env.uses_db > 0
run: cp config/secrets.github.yml config/secrets.yml
- name: Setup MySQL
# Workaround for MySQL in ACT until
# https://bugs.launchpad.net/ubuntu/focal/+source/mysql-8.0/+bug/1899248 is
# released
if: env.uses_db > 0 && env.ACT
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: '8.0'
root-password: root
- name: Start MySQL
if: ${{ env.uses_db > 0 && !env.ACT }}
run: sudo /etc/init.d/mysql start
- name: Create DB
if: env.uses_db > 0
env:
RAILS_ENV: test
run: |
bundle exec rails db:create
bundle exec rails db:schema:load
- name: Run tests
run: |
bundle exec rspec
# prevent accidentally leaking secrets
- name: Remove test secrets
if: env.uses_db > 0
run: |
rm config/secrets.yml