From c715f036a433ad84637fb1cc82e1c28620fe51e9 Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Fri, 24 Jan 2025 09:15:49 +0000 Subject: [PATCH 1/5] Add Actionlint --- .github/actionlint-matcher.json | 17 +++++++++++++++++ .github/workflows/lint-js-and-ruby.yml | 11 +++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .github/actionlint-matcher.json diff --git a/.github/actionlint-matcher.json b/.github/actionlint-matcher.json new file mode 100644 index 000000000..4613e1617 --- /dev/null +++ b/.github/actionlint-matcher.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "actionlint", + "pattern": [ + { + "regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$", + "file": 1, + "line": 2, + "column": 3, + "message": 4, + "code": 5 + } + ] + } + ] +} diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index 8597d95b5..a8d0eccc3 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -65,3 +65,14 @@ jobs: run: yarn start format.listDifferent - name: Type-check TypeScript run: yarn run type-check + - name: Lint GitHub Actions + # We only download and run Actionlint if there is any difference in GitHub Action workflows + # https://github.com/rhysd/actionlint/blob/main/docs/usage.md#on-github-actions + run: | + git fetch origin ${{ github.event.pull_request.base.sha }} + if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q '^.github/workflows'; then + echo "::add-matcher::.github/actionlint-matcher.json" + bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) + SHELLCHECK_OPTS="-S warning" ./actionlint -color + fi + shell: bash From ceb84abe301521d72abbe13674860e01b4df5a41 Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Fri, 24 Jan 2025 09:17:01 +0000 Subject: [PATCH 2/5] Fix Actionlint issues --- .github/workflows/examples.yml | 8 +++++-- .github/workflows/lint-js-and-ruby.yml | 9 ++++++-- .github/workflows/main.yml | 32 ++++++++++++++++++-------- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index d66cee35c..9da9ca627 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -61,7 +61,7 @@ jobs: path: vendor/bundle key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - id: get-sha - run: echo "::set-output name=sha::$(git rev-parse HEAD)" + run: echo "sha=\"$(git rev-parse HEAD)\"" >> "$GITHUB_OUTPUT" - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji @@ -69,7 +69,11 @@ jobs: - name: yalc publish for react-on-rails run: yalc publish - name: Install Ruby Gems for package - run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + run: | + bundle lock --add-platform 'x86_64-linux' + if ! bundle check --path=vendor/bundle; then + bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + fi - name: Ensure minimum required Chrome version run: | echo -e "Already installed $(google-chrome --version)\n" diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index a8d0eccc3..312c47f5f 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -52,9 +52,14 @@ jobs: - name: Install Node modules with Yarn for dummy app run: cd spec/dummy && yarn install --ignore-scripts --no-progress --no-emoji - name: Install Ruby Gems for dummy app - run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + run: | + cd spec/dummy + bundle lock --add-platform 'x86_64-linux' + if ! bundle check --path=vendor/bundle; then + bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + fi - name: generate file system-based packs - run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs + run: cd spec/dummy && RAILS_ENV="test" bundle exec rake react_on_rails:generate_packs - name: Detect dead code run: | yarn run knip diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43ac32e80..b22a1cef6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,13 +67,18 @@ jobs: path: spec/dummy/vendor/bundle key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - name: Install Ruby Gems for dummy app - run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + run: | + cd spec/dummy + bundle lock --add-platform 'x86_64-linux' + if ! bundle check --path=vendor/bundle; then + bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + fi - name: generate file system-based packs - run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs + run: cd spec/dummy && RAILS_ENV="test" bundle exec rake react_on_rails:generate_packs - name: Build test bundles for dummy app - run: cd spec/dummy && rm -rf public/webpack/test && yarn run build:rescript && RAILS_ENV=test NODE_ENV=test bin/${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer + run: cd spec/dummy && rm -rf public/webpack/test && yarn run build:rescript && RAILS_ENV="test" NODE_ENV="test" bin/${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer - id: get-sha - run: echo "::set-output name=sha::$(git rev-parse HEAD)" + run: echo "sha=\"$(git rev-parse HEAD)\"" >> "$GITHUB_OUTPUT" - name: Save test webpack bundles to cache (for build number checksum used by rspec job) uses: actions/cache/save@v4 with: @@ -133,7 +138,7 @@ jobs: path: spec/dummy/node_modules key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} - id: get-sha - run: echo "::set-output name=sha::$(git rev-parse HEAD)" + run: echo "sha=\"$(git rev-parse HEAD)\"" >> "$GITHUB_OUTPUT" - name: Save test webpack bundles to cache (for build number checksum used by rspec job) uses: actions/cache@v4 with: @@ -150,15 +155,24 @@ jobs: - name: Install Node modules with Yarn for dummy app run: cd spec/dummy && yarn install --no-progress --no-emoji - name: Install Ruby Gems for package - run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + run: | + bundle lock --add-platform 'x86_64-linux' + if ! bundle check --path=vendor/bundle; then + bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + fi - name: Install Ruby Gems for dummy app - run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + run: | + cd spec/dummy + bundle lock --add-platform 'x86_64-linux' + if ! bundle check --path=vendor/bundle; then + bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + fi - name: Ensure minimum required Chrome version run: | echo -e "Already installed $(google-chrome --version)\n" MINIMUM_REQUIRED_CHROME_VERSION=75 INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)" - if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then + if [[ $INSTALLED_CHROME_MAJOR_VERSION -lt $MINIMUM_REQUIRED_CHROME_VERSION ]]; then wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' sudo apt-get update @@ -168,7 +182,7 @@ jobs: - name: Increase the amount of inotify watchers run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - name: generate file system-based packs - run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs + run: cd spec/dummy && RAILS_ENV="test" bundle exec rake react_on_rails:generate_packs - name: Git Stuff if: matrix.versions == 'oldest' run: | From 52a9e82b93bd483d18cc8ff8d4f38b11e1512d66 Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Fri, 24 Jan 2025 09:17:46 +0000 Subject: [PATCH 3/5] Remove obsolete CI files --- .circleci/config.yml | 338 ------------------------------------------- .travis.yml | 61 -------- 2 files changed, 399 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index eab28626e..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,338 +0,0 @@ -# CircleCI is not longer in use by this repository & this file is now for reference only. -version: 2 - -aliases: - - &docker-image - - image: circleci/ruby:3.0-node-browsers - - # Print critical data and executables versions. - - &print-system-info - name: Print system information - command: | - 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 "Yarn version: "; yarn --version - echo "Bundler version: "; bundle --version - - &lint-js - name: Linting of JS - command: yarn start lint - - - &lint-ruby - name: Linting of Ruby - command: bundle exec rubocop - - - &format - name: Check formatting - command: yarn start format.listDifferent - - # Install/update Node modules for renderer package unless existing set of modules is satisfying Yarn. - - &install-package-node-modules - name: Install Node modules with Yarn for renderer package - command: | - sudo yarn global add yalc - yarn install --no-progress --no-emoji - yarn run eslint -v - - # Install/update Node modules for dummy app unless existing set of modules is satisfying Yarn. - - &install-dummy-app-node-modules - name: Install Node modules with Yarn for dummy app - command: cd spec/dummy && yarn install --no-progress --no-emoji - - # Setup yarn links for react-on-rails - - &install-yalc-publish - name: yalc publish for react-on-rails - command: yalc publish - - - &install-yalc-add-react-on-rails - name: yalc add react-on-rails - command: cd spec/dummy && yalc add react-on-rails - - # Install ruby gems unless existing set of gems is satisfying bundler. - - &install-dummy-app-ruby-gems - name: Install Ruby Gems for dummy app - command: | - gem install bundler:2.5.9 - echo "Bundler version: "; bundle --version - cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 - - # Install ruby gems unless existing set of gems is satisfying bundler. - - &install-package-ruby-gems - name: Install Ruby Gems for package - command: | - gem install bundler:2.5.9 - echo "Bundler version: "; bundle --version - bundle lock --add-platform 'x86_64-linux' - bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 - - # Restore node_modules dir from cache using yarn.lock checksum as a key. - - &restore-package-node-modules-cache - name: Restore cached node_modules directory - keys: - - v5-package-node-modules-cache-{{ checksum "yarn.lock" }} - - # Restore spec/dummy/node_modules dir from cache using yarn.lock checksum as a key. - - &restore-dummy-app-node-modules-cache - name: Restore cached spec/dummy/node_modules directory - keys: - - v5-dummy-app-node-modules-cache-{{ checksum "spec/dummy/yarn.lock" }} - - # Restore vendor/bundle dir from cache using Gemfile.lock checksum as a key. - - &restore-dummy-app-gem-cache - name: Restore cached Ruby Gems for dummy app - keys: - - v5-dummy-app-gem-cache-{{ checksum "spec/dummy/Gemfile.lock" }} - - # Restore vendor/bundle dir from cache using react_on_rails.gemspec checksum as a key. - - &restore-package-gem-cache - name: Restore cached Ruby Gems for package - keys: - - v5-package-app-gem-cache-{{ checksum "react_on_rails.gemspec" }} - - # NOTE: Sometimes CI generated docker images are not updated in time to keep up with the minimum required - # by chromedriver versions of Chrome. Just bump here Chrome version if chromedriver raises errors - - &install-latest-chrome - name: Ensure minimum required Chrome version - command: | - echo -e "Installed $(google-chrome --version)\n" - MINIMUM_REQUIRED_CHROME_VERSION=75 - INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)" - if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then - wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - - sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' - sudo apt-get update - sudo apt-get install google-chrome-stable - echo -e "\nInstalled $(google-chrome --version)" - fi - -jobs: - # Lint all - lint-js-and-ruby: - docker: *docker-image - steps: - - checkout - - run: *print-system-info - - restore_cache: *restore-package-node-modules-cache - - restore_cache: *restore-package-gem-cache - - run: *install-package-ruby-gems - - run: *lint-ruby - - run: *lint-js - - run: *format - - prettier: - docker: *docker-image - parallelism: 1 - steps: - - checkout - - restore_cache: *restore-package-node-modules-cache - - run: - name: prettier - command: yarn start format.listDifferent - - # Install Node modules for Renderer package with Yarn and save them to cache. - install-package-node-packages: - docker: *docker-image - steps: - - checkout - - run: *print-system-info - - restore_cache: *restore-package-node-modules-cache - - run: *install-package-node-modules - - save_cache: - name: Save root node_modules to cache - key: v5-package-node-modules-cache-{{ checksum "yarn.lock" }} - paths: - - node_modules - - - # Install Node modules for dummy app with Yarn and save them to cache. - install-dummy-app-node-packages: - docker: *docker-image - steps: - - checkout - - run: *print-system-info - - restore_cache: *restore-dummy-app-node-modules-cache - - run: *install-package-node-modules - - run: *install-yalc-publish - - run: *install-yalc-add-react-on-rails - - run: *install-dummy-app-node-modules - - save_cache: - name: Save spec/dummy/node_modules to cache - key: v5-dummy-app-node-modules-cache-{{ checksum "spec/dummy/yarn.lock" }} - paths: - - spec/dummy/node_modules - - spec/dummy/node_modules - - # Install Ruby gems for package with Bundler and save them to cache. - install-package-ruby-gems: - docker: *docker-image - steps: - - checkout - - run: *print-system-info - - restore_cache: *restore-package-gem-cache - - run: *install-package-ruby-gems - - save_cache: - name: Save dummy app ruby gems to cache - key: v5-package-app-gem-cache-{{ checksum "react_on_rails.gemspec" }} - paths: - - vendor/bundle - - # Install Ruby gems for dummy app with Bundler and save them to cache. - install-dummy-app-ruby-gems: - docker: *docker-image - steps: - - checkout - - run: *print-system-info - - restore_cache: *restore-dummy-app-gem-cache - - run: *install-dummy-app-ruby-gems - - save_cache: - name: Save dummy app ruby gems to cache - key: v5-dummy-app-gem-cache-{{ checksum "spec/dummy/Gemfile.lock" }} - paths: - - spec/dummy/vendor/bundle - - # Build client and server bundles for dummy app with Webpack and save them to cache. - # NOTE: keeping around this cache in case we have multiple rspec suites in the future to tests - # different node renderers. - build-dummy-app-webpack-test-bundles: - docker: *docker-image - steps: - - checkout - - run: *print-system-info - - run: *install-package-node-modules - - run: *install-yalc-publish - - restore_cache: *restore-dummy-app-node-modules-cache - - run: *install-yalc-add-react-on-rails - - run: *install-dummy-app-node-modules - - run: *install-dummy-app-ruby-gems - - run: - name: generate file system-based packs - command: cd spec/dummy && bundle exec rake react_on_rails:generate_packs - - run: - name: Build test bundles for dummy app - command: cd spec/dummy && yarn run build:test - - save_cache: - name: Save test webpack bundles to cache (for build number checksum used by rspec job) - key: v5-dummy-app-webpack-bundle-{{ .Revision }} - paths: - - spec/dummy/public/webpack - # Run JS unit tests for Renderer package. - package-js-tests: - docker: *docker-image - steps: - - checkout - - run: *print-system-info - - restore_cache: *restore-package-node-modules-cache - - run: *install-package-node-modules - - run: - name: Run JS unit tests for Renderer package - command: yarn test - - rspec-package-specs: - docker: *docker-image - steps: - - checkout - - run: *print-system-info - - restore_cache: *restore-package-gem-cache - - run: *install-package-ruby-gems - - run: - name: Run rspec tests - command: | - bundle exec rspec spec/react_on_rails - - store_test_results: - path: ~/rspec - - store_artifacts: - path: log/test.log - - main: - docker: *docker-image - steps: - - checkout - - run: *print-system-info - - restore_cache: *restore-package-gem-cache - - restore_cache: *restore-dummy-app-gem-cache - - restore_cache: - name: Restore cached webpack bundles for dummy app - key: v5-dummy-app-webpack-bundle-{{ .Revision }} - - restore_cache: *restore-dummy-app-node-modules-cache - - restore_cache: *restore-package-node-modules-cache - - run: *install-package-node-modules - - run: *install-yalc-publish - - run: *install-yalc-add-react-on-rails - - run: *install-package-ruby-gems - - run: *install-dummy-app-ruby-gems - - run: *install-latest-chrome - - run: - name: Touch webpack bundles - command: touch spec/dummy/public/webpack/test/* - - run: - name: Install yalc globally - command: sudo yarn global add yalc - - run: - name: Prep for CI - # TODO -- need to leverage Circle CI containers - command: | - bundle exec rake prepare_for_ci - - run: - name: Main CI - # TODO -- need to leverage Circle CI containers - command: | - bundle exec rake run_rspec:all_dummy - # The following step will run only if the main job is finished successfully. - # Build hook is triggered by curl command described here https://docs.netlify.com/configure-builds/build-hooks/ - # NETLIFY_HOOK is an environment variable on CircleCI to keep sensitive data outside the repo - - run: - name: Deploy SC website - command: | - if [ $CIRCLE_BRANCH = "master" ]; then - curl -X POST -d '{}' ${NETLIFY_HOOK} - fi - when: on_success - - store_test_results: - path: ~/rspec - - store_artifacts: - path: spec/dummy/tmp/capybara - - store_artifacts: - path: spec/dummy/tmp/screenshots - - store_artifacts: - path: spec/dummy/log/test.log - - store_artifacts: - path: spec/dummy/yarn-error.log - -workflows: - version: 2 - build-and-test: - jobs: - - install-package-node-packages - - install-package-ruby-gems - - install-dummy-app-node-packages - - install-dummy-app-ruby-gems - - lint-js-and-ruby: - requires: - - install-package-node-packages - - install-package-ruby-gems - - prettier: - filters: - branches: - ignore: master - requires: - - install-package-node-packages - - build-dummy-app-webpack-test-bundles: - requires: - - install-dummy-app-node-packages - - install-dummy-app-ruby-gems - - package-js-tests: - requires: - - install-package-node-packages - - rspec-package-specs: - requires: - - install-package-ruby-gems - - build-dummy-app-webpack-test-bundles - - install-dummy-app-ruby-gems - - main: - requires: - - install-package-ruby-gems - - install-dummy-app-ruby-gems - - install-package-node-packages - - build-dummy-app-webpack-test-bundles diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6790f821f..000000000 --- a/.travis.yml +++ /dev/null @@ -1,61 +0,0 @@ -sudo: required - -language: ruby - -rvm: - - 2.5.9 - - 2.6.5 - - 2.7.0 - -services: - - docker - -cache: - bundler: true - directories: - - node_modules # NPM packages - yarn: true - -gemfile: - - spec/dummy/Gemfile - -env: - global: - - RAILS_ENV=test - - DRIVER=selenium_chrome - - CHROME_BIN=/usr/bin/google-chrome - - USE_COVERALLS=TRUE - -before_install: - - sudo apt-get update - - sudo apt-get install -y xvfb libappindicator1 fonts-liberation - - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb - - sudo dpkg -i google-chrome*.deb - - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen scn 1600x1200x16" - -install: - - travis_retry gem install bundler -v '>2' - - travis_retry nvm install 14 - - node -v - - travis_retry npm i -g yarn - - travis_retry yarn global add yalc - - travis_retry yalc add react-on-rails - - travis_retry yarn - - travis_retry bundle install - - travis_retry yarn run build - - travis_retry yalc publish - - cd spec/dummy - - travis_retry yalc add react-on-rails - - travis_retry yarn - - cd ../.. - - bundle exec rake prepare_for_ci - -before_script: - - "export DISPLAY=:99" - -script: - - bundle exec rake - -notifications: - slack: - secure: LfcUk4AJ4vAxWwRIyw4tFh8QNbYefMwfG/oLfsN3CdRMWMOtCOHR1GGsRhAOlfVVJ/FvHqVqWj5gK7z7CaO5Uvl7rD3/zJ8QzExKx/iH9yWj55iIPuKLzwFNnBwRpFW/cqyU2lFPPRxGD50BUn3c+qybkuSqtKZ6qtTowwqlxLa5iyM3N95aZp7MEIKCP7cPcnHfLbJyP8wBpotp/rtw62eXM2HIRJJwgjcp+n+My7VFR9DnBXNFf6R91aZHM4U4cHHDbu15HFtH8honVrzK1JQdyqMNHga+j04dFuaS7z9Q369/hsELMOBp/227+Pz7ZRfWZFK4UASguOvyeX7RmGTRpTuWLm1XJeUzfsPZVROecaSVQBve+U7F12yKqilt97QlvRXn2EGyBILqvxtFNNR4S9kgAf72/6EFgiM1TKq7i9zy6lVOnagU2+7amq7UeopX1uoFsUfNKMR7YbgV1WjF0IK95UP0b0/7ZOJlPYgi5zzkQi129qAFWSMmxGk+ZpsttHh/tjJtvAh0A3mHq/zb5w4ub/MbSyZqeDUNgGj72QArOWUFSAStQT1ybsVLeDoKPgOvVq7OV1D64rpcHjBXcqOCit8tDZ+TqkFhcYJo2cITSaqE4zJXn+4F5s7So5O8CyfKYQq+kFJCooYGmfgTUckJpGl7eIvKmL4TN9Q= From 8ee607c01b945431f0034d91032e39c5db559e0f Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Fri, 24 Jan 2025 10:35:03 +0000 Subject: [PATCH 4/5] Cache Actionlint --- .github/workflows/lint-js-and-ruby.yml | 28 ++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index 312c47f5f..95ffffafe 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -70,14 +70,30 @@ jobs: run: yarn start format.listDifferent - name: Type-check TypeScript run: yarn run type-check - - name: Lint GitHub Actions - # We only download and run Actionlint if there is any difference in GitHub Action workflows - # https://github.com/rhysd/actionlint/blob/main/docs/usage.md#on-github-actions + # We only download and run Actionlint if there is any difference in GitHub Action workflows + # https://github.com/rhysd/actionlint/blob/main/docs/usage.md#on-github-actions + - name: Check for GitHub Actions changes + id: check-workflows run: | git fetch origin ${{ github.event.pull_request.base.sha }} if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q '^.github/workflows'; then - echo "::add-matcher::.github/actionlint-matcher.json" - bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) - SHELLCHECK_OPTS="-S warning" ./actionlint -color + echo "changed=true" >> "$GITHUB_OUTPUT" + actionlint_version=$(curl -s https://api.github.com/repos/rhysd/actionlint/releases/latest | jq -r .tag_name) + echo "actionlint_version=\"$actionlint_version\"" >> "$GITHUB_OUTPUT" fi + - name: Setup Actionlint + if: steps.check-workflows.outputs.changed == 'true' + uses: actions/cache@v4 + id: cache-actionlint + with: + path: ./actionlint + key: ${{ runner.os }}-actionlint-${{ steps.check-workflows.outputs.actionlint_version }} + - name: Download Actionlint + if: steps.check-workflows.outputs.changed == 'true' && steps.cache-actionlint.outputs.cache-hit != 'true' + run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) + - name: Lint GitHub Actions + if: steps.check-workflows.outputs.changed == 'true' + run: | + echo "::add-matcher::.github/actionlint-matcher.json" + SHELLCHECK_OPTS="-S warning" ./actionlint -color shell: bash From a6c16a74d4b83461fff3ed55cfd433e103f9ec0f Mon Sep 17 00:00:00 2001 From: Alexey Romanov <104450112+alexeyr-ci@users.noreply.github.com> Date: Fri, 24 Jan 2025 13:45:01 +0300 Subject: [PATCH 5/5] Better error handling for GitHub API Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .github/workflows/lint-js-and-ruby.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index 95ffffafe..a2c783347 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -78,7 +78,17 @@ jobs: git fetch origin ${{ github.event.pull_request.base.sha }} if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q '^.github/workflows'; then echo "changed=true" >> "$GITHUB_OUTPUT" - actionlint_version=$(curl -s https://api.github.com/repos/rhysd/actionlint/releases/latest | jq -r .tag_name) + response=$(curl -sf https://api.github.com/repos/rhysd/actionlint/releases/latest) + if [ $? -eq 0 ]; then + actionlint_version=$(echo "$response" | jq -r .tag_name) + if [ -z "$actionlint_version" ]; then + echo "Failed to parse Actionlint version" + exit 1 + fi + else + echo "Failed to fetch latest Actionlint version" + exit 1 + fi echo "actionlint_version=\"$actionlint_version\"" >> "$GITHUB_OUTPUT" fi - name: Setup Actionlint