Skip to content

Commit

Permalink
Refactor github actions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m-bucher committed Dec 21, 2023
1 parent 277d911 commit 51a902d
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 88 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/javascript_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
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: Testing
run: npm run test
...
5 changes: 1 addition & 4 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
43 changes: 9 additions & 34 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
36 changes: 36 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
verbose: true,
testMatch: ['**/*.test.js'],
testPathIgnorePatterns: [
'.local',
'.bundle',
'/node_modules/',
'<rootDir>/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',
],
};
54 changes: 4 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -25,59 +22,16 @@
"table-resolver": "^3.2.0"
},
"scripts": {
"test": "node node_modules/.bin/jest --no-cache"
"test": "jest --no-cache"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ATIX-AG/foreman_acd.git"
},
"author": "",
"author": "ATIX AG <[email protected]>",
"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/",
"<rootDir>/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"
}

0 comments on commit 51a902d

Please sign in to comment.