Skip to content

Commit c27f686

Browse files
committed
Rewrite workflow to use reusable GitHub Actions
1 parent 3fb2575 commit c27f686

File tree

4 files changed

+37
-111
lines changed

4 files changed

+37
-111
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,23 @@
11
name: CI
2-
on: [push, pull_request]
3-
env:
4-
RAILS_ENV: test
5-
DATABASE_URL: postgresql://postgres:@localhost/test
6-
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: true
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
concurrency:
10+
group: ${{ github.ref_name }}-${{ github.workflow }}
11+
cancel-in-progress: true
12+
713
jobs:
814
rubocop:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@v3
12-
- name: Setup Ruby
13-
uses: ruby/setup-ruby@v1
14-
with:
15-
ruby-version: 2.7
16-
- name: Setup
17-
run: |
18-
gem install bundler -v 2.4.22
19-
echo "gem 'rdoc', '< 6.4'" >> Gemfile
20-
bundle install --jobs=3 --retry=3
21-
- name: Run rubocop
22-
run: bundle exec rubocop
15+
name: Rubocop
16+
uses: theforeman/actions/.github/workflows/rubocop.yml@v0
17+
2318
test:
24-
runs-on: ubuntu-latest
25-
needs: rubocop
26-
services:
27-
postgres:
28-
image: postgres:12.1
29-
ports: ['5432:5432']
30-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
31-
strategy:
32-
fail-fast: false
33-
matrix:
34-
foreman-core-branch: [3.1-stable, 3.2-stable, 3.3-stable, 3.4-stable, 3.5-stable, 3.6-stable, develop]
35-
ruby-version: [2.7]
36-
node-version: [14]
37-
steps:
38-
- name: Install dependencies
39-
run: |
40-
sudo apt-get update
41-
sudo apt-get install build-essential libcurl4-openssl-dev libvirt-dev ruby-libvirt zlib1g-dev libpq-dev
42-
- uses: actions/checkout@v3
43-
with:
44-
repository: theforeman/foreman
45-
ref: ${{ matrix.foreman-core-branch }}
46-
- uses: actions/checkout@v3
47-
with:
48-
path: foreman_vault
49-
- name: Setup Ruby
50-
uses: ruby/setup-ruby@v1
51-
with:
52-
ruby-version: ${{ matrix.ruby-version }}
53-
- name: Setup Node
54-
uses: actions/setup-node@v3
55-
with:
56-
node-version: ${{ matrix.node-version }}
57-
- name: Setup Bundler
58-
run: |
59-
gem install bundler -v 2.4.22
60-
bundle config path vendor/bundle
61-
bundle config set without journald development console mysql2 sqlite
62-
echo "gem 'foreman_vault', path: './foreman_vault'" > bundler.d/foreman_vault.local.rb
63-
bundle lock --update
64-
- name: Cache gems
65-
uses: actions/cache@v3
66-
with:
67-
path: vendor/bundle
68-
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
69-
restore-keys: |
70-
${{ runner.os }}-gems-
71-
- name: Setup Plugin
72-
run: |
73-
bundle install --jobs=3 --retry=3
74-
bundle exec rake db:create
75-
bundle exec rake db:migrate
76-
npm install
77-
bundle exec rake webpack:compile
78-
- name: Run plugin tests
79-
run: |
80-
bundle exec rake test:foreman_vault
81-
bundle exec rake test TEST="test/unit/foreman/access_permissions_test.rb"
82-
- name: Precompile plugin assets
83-
run: bundle exec rake 'plugin:assets:precompile[foreman_vault]'
84-
env:
85-
RAILS_ENV: production
19+
name: Ruby
20+
# needs: rubocop
21+
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
22+
with:
23+
plugin: foreman_vault

.rubocop.yml

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,24 @@
11
AllCops:
2-
TargetRubyVersion: 2.3
3-
TargetRailsVersion: 5.1
4-
Exclude:
5-
- 'Rakefile'
2+
TargetRubyVersion: 2.5
3+
TargetRailsVersion: 6.0
64

7-
Rails:
8-
Enabled: true
9-
10-
# Don't enforce documentation
115
Style/Documentation:
126
Enabled: false
137

14-
Metrics/LineLength:
15-
Max: 190
16-
17-
Metrics/ParameterLists:
18-
Max: 6
19-
20-
Style/WordArray:
8+
Metrics:
219
Enabled: false
2210

23-
Style/SymbolArray:
11+
Style/FormatStringToken:
2412
Enabled: false
2513

26-
Style/RegexpLiteral:
14+
Layout/LineLength:
2715
Enabled: false
2816

29-
Style/FormatStringToken:
17+
Lint/BooleanSymbol:
3018
Enabled: false
3119

32-
Metrics/BlockLength:
33-
Exclude:
34-
- lib/foreman_vault/engine.rb
35-
- 'test/**/*'
36-
37-
Metrics/ClassLength:
38-
Exclude:
39-
- 'test/**/*'
20+
Style/ClassAndModuleChildren:
21+
Enabled: false
4022

41-
Naming/FileName:
42-
Exclude:
43-
- db/seeds.d/103-provisioning_templates.rb
23+
Style/StringLiterals:
24+
Enabled: false

Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@
33
source 'https://rubygems.org'
44

55
gemspec
6+
7+
group :test do
8+
gem 'rubocop'
9+
gem 'rubocop-minitest'
10+
gem 'rubocop-performance'
11+
gem 'rubocop-rails'
12+
end

foreman_vault.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ Gem::Specification.new do |s|
1616

1717
s.add_dependency 'vault', '~> 0.1'
1818

19+
s.add_development_dependency 'rake'
1920
s.add_development_dependency 'rdoc'
20-
s.add_development_dependency 'rubocop', '0.54.0'
2121
end

0 commit comments

Comments
 (0)