Merge bundle-audit and rubocop into CI & add precompile step (#19228)
This commit is contained in:
parent
dc7ff6382c
commit
2e759c823d
4 changed files with 114 additions and 63 deletions
21
.github/workflows/bundle-audit.yml
vendored
21
.github/workflows/bundle-audit.yml
vendored
|
|
@ -1,21 +0,0 @@
|
|||
name: Bundler-audit
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: setup ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
bundler-cache: true
|
||||
- run: bundle exec bundle-audit check --update
|
||||
136
.github/workflows/ci-cd.yml
vendored
136
.github/workflows/ci-cd.yml
vendored
|
|
@ -17,7 +17,7 @@ env:
|
|||
POSTGRES_PASSWORD: postgres
|
||||
|
||||
jobs:
|
||||
bundle-install:
|
||||
bundle_install:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
|
@ -26,7 +26,7 @@ jobs:
|
|||
with:
|
||||
bundler-cache: true
|
||||
|
||||
yarn-install:
|
||||
yarn_install:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
|
@ -54,9 +54,75 @@ jobs:
|
|||
- run: yarn install --immutable
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
|
||||
RSpec:
|
||||
precompile_assets:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [bundle-install, yarn-install]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Look up if compiled assets exist
|
||||
id: precompiled-asset
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
public/assets
|
||||
public/packs-test
|
||||
tmp/cache/webpacker
|
||||
key: ${{ runner.os }}-precompiled-assets-${{ hashFiles('app/assets/**', 'app/javascript/**', 'config/webpack/**', 'config/webpacker.yml', '**/package.json', '**/yarn.lock') }}
|
||||
restore-keys: ${{ runner.os }}-precompiled-assets-
|
||||
- name: setup ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
bundler-cache: true
|
||||
if: steps.precompiled-asset.outputs.cache-hit != 'true'
|
||||
- name: Cache node_modules
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: ${{ runner.os }}-node-modules-
|
||||
if: steps.precompiled-asset.outputs.cache-hit != 'true'
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
cache: yarn
|
||||
if: steps.precompiled-asset.outputs.cache-hit != 'true'
|
||||
- run: yarn install --immutable
|
||||
if: steps.precompiled-asset.outputs.cache-hit != 'true'
|
||||
- run: bundle exec rails assets:precompile
|
||||
if: steps.precompiled-asset.outputs.cache-hit != 'true'
|
||||
|
||||
audit:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [bundle_install]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: setup ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
bundler-cache: true
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
cache: yarn
|
||||
- name: Restore node_modules
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: ${{ runner.os }}-node-modules-
|
||||
- name: rubocop
|
||||
uses: reviewdog/action-rubocop@v2
|
||||
with:
|
||||
rubocop_version: gemfile
|
||||
rubocop_extensions: rubocop-performance:gemfile rubocop-rails:gemfile rubocop-rspec:gemfile
|
||||
reporter: github-pr-review # Default is github-pr-check
|
||||
- run: yarn lint:frontend
|
||||
- run: bundle exec bundle-audit check --update
|
||||
|
||||
rspec:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [bundle_install, yarn_install, precompile_assets]
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
|
||||
|
|
@ -83,7 +149,17 @@ jobs:
|
|||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Cache node modules
|
||||
- name: Restore compiled assets
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
fail-on-cache-miss: true
|
||||
path: |
|
||||
public/assets
|
||||
public/packs-test
|
||||
tmp/cache/webpacker
|
||||
key: ${{ runner.os }}-precompiled-assets-${{ hashFiles('app/assets/**', 'app/javascript/**', 'config/webpack/**', 'config/webpacker.yml', '**/package.json', '**/yarn.lock') }}
|
||||
restore-keys: ${{ runner.os }}-precompiled-assets-
|
||||
- name: Restore node_modules
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: node_modules
|
||||
|
|
@ -97,7 +173,6 @@ jobs:
|
|||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
bundler-cache: true
|
||||
- run: bin/webpack
|
||||
- run: bundle exec rails db:test:prepare
|
||||
- name: RSpec
|
||||
run: bin/knapsack_pro_rspec
|
||||
|
|
@ -121,14 +196,14 @@ jobs:
|
|||
key: ${{ secrets.BUILDPULSE_ACCESS_KEY_ID }}
|
||||
secret: ${{ secrets.BUILDPULSE_SECRET_ACCESS_KEY }}
|
||||
|
||||
Jest:
|
||||
jest:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [yarn-install]
|
||||
needs: [yarn_install]
|
||||
timeout-minutes: 20
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Cache node modules
|
||||
- name: Restore node_modules
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: node_modules
|
||||
|
|
@ -138,7 +213,6 @@ jobs:
|
|||
with:
|
||||
node-version: 16
|
||||
cache: yarn
|
||||
- run: yarn lint:frontend
|
||||
- run: yarn test --colors --ci --reporters=jest-junit
|
||||
- name: Upload test results to BuildPulse for flaky test detection
|
||||
if: '!cancelled()' # Run this step even when the tests fail. Skip if the workflow is cancelled.
|
||||
|
|
@ -153,13 +227,13 @@ jobs:
|
|||
with:
|
||||
flags: javascript
|
||||
|
||||
Storybook:
|
||||
storybook:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [yarn-install]
|
||||
needs: [yarn_install]
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Cache node modules
|
||||
- name: Restore node_modules
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: node_modules
|
||||
|
|
@ -171,9 +245,9 @@ jobs:
|
|||
cache: yarn
|
||||
- run: yarn build-storybook
|
||||
|
||||
Build-test:
|
||||
build_test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [bundle-install, yarn-install]
|
||||
needs: [bundle_install, yarn_install, precompile_assets]
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/Forem_prod_test
|
||||
|
|
@ -199,7 +273,16 @@ jobs:
|
|||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Cache node modules
|
||||
- name: Cache compiled assets
|
||||
uses: actions/cache/@v3
|
||||
with:
|
||||
path: |
|
||||
public/assets
|
||||
public/packs-test
|
||||
tmp/cache/webpacker
|
||||
key: ${{ runner.os }}-precompiled-assets-${{ hashFiles('app/assets/**', 'app/javascript/**', 'config/webpack/**', 'config/webpacker.yml', '**/package.json', '**/yarn.lock') }}
|
||||
restore-keys: ${{ runner.os }}-precompiled-assets-
|
||||
- name: Restore node_modules
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: node_modules
|
||||
|
|
@ -216,10 +299,10 @@ jobs:
|
|||
- run: bundle exec rails assets:precompile
|
||||
- run: bin/test-console-check
|
||||
|
||||
Cypress:
|
||||
cypress:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
needs: [bundle-install, yarn-install]
|
||||
needs: [bundle_install, yarn_install, precompile_assets]
|
||||
|
||||
services:
|
||||
postgres:
|
||||
|
|
@ -241,7 +324,17 @@ jobs:
|
|||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Cache node modules
|
||||
- name: Restore compiled assets
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
fail-on-cache-miss: true
|
||||
path: |
|
||||
public/assets
|
||||
public/packs-test
|
||||
tmp/cache/webpacker
|
||||
key: ${{ runner.os }}-precompiled-assets-${{ hashFiles('app/assets/**', 'app/javascript/**', 'config/webpack/**', 'config/webpacker.yml', '**/package.json', '**/yarn.lock') }}
|
||||
restore-keys: ${{ runner.os }}-precompiled-assets-
|
||||
- name: Restore node_modules
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: node_modules
|
||||
|
|
@ -255,7 +348,6 @@ jobs:
|
|||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
bundler-cache: true
|
||||
- run: bin/webpack
|
||||
- run: bundle exec rails db:test:prepare
|
||||
- run: yarn cypress install
|
||||
- name: cypress
|
||||
|
|
@ -290,7 +382,7 @@ jobs:
|
|||
|
||||
CI-status-report:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [rspec, jest, cypress, build-test]
|
||||
needs: [rspec, jest, cypress, build_test]
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
|
|
@ -308,7 +400,7 @@ jobs:
|
|||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||
if: failure() && github.ref == 'refs/heads/main'
|
||||
|
||||
Deploy:
|
||||
deploy:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [CI-status-report]
|
||||
|
|
|
|||
18
.github/workflows/rubocop.yml
vendored
18
.github/workflows/rubocop.yml
vendored
|
|
@ -1,18 +0,0 @@
|
|||
name: Rubocop
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
rubocop:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.0.2
|
||||
- name: rubocop
|
||||
uses: reviewdog/action-rubocop@v2
|
||||
with:
|
||||
rubocop_version: gemfile
|
||||
rubocop_extensions: rubocop-performance:gemfile rubocop-rails:gemfile rubocop-rspec:gemfile
|
||||
reporter: github-pr-review # Default is github-pr-check
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/bash
|
||||
bundle install --local --jobs 3
|
||||
Loading…
Add table
Reference in a new issue