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