]> git.openstreetmap.org Git - rails.git/blob - .github/workflows/tests.yml
Merge remote-tracking branch 'upstream/pull/2994'
[rails.git] / .github / workflows / tests.yml
1 name: Tests
2 on:
3   - push
4   - pull_request
5 jobs:
6   test:
7     name: Ubuntu ${{ matrix.ubuntu }}, Ruby ${{ matrix.ruby }}
8     strategy:
9       matrix:
10         ubuntu: [18.04, 20.04]
11         ruby: [2.5, 2.7]
12     runs-on: ubuntu-${{ matrix.ubuntu }}
13     env:
14       RAILS_ENV: test
15       OPENSTREETMAP_MEMCACHE_SERVERS: 127.0.0.1
16     steps:
17     - name: Checkout source
18       uses: actions/checkout@v2
19     - name: Setup ruby
20       uses: actions/setup-ruby@v1
21       with:
22         ruby-version: ${{ matrix.ruby }}
23     - name: Cache gems
24       uses: actions/cache@v2
25       with:
26         path: vendor/bundle
27         key: bundle-ubuntu-${{ matrix.ubuntu }}-ruby-${{ matrix.ruby }}-${{ hashFiles('Gemfile.lock') }}
28         restore-keys: |
29           bundle-ubuntu-${{ matrix.ubuntu }}-ruby-${{ matrix.ruby }}-
30     - name: Cache node modules
31       uses: actions/cache@v1
32       with:
33         path: node_modules
34         key: yarn-ubuntu-${{ matrix.ubuntu }}-${{ hashFiles('yarn.lock') }}
35         restore-keys: |
36           yarn-ubuntu-${{ matrix.ubuntu }}-
37     - name: Install packages
38       run: |
39         sudo apt-get -yqq update
40         sudo apt-get -yqq install memcached
41     - name: Install gems
42       run: |
43         gem install bundler
44         bundle config set deployment true
45         bundle install --jobs 4 --retry 3
46     - name: Create database
47       run: |
48         sudo systemctl start postgresql
49         sudo -u postgres createuser -s $(id -un)
50         createdb openstreetmap
51         psql -c "CREATE EXTENSION btree_gist" openstreetmap
52         psql -f db/functions/functions.sql openstreetmap
53     - name: Configure rails
54       run: |
55         cp config/github.database.yml config/database.yml
56         cp config/example.storage.yml config/storage.yml
57         touch config/settings.local.yml
58     - name: Populate database
59       run: |
60         sed -f script/normalise-structure db/structure.sql > db/structure.expected
61         bundle exec rake db:migrate
62         sed -f script/normalise-structure db/structure.sql > db/structure.actual
63         diff -uw db/structure.expected db/structure.actual
64     - name: Export javascript strings
65       run: bundle exec rake i18n:js:export
66     - name: Install node modules
67       run: bundle exec rake yarn:install
68     - name: Run tests
69       run: bundle exec rake test:db
70     - name: Report completion to Coveralls
71       uses: coverallsapp/github-action@v1.1.2
72       with:
73         github-token: ${{ secrets.github_token }}
74         flag-name: ubuntu-${{ matrix.ubuntu }}-ruby-${{ matrix.ruby }}
75         parallel: true
76   finish:
77     name: Finalise
78     needs: test
79     runs-on: ubuntu-latest
80     steps:
81     - name: Report completion to Coveralls
82       uses: coverallsapp/github-action@v1.1.2
83       with:
84         github-token: ${{ secrets.github_token }}
85         parallel-finished: true