]> git.openstreetmap.org Git - rails.git/blob - .github/workflows/lint.yml
75a1cc960f6e8c3fd44c343274f5cb0adcd2f985
[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   os: ubuntu-22.04
10   ruby: '3.1'
11 jobs:
12   rubocop:
13     name: RuboCop
14     runs-on: ubuntu-22.04
15     steps:
16     - name: Check out code
17       uses: actions/checkout@v4
18     - name: Setup ruby
19       uses: ruby/setup-ruby@v1
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     steps:
30     - name: Check out code
31       uses: actions/checkout@v4
32     - name: Setup ruby
33       uses: ruby/setup-ruby@v1
34       with:
35         ruby-version: ${{ env.ruby }}
36         rubygems: 3.4.10
37         bundler-cache: true
38     - name: Run erblint
39       run: bundle exec erb_lint .
40   eslint:
41     name: ESLint
42     runs-on: ubuntu-22.04
43     steps:
44     - name: Check out code
45       uses: actions/checkout@v4
46     - name: Setup ruby
47       uses: ruby/setup-ruby@v1
48       with:
49         ruby-version: ${{ env.ruby }}
50         rubygems: 3.4.10
51         bundler-cache: true
52     - name: Cache node modules
53       uses: actions/setup-node@v4
54       with:
55         cache: yarn
56     - name: Install node modules
57       run: bundle exec bin/yarn install
58     - name: Create dummy database configuration
59       run: cp config/example.database.yml config/database.yml
60     - name: Run eslint
61       run: bundle exec rails eslint
62   brakeman:
63     name: Brakeman
64     runs-on: ubuntu-22.04
65     steps:
66     - name: Check out code
67       uses: actions/checkout@v4
68     - name: Setup ruby
69       uses: ruby/setup-ruby@v1
70       with:
71         ruby-version: ${{ env.ruby }}
72         rubygems: 3.4.10
73         bundler-cache: true
74     - name: Run brakeman
75       run: bundle exec brakeman -q
76   annotate_models:
77     env:
78       RAILS_ENV: test
79     name: Rails Annotate Models
80     runs-on: ubuntu-22.04
81     steps:
82     - name: Check out code
83       uses: actions/checkout@v4
84     - name: Setup ruby
85       uses: ruby/setup-ruby@v1
86       with:
87         ruby-version: ${{ env.ruby }}
88         rubygems: 3.4.10
89         bundler-cache: true
90     - name: Setup database
91       run: |
92         sudo systemctl start postgresql
93         sudo -u postgres createuser -s $(id -un)
94         createdb openstreetmap
95         cp config/github.database.yml config/database.yml
96         bundle exec rails db:schema:load
97     - name: Run Annotate Models
98       run: bundle exec rails annotate_models
99     - name: Fail if model annotations are out of date
100       run: git diff --exit-code