]> git.openstreetmap.org Git - rails.git/blob - .github/workflows/tests.yml
504bb94ab9afa8f1593759a7609cfa5388fdc3a4
[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: ruby/setup-ruby@v1
24       with:
25         ruby-version: ${{ matrix.ruby }}
26         bundler-cache: true
27     - name: Cache node modules
28       uses: actions/cache@v3
29       with:
30         path: node_modules
31         key: yarn-ubuntu-${{ matrix.ubuntu }}-${{ hashFiles('yarn.lock') }}
32         restore-keys: |
33           yarn-ubuntu-${{ matrix.ubuntu }}-
34     - name: Install packages
35       run: |
36         sudo apt-get -yqq update
37         sudo apt-get -yqq install memcached libvips-dev
38     - name: Create database
39       run: |
40         sudo systemctl start postgresql
41         sudo -u postgres createuser -s $(id -un)
42         createdb openstreetmap
43     - name: Configure rails
44       run: |
45         cp config/github.database.yml config/database.yml
46         cp config/example.storage.yml config/storage.yml
47         touch config/settings.local.yml
48     - name: Populate database
49       run: |
50         sed -f script/normalise-structure db/structure.sql > db/structure.expected
51         bundle exec rake db:migrate
52         sed -f script/normalise-structure db/structure.sql > db/structure.actual
53         diff -uw db/structure.expected db/structure.actual
54     - name: Export javascript strings
55       run: bundle exec rake i18n:js:export
56     - name: Install node modules
57       run: bundle exec rake yarn:install
58     - name: Run tests
59       run: bundle exec rails test:all
60     - name: Report completion to Coveralls
61       uses: coverallsapp/github-action@1.1.3
62       with:
63         github-token: ${{ secrets.github_token }}
64         flag-name: ubuntu-${{ matrix.ubuntu }}-ruby-${{ matrix.ruby }}
65         parallel: true
66   finish:
67     name: Finalise
68     needs: test
69     runs-on: ubuntu-latest
70     steps:
71     - name: Report completion to Coveralls
72       uses: coverallsapp/github-action@1.1.3
73       with:
74         github-token: ${{ secrets.github_token }}
75         parallel-finished: true