Merge pull request #5919 from tchak/gh-actions

Add github actions CI
This commit is contained in:
Paul Chavard 2021-02-23 13:05:20 +01:00 committed by GitHub
commit e920764078
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 103 additions and 52 deletions

101
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,101 @@
name: Continuous Integration
on:
push:
branches: 'main'
pull_request:
branches: 'main'
jobs:
linters:
name: Linters
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Find yarn cache location
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: JS package cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: |
yarn install --pure-lockfile
- name: Run linters
run: |
bundle exec rake lint
tests:
name: Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: tps_test
POSTGRES_DB: tps_test
POSTGRES_PASSWORD: tps_test
ports: ["5432:5432"]
strategy:
matrix:
pattern:
- spec/controllers
- spec/features
- spec/helpers spec/lib spec/middlewares
- spec/mailers spec/jobs spec/policies
- spec/models
- spec/serializers spec/services
- spec/views
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Find yarn cache location
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: JS package cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: |
yarn install --pure-lockfile
- name: Setup test database
env:
RAILS_ENV: test
DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test"
run: |
bundle exec rake db:create db:schema:load db:migrate
- name: Run tests
run: bundle exec rspec ${{ matrix.pattern }}

View file

@ -12,6 +12,7 @@ AllCops:
- "db/migrate/20190730153555_recreate_structure.rb"
- "bin/*"
- "node_modules/**/*"
- "vendor/**/*"
DS/Unscoped:
Enabled: true

View file

@ -1,5 +1,5 @@
task :lint do
sh "bundle exec rubocop"
sh "bundle exec rubocop --parallel"
sh "bundle exec haml-lint app/views/"
sh "bundle exec scss-lint app/assets/stylesheets/"
sh "bundle exec brakeman --no-pager"

View file

@ -77,51 +77,6 @@ FactoryBot.define do
end
end
trait :invalid_multi_polygon do
geometry do
{
"type": "MultiPolygon",
"coordinates": [
[
[
[5.894422531127931, 48.22810341752755],
[5.893049240112306, 48.22427237832278],
[5.892534255981446, 48.22593062452037],
[5.892791748046875, 48.2260449843468],
[5.894422531127931, 48.229933066408215],
[5.894422531127931, 48.22810341752755]
]
],
[
[
[5.8950233459472665, 48.229933066408215],
[5.893478393554688, 48.228961073585126],
[5.892791748046875, 48.228903896961775],
[5.892705917358398, 48.230390468407535],
[5.8950233459472665, 48.229933066408215]
]
],
[
[
[5.893220901489259, 48.229246955743626],
[5.893392562866212, 48.22884672027457],
[5.892705917358398, 48.22878954352343],
[5.892019271850587, 48.22856083588024],
[5.892019271850587, 48.2277031731152],
[5.890989303588868, 48.22787470681807],
[5.889959335327149, 48.22787470681807],
[5.890560150146485, 48.22838930447709],
[5.890645980834962, 48.22878954352343],
[5.890989303588868, 48.229018250144584],
[5.892362594604493, 48.22930413198368],
[5.893220901489259, 48.229246955743626]
]
]
]
}
end
end
trait :line_string do
geometry do
{

View file

@ -45,12 +45,6 @@ RSpec.describe GeoArea, type: :model do
it { expect(geo_area.geometry).to eq(polygon) }
context 'invalid' do
let(:geo_area) { build(:geo_area, :invalid_multi_polygon) }
it { expect(geo_area.rgeo_geometry).to be_nil }
end
context 'polygon_with_extra_coordinate' do
let(:geo_area) { build(:geo_area, :polygon_with_extra_coordinate) }