Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Remove foreman vendor #10342

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 0 additions & 200 deletions .eslintrc

This file was deleted.

21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const lintCoreConfig = require('./script/lint/lint_core_config.js');
const lintGenericConfig = require('./script/lint/lint_generic_config.js');

const combinedConfig = {
...lintCoreConfig,
...lintGenericConfig,
rules: {
...lintCoreConfig.rules,
...lintGenericConfig.rules,
},
plugins: [
...(lintCoreConfig.plugins || []),
...(lintGenericConfig.plugins || []),
],
extends: [
...(lintCoreConfig.extends || []),
...(lintGenericConfig.extends || []),
],
};

module.exports = combinedConfig;
2 changes: 2 additions & 0 deletions .github/workflows/foreman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: use npm 8
run: npm i -g npm@8 --registry=https://registry.npmjs.org
- name: Setup NPM Cache
uses: actions/cache@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/js_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: use npm 8
run: npm i -g npm@8 --registry=https://registry.npmjs.org
- name: Generate npm dependencies package-lock
run: npm install --package-lock-only --no-audit
- name: Install npm dependencies
run: npm ci --no-audit
- name: Run linter
run: npm run lint
- name: Run custom eslint rules Spellcheck (only warnings) and missing ouia-ids
run: npm run lint:custom
- name: Run tests
run: npm run test
- name: Publish Coveralls
Expand Down
32 changes: 27 additions & 5 deletions .github/workflows/plugins_react_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true

env:
BUNDLE_WITHOUT: "console:development:journald:libvirt"

jobs:
setup_matrix:
name: Setup matrix
Expand Down Expand Up @@ -45,11 +48,13 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
# We could update the postinstall action for foreman to look for an environment variable for plugin webpack dirs
# before kicking off the ruby script to find them, this would eliminate the ruby dep and running `npm install` in plugins.
- uses: ruby/setup-ruby@v1
- name: use npm 8
run: npm i -g npm@8 --registry=https://registry.npmjs.org
- name: "Set up Ruby ${{ matrix.ruby }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Checkout Foreman
uses: actions/checkout@v4
with:
Expand All @@ -65,12 +70,29 @@ jobs:
with:
repository: ${{ matrix.plugin }}
path: ${{ github.workspace }}/projects/plugin
- name: store plugin name
run: echo "PLUGIN_NAME=$(echo ${{ matrix.plugin }} | awk -F'/' '{print $NF}')" >> "${GITHUB_ENV}"
- name: Set up plugin in Foreman
run: |
echo "gemspec name: '$PLUGIN_NAME', path: '${{ github.workspace }}/projects/plugin'" > "bundler.d/$PLUGIN_NAME.local.rb"
if [ -d $PLUGIN_NAME/gemfile.d ] ; then
cat $PLUGIN_NAME/gemfile.d/*.rb >> bundler.d/$PLUGIN_NAME.local.rb
fi
working-directory: ${{ github.workspace }}/projects/foreman
- name: Generate ${{ matrix.plugin }} npm dependencies package-lock
run: npm install --package-lock-only --no-audit --legacy-peer-deps
working-directory: ${{ github.workspace }}/projects/plugin
- name: Install ${{ matrix.plugin }} npm dependencies
run: npm ci --no-audit --legacy-peer-deps
working-directory: ${{ github.workspace }}/projects/plugin
- run: sudo apt-get update
- run: sudo apt-get -qq -y install build-essential libcurl4-openssl-dev zlib1g-dev libpq-dev libvirt-dev
- name: Install gems
run: bundle install
working-directory: ${{ github.workspace }}/projects/foreman
- name: Run plugin webpack dir to test
run: ./script/plugin_webpack_directories.rb
working-directory: ${{ github.workspace }}/projects/foreman
- name: Run ${{ matrix.plugin }} tests
run: npm test
working-directory: ${{ github.workspace }}/projects/plugin
run: npm run test:plugins $(echo ${{ matrix.plugin }} | awk -F'/' '{print $NF}')
working-directory: ${{ github.workspace }}/projects/foreman
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
engine-strict=true
legacy-peer-deps=true
2 changes: 1 addition & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function onContentLoad() {
password_caps_lock_hint();

tfm.i18n.intl.ready.then(function() {
var tz = jstz.determine();
var tz = tfm.jstz.determine();
$.cookie('timezone', tz.name(), {
path: '/',
secure: location.protocol === 'https:',
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/host_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,12 @@ function serializeForm() {
}

function subnet_contains(network, cidr, ip) {
if (!ip || 0 === ip.length || !ipaddr.isValid(ip)) {
if (!ip || 0 === ip.length || !tfm.ipaddr.isValid(ip)) {
return;
}

var addr = ipaddr.parse(ip);
var range = ipaddr.parse(network);
var addr = tfm.ipaddr.parse(ip);
var range = tfm.ipaddr.parse(network);

return addr.match(range, cidr);
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/subnets.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function subnetMaskChanged(field) {
}
if ($('input[id^=subnet_type_]:checked').val() === 'Subnet::Ipv4') {
try {
var cidr = ipaddr.IPv4.parse(mask).prefixLengthFromSubnetMask();
var cidr = tfm.ipaddr.IPv4.parse(mask).prefixLengthFromSubnetMask();
} catch (err) {
var cidr = '';
}
Expand Down
7 changes: 1 addition & 6 deletions app/helpers/reactjs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@ def get_webpack_chunk(name, extension)
data['assetsByChunkName'][name]&.find { |value| value.end_with?(".#{extension}") }
end

def get_webpack_foreman_vendor_js
foreman_vendor_js = get_webpack_chunk('foreman-vendor', 'js')
javascript_include_tag("/webpack/#{foreman_vendor_js}")
end

def get_webpack_foreman_vendor_css
foreman_vendor_css = get_webpack_chunk('foreman-vendor', 'css')
foreman_vendor_css = get_webpack_chunk('vendorStyles', 'css')
stylesheet_link_tag("/webpack/#{foreman_vendor_css}")
end

Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
</head>

<body class='<%= body_css_classes %>'>
<%= get_webpack_foreman_vendor_js %>

<%= javascript_include_tag("/webpack/#{get_webpack_chunk('vendor', 'js')}") %>
<%= javascript_include_tag("/webpack/#{get_webpack_chunk('bundle', 'js')}") %>
<%= javascript_include_tag("/webpack/#{get_webpack_chunk('reactExports', 'js')}") %>
<%= javascript_include_tag("/webpack/#{get_webpack_chunk('bundle', 'js')}") %>
Comment on lines -41 to +42
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if needed


<%= javascript_include_tag 'application' %>
<%= webpacked_plugins_with_global_js %>
Expand Down
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@theforeman/builder/babel')],
};
Loading
Loading