]> git.openstreetmap.org Git - rails.git/blob - .github/workflows/tests.yml
Attempt to get danger working as a CI workflow
[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: Ubuntu ${{ matrix.ubuntu }}, Ruby ${{ matrix.ruby }}
11     strategy:
12       matrix:
13         ubuntu: [22.04, 24.04]
14         ruby: ['3.1', '3.2', '3.3']
15     runs-on: ubuntu-${{ matrix.ubuntu }}
16     env:
17       RAILS_ENV: test
18       OPENSTREETMAP_MEMCACHE_SERVERS: 127.0.0.1
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/cache@v4
30       with:
31         path: node_modules
32         key: yarn-ubuntu-${{ matrix.ubuntu }}-${{ hashFiles('yarn.lock') }}
33         restore-keys: |
34           yarn-ubuntu-${{ matrix.ubuntu }}-
35     - name: Install packages
36       run: |
37         sudo apt-get -yqq update
38         sudo apt-get -yqq install memcached libvips-dev
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: Populate database
50       run: |
51         sed -f script/normalise-structure db/structure.sql > db/structure.expected
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 rails i18n:js:export
57     - name: Install node modules
58       run: bundle exec bin/yarn install
59     - name: Compile assets
60       run: bundle exec rails assets:precompile
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: Report completion to Coveralls
68       uses: coverallsapp/github-action@v2.3.3
69       with:
70         github-token: ${{ secrets.github_token }}
71         flag-name: ubuntu-${{ matrix.ubuntu }}-ruby-${{ matrix.ruby }}
72         format: lcov
73         parallel: true
74   finish:
75     name: Finalise
76     needs: test
77     runs-on: ubuntu-latest
78     steps:
79     - name: Report completion to Coveralls
80       uses: coverallsapp/github-action@v2.3.3
81       with:
82         github-token: ${{ secrets.github_token }}
83         parallel-finished: true