Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🦺 Check Ruby runtime #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ShiriNmi1520
Copy link

@ShiriNmi1520 ShiriNmi1520 commented Nov 11, 2024

Description

This PR adds Ruby runtime validation before running Ruby command.

Why this PR exists

I've encountered a weird EINVALIDGEMSPEC error when releasing my modification to RubyGem.
After struggling for half an hour, I discovered I was missing install Ruby in my CircleCI script; after adding them, the error disappeared.
This PR can add some clarity to error messages.

Fixed CircleCi configuration

jobs:
  release:
    executor: node/default
    steps:
      - checkout
      - check-changed-files-or-halt:
          pattern: ^(lib)|(.rb|gemspec)$
      # This ruby/install step was missing
      - ruby/install:
          version: 3.0.0
      - run: yarn install --frozen-lockfile
      - run: yarn semantic-release

Semantic release configuration

{
  "release": {
    "branches": ["master"]
  },
  "plugins": [
    "@semantic-release/commit-analyzer",
    "semantic-release-gitmoji",
    "@semantic-release/release-notes-generator",
    [
      "@webhippie/semantic-release-rubygem",
      {
        "gemPublish": true,
        "versionGlob": "lib/fastlane/plugin/google_cloud_storage/version.rb"
      }
    ]
  ]
}

Origin error before adding Ruby runtime

yarn run v1.22.22
$ /home/circleci/project/node_modules/.bin/semantic-release
[2:11:37 AM] [semantic-release] › ℹ  Running semantic-release version 24.2.0
[2:11:37 AM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@webhippie/semantic-release-rubygem"
[2:11:37 AM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[2:11:37 AM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "semantic-release-gitmoji"
[2:11:37 AM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "semantic-release-gitmoji"
[2:11:37 AM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[2:11:37 AM] [semantic-release] › ✔  Loaded plugin "prepare" from "@webhippie/semantic-release-rubygem"
[2:11:37 AM] [semantic-release] › ✔  Loaded plugin "publish" from "@webhippie/semantic-release-rubygem"
[2:11:37 AM] [semantic-release] › ✔  Run automated release from branch master on repository [email protected]:ShiriNmi1520/my-gem.git
[2:11:38 AM] [semantic-release] › ✔  Allowed to push to the Git repository
[2:11:38 AM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@webhippie/semantic-release-rubygem"
[2:11:38 AM] [semantic-release] › ✘  Failed step "verifyConditions" of plugin "@webhippie/semantic-release-rubygem"
[2:11:38 AM] [semantic-release] › ✘  EINVALIDGEMSPEC Error loading `my-gem.gemspec`
A valid .gemspec (https://guides.rubygems.org/specification-reference/) is required to release a Rubygem.

Please follow the "Make your own gem guide (https://guides.rubygems.org/make-your-own-gem/)" to create a valid .gemspec file
      

AggregateError: 
    SemanticReleaseError: Error loading `my-gem.gemspec`
        at loadGemspec (file:///home/circleci/project/node_modules/@webhippie/semantic-release-rubygem/lib/verify.js:37:11)
        at async verify (file:///home/circleci/project/node_modules/@webhippie/semantic-release-rubygem/lib/verify.js:122:29)
        at async verifyConditions (file:///home/circleci/project/node_modules/@webhippie/semantic-release-rubygem/index.js:17:40)
        at async validator (file:///home/circleci/project/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
        at async file:///home/circleci/project/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
        at async file:///home/circleci/project/node_modules/semantic-release/lib/plugins/pipeline.js:32:5
        at async pluginsConfigAccumulator.<computed> [as verifyConditions] (file:///home/circleci/project/node_modules/semantic-release/lib/plugins/index.js:87:11)
        at async run (file:///home/circleci/project/node_modules/semantic-release/index.js:106:3)
        at async Module.default (file:///home/circleci/project/node_modules/semantic-release/index.js:278:22)
    at file:///home/circleci/project/node_modules/semantic-release/lib/plugins/pipeline.js:55:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async pluginsConfigAccumulator.<computed> [as verifyConditions] (file:///home/circleci/project/node_modules/semantic-release/lib/plugins/index.js:87:11)
    at async run (file:///home/circleci/project/node_modules/semantic-release/index.js:106:3)
    at async Module.default (file:///home/circleci/project/node_modules/semantic-release/index.js:278:22)
    at async default (file:///home/circleci/project/node_modules/semantic-release/cli.js:55:5) {
  errors: [
    SemanticReleaseError: Error loading `my-gem.gemspec`
        at loadGemspec (file:///home/circleci/project/node_modules/@webhippie/semantic-release-rubygem/lib/verify.js:37:11)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async verify (file:///home/circleci/project/node_modules/@webhippie/semantic-release-rubygem/lib/verify.js:122:29)
        at async verifyConditions (file:///home/circleci/project/node_modules/@webhippie/semantic-release-rubygem/index.js:17:40)
        at async validator (file:///home/circleci/project/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
        at async file:///home/circleci/project/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
        at async file:///home/circleci/project/node_modules/semantic-release/lib/plugins/pipeline.js:32:5
        at async pluginsConfigAccumulator.<computed> [as verifyConditions] (file:///home/circleci/project/node_modules/semantic-release/lib/plugins/index.js:87:11)
        at async run (file:///home/circleci/project/node_modules/semantic-release/index.js:106:3)
        at async Module.default (file:///home/circleci/project/node_modules/semantic-release/index.js:278:22) {
      code: 'EINVALIDGEMSPEC',
      details: 'A valid [.gemspec](https://guides.rubygems.org/specification-reference/) is required to release a Rubygem.\n' +
        '\n' +
        'Please follow the "[Make your own gem guide](https://guides.rubygems.org/make-your-own-gem/)" to create a valid `.gemspec` file\n' +
        '      ',
      semanticRelease: true,
      pluginName: '@webhippie/semantic-release-rubygem'
    }
  ]
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Exited with code exit status 1

Add code to check if Ruby runtime is available before implementing the command.
@ShiriNmi1520
Copy link
Author

Reopen for resolved conflicts

@ShiriNmi1520 ShiriNmi1520 reopened this Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant