]> git.openstreetmap.org Git - rails.git/blob - .github/workflows/lint.yml
Backfill enhanced changeset stats
[rails.git] / .github / workflows / lint.yml
1 name: Lint
2 on:
3   - push
4   - pull_request
5 concurrency:
6   group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
7   cancel-in-progress: true
8 env:
9   ruby: '3.2'
10 jobs:
11   rubocop:
12     name: RuboCop
13     runs-on: ubuntu-latest
14     timeout-minutes: 10
15     steps:
16     - name: Check out code
17       uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
18     - name: Setup ruby
19       uses: ruby/setup-ruby@efbf473cab83af4468e8606cc33eca9281bb213f # v1.256.0
20       with:
21         ruby-version: ${{ env.ruby }}
22         rubygems: 3.4.10
23         bundler-cache: true
24     - name: Run rubocop
25       run: bundle exec rubocop --format fuubar
26   erblint:
27     name: ERB Lint
28     runs-on: ubuntu-22.04
29     timeout-minutes: 10
30     steps:
31     - name: Check out code
32       uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33     - name: Setup ruby
34       uses: ruby/setup-ruby@efbf473cab83af4468e8606cc33eca9281bb213f # v1.256.0
35       with:
36         ruby-version: ${{ env.ruby }}
37         rubygems: 3.4.10
38         bundler-cache: true
39     - name: Run erblint
40       run: bundle exec erb_lint .
41   eslint:
42     name: ESLint
43     runs-on: ubuntu-22.04
44     timeout-minutes: 10
45     steps:
46     - name: Check out code
47       uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
48     - name: Setup ruby
49       uses: ruby/setup-ruby@efbf473cab83af4468e8606cc33eca9281bb213f # v1.256.0
50       with:
51         ruby-version: ${{ env.ruby }}
52         rubygems: 3.4.10
53         bundler-cache: true
54     - name: Cache node modules
55       uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
56       with:
57         cache: yarn
58     - name: Install node modules
59       run: bundle exec bin/yarn install
60     - name: Create dummy database configuration
61       run: cp config/example.database.yml config/database.yml
62     - name: Run eslint
63       run: bundle exec rails eslint
64   brakeman:
65     name: Brakeman
66     runs-on: ubuntu-22.04
67     timeout-minutes: 10
68     steps:
69     - name: Check out code
70       uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
71     - name: Setup ruby
72       uses: ruby/setup-ruby@efbf473cab83af4468e8606cc33eca9281bb213f # v1.256.0
73       with:
74         ruby-version: ${{ env.ruby }}
75         rubygems: 3.4.10
76         bundler-cache: true
77     - name: Run brakeman
78       run: bundle exec brakeman -q
79   annotate_models:
80     env:
81       RAILS_ENV: test
82     name: Rails Annotate Models
83     runs-on: ubuntu-22.04
84     timeout-minutes: 10
85     steps:
86     - name: Check out code
87       uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
88     - name: Setup ruby
89       uses: ruby/setup-ruby@efbf473cab83af4468e8606cc33eca9281bb213f # v1.256.0
90       with:
91         ruby-version: ${{ env.ruby }}
92         rubygems: 3.4.10
93         bundler-cache: true
94     - name: Configure rails
95       run: |
96         cp config/github.database.yml config/database.yml
97         cp config/example.storage.yml config/storage.yml
98     - name: Cache node modules
99       uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
100       with:
101         cache: yarn
102     - name: Install node modules
103       run: bundle exec bin/yarn install
104     - name: Setup database
105       run: |
106         sudo systemctl start postgresql
107         sudo -u postgres createuser -s $(id -un)
108         createdb openstreetmap
109         bundle exec rails db:schema:load
110     - name: Run Annotate Models
111       run: bundle exec annotaterb models
112     - name: Fail if model annotations are out of date
113       run: git diff --exit-code