]> git.openstreetmap.org Git - rails.git/blob - .github/workflows/tests.yml
Merge remote-tracking branch 'upstream/pull/6286'
[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.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     timeout-minutes: 20
19     steps:
20     - name: Checkout source
21       uses: actions/checkout@v4
22     - name: Setup ruby
23       uses: ruby/setup-ruby@v1
24       with:
25         ruby-version: ${{ matrix.ruby }}
26         rubygems: 3.4.10
27         bundler-cache: true
28     - name: Cache node modules
29       uses: actions/setup-node@v4
30       with:
31         cache: yarn
32     - name: Install packages
33       run: |
34         sudo apt-get -yqq update
35         sudo apt-get -yqq install memcached libvips-dev
36     - name: Create database
37       run: |
38         sudo systemctl start postgresql
39         sudo -u postgres createuser -s $(id -un)
40         createdb openstreetmap
41     - name: Configure rails
42       run: |
43         cp config/github.database.yml config/database.yml
44         cp config/example.storage.yml config/storage.yml
45         touch config/settings.local.yml
46     - name: Install node modules
47       run: bundle exec bin/yarn install
48     - name: Populate database
49       run: |
50         sed -f script/normalise-structure db/structure.sql > db/structure.expected
51         rm -f db/structure.sql
52         bundle exec rails db:migrate
53         sed -f script/normalise-structure db/structure.sql > db/structure.actual
54         diff -uw db/structure.expected db/structure.actual
55     - name: Export javascript strings
56       run: bundle exec i18n export
57     - name: Compile assets
58       run: bundle exec rails assets:precompile
59       timeout-minutes: 10
60     - name: Create tmp/pids directory
61       run: mkdir -p tmp/pids
62     - name: Run tests
63       run: bundle exec rails test:all
64     - name: Run javascript tests
65       run: bundle exec teaspoon
66     - name: Upload screenshots
67       uses: actions/upload-artifact@v4
68       if: failure()
69       with:
70         name: screenshots
71         path: tmp/screenshots
72         if-no-files-found: ignore
73     - name: Report completion to Coveralls
74       uses: coverallsapp/github-action@v2.3.6
75       with:
76         github-token: ${{ secrets.github_token }}
77         flag-name: ruby-${{ matrix.ruby }}
78         format: lcov
79         parallel: true
80   finish:
81     name: Finalise
82     needs: test
83     runs-on: ubuntu-latest
84     timeout-minutes: 1
85     steps:
86     - name: Report completion to Coveralls
87       uses: coverallsapp/github-action@v2.3.6
88       with:
89         github-token: ${{ secrets.github_token }}
90         parallel-finished: true