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