From aaa44de8b7874072165b16919bc3d5645d75b343 Mon Sep 17 00:00:00 2001 From: Ryker Blunck Date: Mon, 18 Apr 2022 11:16:59 -0600 Subject: [PATCH 1/3] add pronto as a github action and add some violations to test it --- .github/workflows/github-actions-ci-lint.yml | 64 ++++++++++++++------ Gemfile | 2 +- Gemfile.lock | 12 ++-- app/models/ability.rb | 4 ++ client/apps/hello_world/app.jsx | 3 + 5 files changed, 60 insertions(+), 25 deletions(-) diff --git a/.github/workflows/github-actions-ci-lint.yml b/.github/workflows/github-actions-ci-lint.yml index ffe4915f4..58363f87b 100644 --- a/.github/workflows/github-actions-ci-lint.yml +++ b/.github/workflows/github-actions-ci-lint.yml @@ -1,29 +1,59 @@ -name: linter +# based on https://github.com/prontolabs/pronto/wiki/GitHub-Actions-Integration#rails-application-example- +on: [pull_request] -on: - push: - branches: [ i_amDisabl_ed] +name: Pronto jobs: - test: - + linters: + name: Linters runs-on: ubuntu-latest - + strategy: + matrix: + ruby-version: [2.7] steps: - name: Checkout code uses: actions/checkout@v2 - - name: Set up Ruby + - run: | + git fetch --no-tags --prune --depth=10 origin +refs/heads/*:refs/remotes/origin/* + + - name: Setup Ruby uses: ruby/setup-ruby@v1 + + - name: Ruby gem cache + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + + - name: Install gems + run: | + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: 14.x + + - name: Find yarn cache location + id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: JS package cache + uses: actions/cache@v1 with: - ruby-version: 2.7 - bundler-cache: true + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- - - name: Install dependencies - env: - RAILS_ENV: test - RAILS_GROUPS: build - run: bundle install + - name: Install packages + run: | + yarn install --pure-lockfile - - name: Run linter - run: git diff --name-only origin/master | bundle exec xargs rubocop --force-exclusion --parallel + - name: Run Pronto + run: | + PRONTO_PULL_REQUEST_ID="${{ github.event.pull_request.number }}" PRONTO_GITHUB_ACCESS_TOKEN="${{ github.token }}" bundle exec pronto run -f github_status github_pr -c origin/${{ github.base_ref }} diff --git a/Gemfile b/Gemfile index d26818d24..3e529776a 100644 --- a/Gemfile +++ b/Gemfile @@ -105,7 +105,7 @@ end group :ci do gem "pronto" - gem "pronto-eslint", require: false + gem "pronto-eslint_npm", require: false gem "pronto-rubocop", require: false end diff --git a/Gemfile.lock b/Gemfile.lock index e39e76ab9..236cebc5d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -135,10 +135,6 @@ GEM railties (>= 3.2) encryptor (3.0.0) erubi (1.10.0) - eslintrb (2.1.0) - execjs - multi_json (>= 1.3) - rake execjs (2.8.1) factory_bot (6.2.1) activesupport (>= 5.0.0) @@ -234,6 +230,8 @@ GEM nio4r (2.5.8) nokogiri (1.13.3-x86_64-darwin) racc (~> 1.4) + nokogiri (1.13.3-x86_64-linux) + racc (~> 1.4) non-stupid-digest-assets (1.0.9) sprockets (>= 2.0) notiffany (0.1.3) @@ -273,8 +271,7 @@ GEM rexml (~> 3.2) rugged (>= 0.23.0, < 1.1.0) thor (>= 0.20.3, < 2.0) - pronto-eslint (0.11.0) - eslintrb (~> 2.0, >= 2.0.0) + pronto-eslint_npm (0.11.0) pronto (~> 0.11.0) pronto-rubocop (0.11.1) pronto (~> 0.11.0) @@ -461,6 +458,7 @@ GEM PLATFORMS x86_64-darwin-21 + x86_64-linux DEPENDENCIES apartment-activejob-que @@ -501,7 +499,7 @@ DEPENDENCIES omniauth-canvas (~> 1.0.2) pg pronto - pronto-eslint + pronto-eslint_npm pronto-rubocop puma que diff --git a/app/models/ability.rb b/app/models/ability.rb index 4a2791177..ee0e8cb1c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,6 +1,10 @@ class Ability include CanCan::Ability + def linterShouldCatchThis + + end + def initialize(user, context_id = nil) # Define abilities for the passed in user here. For example: # diff --git a/client/apps/hello_world/app.jsx b/client/apps/hello_world/app.jsx index 3dda81003..99addc126 100644 --- a/client/apps/hello_world/app.jsx +++ b/client/apps/hello_world/app.jsx @@ -14,6 +14,9 @@ import initResizeHandler from '../../common/libs/resize_iframe'; import './styles/styles'; +function linter_should_catch_this() { +} + // Polyfill es6 promises for IE es6Promise.polyfill(); From 603e0c962d41adb808212c0476577bb828564f0f Mon Sep 17 00:00:00 2001 From: Ryker Blunck Date: Mon, 18 Apr 2022 11:37:55 -0600 Subject: [PATCH 2/3] add pronto config file --- .pronto_eslint_npm.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .pronto_eslint_npm.yml diff --git a/.pronto_eslint_npm.yml b/.pronto_eslint_npm.yml new file mode 100644 index 000000000..6c6f117f2 --- /dev/null +++ b/.pronto_eslint_npm.yml @@ -0,0 +1,2 @@ +# .pronto_eslint_npm.yml +files_to_lint: '(\.js|\.jsx|\.es6)$' From 1ebb6ce55419f40c5bca511f160557321b498389 Mon Sep 17 00:00:00 2001 From: Ryker Blunck Date: Mon, 18 Apr 2022 11:57:18 -0600 Subject: [PATCH 3/3] try adding eslint to path --- .github/workflows/github-actions-ci-lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-actions-ci-lint.yml b/.github/workflows/github-actions-ci-lint.yml index 58363f87b..fc8669900 100644 --- a/.github/workflows/github-actions-ci-lint.yml +++ b/.github/workflows/github-actions-ci-lint.yml @@ -53,6 +53,7 @@ jobs: - name: Install packages run: | yarn install --pure-lockfile + yarn global add eslint - name: Run Pronto run: |