diff --git a/.github/workflows/javascript_tests.yml b/.github/workflows/javascript_tests.yml new file mode 100644 index 00000000..cf480099 --- /dev/null +++ b/.github/workflows/javascript_tests.yml @@ -0,0 +1,30 @@ +--- +name: React and Javascript tests +on: + pull_request: + push: + branches: + - master + +jobs: + test_js: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: [14] + steps: + - uses: actions/checkout@v2 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - run: npm install + - name: Linting + run: | + # FIXME: we need to fix the findings, first + #npm run lint + npm run stylelint + - name: Testing + run: npm run test +... diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 07c639fa..a008eb33 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -14,9 +14,6 @@ jobs: with: ruby-version: 2.7 bundler-cache: true - - name: Setup rubocop - run: | - gem install bundler - name: Execute rubocop run: | - bundle exec rubocop + bundle exec rake rubocop diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index ce04e550..023d6c1a 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -24,9 +24,8 @@ jobs: fail-fast: false matrix: foreman-repo: [theforeman/foreman] - foreman-core-branch: [3.3-stable, 3.4-stable, develop] + foreman-core-branch: [3.8-stable, 3.9-stable, develop] ruby-version: [2.7] - node: [14] steps: - run: | sudo apt-get update @@ -38,55 +37,31 @@ jobs: - uses: actions/checkout@v2 with: path: foreman_acd - - name: Setup Bundler + - name: Add ACD to foreman run: | echo "gem 'foreman_acd', path: './foreman_acd'" > bundler.d/foreman_acd.local.rb - - name: Limit REX and tasks version for Foreman 3.3-stable + - name: Limit REX and tasks version for Foreman 3.8-stable working-directory: foreman_acd - if: ${{ matrix.foreman-core-branch == '3.3-stable' }} + if: ${{ matrix.foreman-core-branch == '3.8-stable' }} run: | - sed -i '23,24d' foreman_acd.gemspec - sed -i '23is.add_dependency "foreman-tasks", "~> 6.0"' foreman_acd.gemspec - sed -i '23is.add_dependency "foreman_remote_execution", "~> 7.2"' foreman_acd.gemspec - - name: Limit REX and tasks version for Foreman 3.4-stable - working-directory: foreman_acd - if: ${{ matrix.foreman-core-branch == '3.4-stable' }} - run: | - sed -i '23,24d' foreman_acd.gemspec - sed -i '23is.add_dependency "foreman-tasks", "~> 7.0"' foreman_acd.gemspec - sed -i '23is.add_dependency "foreman_remote_execution", "~> 8.0"' foreman_acd.gemspec - - name: Limit REX and tasks version for Foreman develop - working-directory: foreman_acd - if: ${{ matrix.foreman-core-branch == 'develop' }} - run: | - sed -i '23,24d' foreman_acd.gemspec - sed -i '23is.add_dependency "foreman-tasks", "~> 7.0"' foreman_acd.gemspec - sed -i '23is.add_dependency "foreman_remote_execution", "~> 9.0"' foreman_acd.gemspec + sed -i '/s\.add_dependency .foreman-tasks./s/,[^,]*$/, "~> 8.3"/' foreman_acd.gemspec + sed -i '/s\.add_dependency .foreman_remote_execution./s/,[^,]*$/, "~> 11.1"/' foreman_acd.gemspec + cat foreman_acd.gemspec + - name: Setup Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} + - run: bundle list - name: Prepare test env run: | bundle exec rake db:create bundle exec rake db:migrate bundle exec rake db:test:prepare - - name: Prepare webpack - run: | - npm install - bundle exec rake webpack:compile - name: Run plugin tests run: | bundle exec rake test:foreman_acd - - name: Run npm tests - working-directory: ./foreman_acd - run: | - npm test - name: Run access permission test run: | bundle exec rake test TEST="test/unit/foreman/access_permissions_test.rb" diff --git a/.packit.yaml b/.packit.yaml index 28a171e0..e1e73d7e 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -29,7 +29,7 @@ jobs: trigger: pull_request targets: centos-stream-8: - additional_modules: "foreman:el8,nodejs:12" + additional_modules: "foreman:el8,nodejs:14" additional_repos: - http://koji.katello.org/releases/yum/foreman-nightly/el8/x86_64/ - http://yum.theforeman.org/plugins/nightly/el8/x86_64/ diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 00000000..5f8bb229 --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "stylelint-config-standard", + ], +} diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..0eca6d15 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,36 @@ +module.exports = { + verbose: true, + testMatch: ['**/*.test.js'], + testPathIgnorePatterns: [ + '.local', + '.bundle', + '/node_modules/', + '/foreman/', + ], + moduleDirectories: ['node_modules', 'webpack'], + testURL: 'http://localhost/', + collectCoverage: true, + collectCoverageFrom: [ + 'webpack/**/*.js', + '!webpack/index.js', + '!webpack/test_setup.js', + '!webpack/**/bundle*', + '!webpack/stories/**', + '!webpack/**/*stories.js', + ], + coverageReporters: ['text', 'lcov'], + moduleNameMapper: { + '^.+\\.(png|gif|css|scss)$': 'identity-obj-proxy', + }, + globals: { + __testing__: true, + }, + transform: { + '^.+\\.js$': 'babel-jest', + }, + setupFiles: [ + 'raf/polyfill', + 'jest-prop-type-error', + './webpack/test_setup.js', + ], +}; diff --git a/package.json b/package.json index 40e70189..dbfc9b33 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,6 @@ "version": "0.9.3", "description": "foreman application centric deployment", "main": "index.js", - "directories": { - "test": "test" - }, "peerDependencies": { "@theforeman/vendor": ">= 10.1.0" }, @@ -17,67 +14,32 @@ "babel-plugin-transform-class-properties": "^6.24.1", "babel-preset-env": "^1.6.0", "babel-preset-react": "^6.24.1", + "eslint": "^6.7.2", "jest": "^23.6.0", "jest-prop-type-error": "^1.1.0", "lodash": "^4.17.11", + "prettier": "^1.19.1", "react-redux-test-utils": "^0.1.1", "sortabular": "^1.5.1", + "stylelint": "^9.3.0", + "stylelint-config-standard": "^18.0.0", "table-resolver": "^3.2.0" }, "scripts": { - "test": "node node_modules/.bin/jest --no-cache" + "lint": "tfm-lint --plugin -d *.js,webpack", + "lint-fix": "tfm-lint --plugin -d *.js,webpack --fix", + "stylelint": "stylelint webpack/**/*.scss", + "stylelint-fix": "stylelint webpack/**/*.scss --fix", + "test": "jest --no-cache" }, "repository": { "type": "git", "url": "git+https://github.com/ATIX-AG/foreman_acd.git" }, - "author": "", + "author": "ATIX AG ", "license": "ISC", "bugs": { - "url": "https://atix.de" + "url": "https://github.com/ATIX-AG/foreman_acd/issues" }, - "homepage": "https://atix.de", - "jest": { - "verbose": true, - "testMatch": [ - "**/*.test.js" - ], - "testPathIgnorePatterns": [ - ".local", - ".bundle", - "/node_modules/", - "/foreman/" - ], - "moduleDirectories": [ - "node_modules", - "webpack" - ], - "testURL": "http://localhost/", - "collectCoverage": true, - "collectCoverageFrom": [ - "webpack/**/*.js", - "!webpack/index.js", - "!webpack/test_setup.js", - "!webpack/**/bundle*", - "!webpack/stories/**", - "!webpack/**/*stories.js" - ], - "coverageReporters": [ - "lcov" - ], - "moduleNameMapper": { - "^.+\\.(png|gif|css|scss)$": "identity-obj-proxy" - }, - "globals": { - "__testing__": true - }, - "transform": { - "^.+\\.js$": "babel-jest" - }, - "setupFiles": [ - "raf/polyfill", - "jest-prop-type-error", - "./webpack/test_setup.js" - ] - } + "homepage": "https://atix.de" } diff --git a/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss b/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss index a4456e80..49e6f060 100644 --- a/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +++ b/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss @@ -5,26 +5,26 @@ } .deploy_status_head { - float:left; - width:25%; - height:10%; + float: left; + width: 25%; + height: 10%; } .deploy_status_content { - float:left; - width:75%; - height:10%; + float: left; + width: 75%; + height: 10%; } .deploy_report_hosts { - float:left; - width:25%; - height:100%; + float: left; + width: 25%; + height: 100%; } .deploy_report_tasks { - float:left; - width:75%; + float: left; + width: 75%; min-height: 300px; background-color: #ecf9fe; padding: 10px; diff --git a/webpack/components/ExistingHostSelection/ExistingHostSelection.scss b/webpack/components/ExistingHostSelection/ExistingHostSelection.scss index 35adca3c..dd987c20 100644 --- a/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +++ b/webpack/components/ExistingHostSelection/ExistingHostSelection.scss @@ -1,11 +1,11 @@ @import '~@theforeman/vendor/scss/variables'; .add_existing_hosts_modal { - margin-top: 0; - margin-bottom: 0; - height: 100%; - width: 80%; - max-width: none !important; + margin-top: 0; + margin-bottom: 0; + height: 100%; + width: 80%; + max-width: none !important; } .row { diff --git a/webpack/components/ParameterSelection/ParameterSelection.scss b/webpack/components/ParameterSelection/ParameterSelection.scss index cc031ae0..f24f1f2a 100644 --- a/webpack/components/ParameterSelection/ParameterSelection.scss +++ b/webpack/components/ParameterSelection/ParameterSelection.scss @@ -1,17 +1,17 @@ @import '~@theforeman/vendor/scss/variables'; .param_selection_modal { - margin-top: 0; - margin-bottom: 0; - height: 100%; - width: 80%; - max-width: none !important; + margin-top: 0; + margin-bottom: 0; + height: 100%; + width: 80%; + max-width: none !important; } .complex_data_modal { - margin-top: 0; - margin-bottom: 0; - height: 80%; - width: 40%; - max-width: none !important; + margin-top: 0; + margin-bottom: 0; + height: 80%; + width: 40%; + max-width: none !important; }