Migrate from Yarn Classic to pnpm #480
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: React on Rails Pro - Package Tests | |
| on: | |
| push: | |
| branches: | |
| - 'master' | |
| # Always trigger on master; docs-only detection handles skipping heavy jobs | |
| pull_request: | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| - 'react_on_rails/lib/**' | |
| - 'react_on_rails/spec/**' | |
| - 'packages/react_on_rails/**' | |
| workflow_dispatch: | |
| inputs: | |
| force_run: | |
| description: 'Force run all jobs (bypass detect-changes)' | |
| required: false | |
| type: boolean | |
| default: false | |
| defaults: | |
| run: | |
| working-directory: react_on_rails_pro | |
| jobs: | |
| detect-changes: | |
| permissions: | |
| contents: read | |
| actions: read | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| docs_only: ${{ steps.detect.outputs.docs_only }} | |
| run_pro_lint: ${{ steps.detect.outputs.run_pro_lint }} | |
| run_pro_tests: ${{ steps.detect.outputs.run_pro_tests }} | |
| has_full_ci_label: ${{ steps.check-label.outputs.result }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Check for full-ci label | |
| id: check-label | |
| uses: ./.github/actions/check-full-ci-label | |
| - name: Detect relevant changes | |
| id: detect | |
| working-directory: . | |
| run: | | |
| # If force_run is true OR full-ci label is present, run everything | |
| if [ "${{ inputs.force_run }}" = "true" ] || [ "${{ steps.check-label.outputs.result }}" = "true" ]; then | |
| echo "run_pro_lint=true" >> "$GITHUB_OUTPUT" | |
| echo "run_pro_tests=true" >> "$GITHUB_OUTPUT" | |
| echo "docs_only=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| BASE_REF="${{ github.event.pull_request.base.sha || github.event.before || 'origin/master' }}" | |
| script/ci-changes-detector "$BASE_REF" | |
| shell: bash | |
| - name: Guard docs-only master pushes | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| uses: ./.github/actions/ensure-master-docs-safety | |
| with: | |
| docs-only: ${{ steps.detect.outputs.docs_only }} | |
| previous-sha: ${{ github.event.before }} | |
| # Build webpack test bundles for dummy app | |
| build-dummy-app-webpack-test-bundles: | |
| needs: detect-changes | |
| if: | | |
| !( | |
| github.event_name == 'push' && | |
| github.ref == 'refs/heads/master' && | |
| needs.detect-changes.outputs.docs_only == 'true' | |
| ) && ( | |
| github.ref == 'refs/heads/master' || | |
| github.event_name == 'workflow_dispatch' || | |
| needs.detect-changes.outputs.run_pro_tests == 'true' | |
| ) | |
| runs-on: ubuntu-22.04 | |
| env: | |
| REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE_V2 }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: 3.3.7 | |
| bundler: 2.5.4 | |
| - name: Setup Node | |
| uses: ./.github/actions/setup-node-with-retry | |
| with: | |
| # Pin to 22.11.0 (LTS) to avoid V8 bug in 22.21.0 | |
| # https://github.com/nodejs/node/issues/56010 | |
| node-version: '22.11.0' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Print system information | |
| run: | | |
| echo "Linux release: "; cat /etc/issue | |
| echo "Current user: "; whoami | |
| echo "Current directory: "; pwd | |
| echo "Ruby version: "; ruby -v | |
| echo "Node version: "; node -v | |
| echo "pnpm version: "; pnpm --version | |
| echo "Bundler version: "; bundle --version | |
| - name: Cache Pro dummy app Ruby gems | |
| uses: actions/cache@v4 | |
| with: | |
| path: react_on_rails_pro/spec/dummy/vendor/bundle | |
| key: v4-pro-dummy-app-gem-cache-${{ hashFiles('react_on_rails_pro/spec/dummy/Gemfile.lock') }} | |
| - name: Install Node modules with pnpm for Pro package | |
| run: | | |
| pnpm add -g yalc | |
| pnpm install --frozen-lockfile | |
| - name: Install Node modules with pnpm for Pro dummy app | |
| # --ignore-workspace prevents pnpm from treating this as part of the parent workspace | |
| run: cd spec/dummy && pnpm install --ignore-workspace | |
| - name: Install Ruby Gems for Pro dummy app | |
| run: | | |
| gem install bundler -v "2.5.4" | |
| cd spec/dummy | |
| bundle lock --add-platform 'x86_64-linux' | |
| bundle _2.5.4_ check || bundle _2.5.4_ install --jobs=4 --retry=3 | |
| - name: Generate file-system based entrypoints | |
| run: cd spec/dummy && bundle exec rake react_on_rails:generate_packs | |
| - name: Build test bundles for Pro dummy app | |
| run: cd spec/dummy && pnpm run build:test | |
| - id: get-sha | |
| run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| - name: Save test webpack bundles to cache | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| react_on_rails_pro/spec/dummy/public/webpack/test | |
| react_on_rails_pro/spec/dummy/ssr-generated | |
| key: v4-pro-dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }} | |
| # Jest unit tests for Pro package | |
| package-js-tests: | |
| needs: | |
| - detect-changes | |
| - build-dummy-app-webpack-test-bundles | |
| if: | | |
| !( | |
| github.event_name == 'push' && | |
| github.ref == 'refs/heads/master' && | |
| needs.detect-changes.outputs.docs_only == 'true' | |
| ) && ( | |
| github.ref == 'refs/heads/master' || | |
| github.event_name == 'workflow_dispatch' || | |
| needs.detect-changes.outputs.run_pro_tests == 'true' | |
| ) | |
| runs-on: ubuntu-22.04 | |
| # Redis service container | |
| services: | |
| redis: | |
| image: cimg/redis:6.2.6 | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| env: | |
| REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE_V2 }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Node | |
| uses: ./.github/actions/setup-node-with-retry | |
| with: | |
| # Pin to 22.11.0 (LTS) to avoid V8 bug in 22.21.0 | |
| # https://github.com/nodejs/node/issues/56010 | |
| node-version: '22.11.0' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Print system information | |
| run: | | |
| echo "Linux release: "; cat /etc/issue | |
| echo "Current user: "; whoami | |
| echo "Current directory: "; pwd | |
| echo "Node version: "; node -v | |
| echo "pnpm version: "; pnpm --version | |
| - name: Remove old webpack bundles | |
| run: | | |
| rm -rf spec/dummy/public/webpack | |
| rm -rf spec/dummy/ssr-generated | |
| - id: get-sha | |
| run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| - name: Restore test webpack bundles from cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| react_on_rails_pro/spec/dummy/public/webpack/test | |
| react_on_rails_pro/spec/dummy/ssr-generated | |
| key: v4-pro-dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }} | |
| - name: Install Node modules with pnpm for Pro package | |
| working-directory: . | |
| run: | | |
| pnpm add -g yalc | |
| pnpm install --frozen-lockfile | |
| - name: Run JS unit tests for Pro package | |
| run: pnpm --filter react-on-rails-pro-node-renderer run ci | |
| env: | |
| JEST_JUNIT_OUTPUT_DIR: ./jest | |
| JEST_JUNIT_ADD_FILE_ATTRIBUTE: "true" | |
| - name: Store test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: pro-jest-results | |
| path: packages/react-on-rails-pro-node-renderer/jest | |
| # RSpec tests for Pro package | |
| rspec-gem-specs: | |
| needs: detect-changes | |
| if: | | |
| !( | |
| github.event_name == 'push' && | |
| github.ref == 'refs/heads/master' && | |
| needs.detect-changes.outputs.docs_only == 'true' | |
| ) && ( | |
| github.ref == 'refs/heads/master' || | |
| github.event_name == 'workflow_dispatch' || | |
| needs.detect-changes.outputs.run_pro_tests == 'true' | |
| ) | |
| strategy: | |
| matrix: | |
| ruby-version: ['3.3.7'] | |
| runs-on: ubuntu-22.04 | |
| env: | |
| REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE_V2 }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler: 2.5.4 | |
| - name: Print system information | |
| run: | | |
| echo "Linux release: "; cat /etc/issue | |
| echo "Current user: "; whoami | |
| echo "Current directory: "; pwd | |
| echo "Ruby version: "; ruby -v | |
| echo "Bundler version: "; bundle --version | |
| - name: Cache Pro package Ruby gems | |
| uses: actions/cache@v4 | |
| with: | |
| path: react_on_rails_pro/vendor/bundle | |
| key: v4-pro-package-gem-cache-ruby${{ matrix.ruby-version }}-${{ hashFiles('react_on_rails_pro/react_on_rails_pro.gemspec') }} | |
| - name: Install Ruby Gems for Pro package | |
| run: | | |
| gem install bundler -v "2.5.4" | |
| echo "Bundler version: "; bundle --version | |
| bundle config set --local path 'vendor/bundle' | |
| bundle config set --local disable_checksum_validation true | |
| bundle _2.5.4_ check || bundle _2.5.4_ install --jobs=4 --retry=3 | |
| - name: Run RSpec tests for Pro package | |
| run: bundle exec rspec spec/react_on_rails_pro | |
| - name: Store test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: pro-rspec-package-results-ruby${{ matrix.ruby-version }} | |
| path: ~/rspec | |
| - name: Store test log | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: pro-rspec-package-log-ruby${{ matrix.ruby-version }} | |
| path: react_on_rails_pro/log/test.log |