]> git.openstreetmap.org Git - rails.git/blob - .github/workflows/tests.yml
Update banners.yml
[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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
23     - name: Setup ruby
24       uses: ruby/setup-ruby@0481980f17b760ef6bca5e8c55809102a0af1e5a # v1.263.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@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.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
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: Run tests
64       run: bundle exec rails test:all
65     - name: Run javascript tests
66       run: bundle exec teaspoon
67     - name: Upload screenshots
68       uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
69       if: failure()
70       with:
71         name: screenshots
72         path: tmp/screenshots
73         if-no-files-found: ignore
74     - name: Report completion to Coveralls
75       uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
76       with:
77         github-token: ${{ secrets.github_token }}
78         flag-name: ruby-${{ matrix.ruby }}
79         format: lcov
80         parallel: true
81   finish:
82     name: Finalise
83     needs: test
84     runs-on: ubuntu-latest
85     timeout-minutes: 1
86     steps:
87     - name: Report completion to Coveralls
88       uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
89       with:
90         github-token: ${{ secrets.github_token }}
91         parallel-finished: true