diff --git a/.github/workflows/plugins_react_tests.yml b/.github/workflows/plugins_react_tests.yml index 62175e09a76..d06619d3b3a 100644 --- a/.github/workflows/plugins_react_tests.yml +++ b/.github/workflows/plugins_react_tests.yml @@ -45,11 +45,11 @@ 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: "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: @@ -65,12 +65,27 @@ 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 + - 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 run test:plugins $(echo ${{ matrix.plugin }} | awk -F'/' '{print $NF}') working-directory: ${{ github.workspace }}/projects/foreman diff --git a/script/npm_test_plugin.js b/script/npm_test_plugin.js index e9c9a58cbcf..90eafc4afff 100755 --- a/script/npm_test_plugin.js +++ b/script/npm_test_plugin.js @@ -52,6 +52,7 @@ function runChildProcess(args, pluginPath) { } const runTests = async () => { var dirs = packageJsonDirs(); + console.log('dirs', dirs); function pluginDefinesLint(pluginPath) { var packageHasNodeModules = fs.existsSync(`${pluginPath}/node_modules`); // skip gems var packageData = JSON.parse(fs.readFileSync(`${pluginPath}/package.json`)); @@ -125,7 +126,7 @@ const runTests = async () => { '--color', ...passedArgs, ]; - + console.log('args', args); // eslint-disable-next-line no-await-in-loop await runChildProcess(args, pluginPath); // Run every plugin test in a separate process if (fs.existsSync(combinedConfigPath)) { diff --git a/script/plugin_webpack_directories.js b/script/plugin_webpack_directories.js index 08d006e9c10..33e9a60181e 100644 --- a/script/plugin_webpack_directories.js +++ b/script/plugin_webpack_directories.js @@ -47,8 +47,16 @@ var webpackedDirs = stderr => { }); }; -var getPluginDirs = stderr => - JSON.parse(sanitizeWebpackDirs(webpackedDirs(stderr))); +var getPluginDirs = stderr => { + console.log('stderr', stderr); + // console.log('webpackedDirs', webpackedDirs(stderr)); + // console.log( + // 'sanitizeWebpackDirs', + // // sanitizeWebpackDirs(webpackedDirs(stderr)) + // JSON.parse(sanitizeWebpackDirs(webpackedDirs(stderr))) + // ); + return JSON.parse(sanitizeWebpackDirs(webpackedDirs(stderr))); +}; var packageJsonDirs = stderr => pluginPath('package.json')(getPluginDirs(stderr)).map(path.dirname);