]> git.openstreetmap.org Git - rails.git/blob - .github/workflows/tests.yml
Add bcl to UI languages
[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       fail-fast: false
15     runs-on: ubuntu-latest
16     env:
17       RAILS_ENV: test
18       OPENSTREETMAP_MEMCACHE_SERVERS: 127.0.0.1
19     timeout-minutes: 20
20     steps:
21     - name: Checkout source
22       uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
23     - name: Setup ruby
24       uses: ruby/setup-ruby@d697be2f83c6234b20877c3b5eac7a7f342f0d0c # v1.269.0
25       with:
26         ruby-version: ${{ matrix.ruby }}
27         rubygems: 3.4.10
28         bundler-cache: true
29     - name: Cache node modules
30       uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
31       with:
32         cache: yarn
33     - name: Install packages
34       run: |
35         sudo apt-get -yqq update
36         sudo apt-get -yqq install memcached libvips-dev xvfb mesa-utils libgl1-mesa-dri
37     - name: Create database
38       run: |
39         sudo systemctl start postgresql
40         sudo -u postgres createuser -s $(id -un)
41         createdb openstreetmap
42     - name: Configure rails
43       run: |
44         cp config/github.database.yml config/database.yml
45         cp config/example.storage.yml config/storage.yml
46         touch config/settings.local.yml
47     - name: Install node modules
48       run: bundle exec bin/yarn install
49     - name: Populate database
50       run: |
51         sed -f script/normalise-structure db/structure.sql > db/structure.expected
52         rm -f db/structure.sql
53         bundle exec rails db:migrate
54         sed -f script/normalise-structure db/structure.sql > db/structure.actual
55         diff -uw db/structure.expected db/structure.actual
56     - name: Export javascript strings
57       run: bundle exec i18n export
58     - name: Compile assets
59       run: bundle exec rails assets:precompile
60       timeout-minutes: 10
61     - name: Create tmp/pids directory
62       run: mkdir -p tmp/pids
63     - name: Enable virtual display
64       run: Xvfb :99 -screen 0 1024x768x24 &
65     - name: Run tests
66       run: bundle exec rails test:all
67       env:
68         DISPLAY: ":99"
69     - name: Run javascript tests
70       run: bundle exec teaspoon
71       env:
72         DISPLAY: ":99"
73     - name: Upload screenshots
74       uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
75       if: failure()
76       with:
77         name: screenshots
78         path: tmp/screenshots
79         if-no-files-found: ignore
80     - name: Report completion to Coveralls
81       uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
82       with:
83         github-token: ${{ secrets.github_token }}
84         flag-name: ruby-${{ matrix.ruby }}
85         format: lcov
86         parallel: true
87   finish:
88     name: Finalise
89     needs: test
90     runs-on: ubuntu-latest
91     timeout-minutes: 1
92     steps:
93     - name: Report completion to Coveralls
94       uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
95       with:
96         github-token: ${{ secrets.github_token }}
97         parallel-finished: true