]> git.openstreetmap.org Git - rails.git/blob - .github/workflows/tests.yml
d1cf73eaefc7d239a7fe5af072007ee702f3d236
[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: Ruby ${{ matrix.ruby }}
11     strategy:
12       matrix:
13         ruby: ['3.1', '3.2', '3.3', '3.4']
14     runs-on: ubuntu-latest
15     env:
16       RAILS_ENV: test
17       OPENSTREETMAP_MEMCACHE_SERVERS: 127.0.0.1
18     steps:
19     - name: Checkout source
20       uses: actions/checkout@v4
21     - name: Setup ruby
22       uses: ruby/setup-ruby@v1
23       with:
24         ruby-version: ${{ matrix.ruby }}
25         rubygems: 3.4.10
26         bundler-cache: true
27     - name: Cache node modules
28       uses: actions/setup-node@v4
29       with:
30         cache: yarn
31     - name: Install packages
32       run: |
33         sudo apt-get -yqq update
34         sudo apt-get -yqq install memcached libvips-dev
35     - name: Create database
36       run: |
37         sudo systemctl start postgresql
38         sudo -u postgres createuser -s $(id -un)
39         createdb openstreetmap
40     - name: Configure rails
41       run: |
42         cp config/github.database.yml config/database.yml
43         cp config/example.storage.yml config/storage.yml
44         touch config/settings.local.yml
45     - name: Populate database
46       run: |
47         sed -f script/normalise-structure db/structure.sql > db/structure.expected
48         bundle exec rails db:migrate
49         sed -f script/normalise-structure db/structure.sql > db/structure.actual
50         diff -uw db/structure.expected db/structure.actual
51     - name: Export javascript strings
52       run: bundle exec rails i18n:js:export
53     - name: Install node modules
54       run: bundle exec bin/yarn install
55     - name: Compile assets
56       run: bundle exec rails assets:precompile
57     - name: Create tmp/pids directory
58       run: mkdir -p tmp/pids
59     - name: Run tests
60       run: bundle exec rails test:all
61     - name: Run javascript tests
62       run: bundle exec teaspoon
63     - name: Report completion to Coveralls
64       uses: coverallsapp/github-action@v2.3.6
65       with:
66         github-token: ${{ secrets.github_token }}
67         flag-name: ruby-${{ matrix.ruby }}
68         format: lcov
69         parallel: true
70   finish:
71     name: Finalise
72     needs: test
73     runs-on: ubuntu-latest
74     steps:
75     - name: Report completion to Coveralls
76       uses: coverallsapp/github-action@v2.3.6
77       with:
78         github-token: ${{ secrets.github_token }}
79         parallel-finished: true