Skip to content

Commit 7cc3654

Browse files
authored
Merge pull request #16 from chef/nikhil/create-lock-file-runtime
Fix Ruby build and add runtime Gemfile.lock generation support
2 parents 1cb5ba0 + 6d67079 commit 7cc3654

2 files changed

Lines changed: 34 additions & 12 deletions

File tree

.github/workflows/ci-main-pull-request.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ on:
359359
required: false
360360
type: string
361361
default: 'path/to/detect'
362+
run-bundle-install: # Added to support projects without committed Gemfile.lock (e.g., chef-cli)
363+
description: 'Run bundle install before scanning to generate Gemfile.lock at runtime'
364+
required: false
365+
type: boolean
366+
default: false
362367

363368
udf1:
364369
description: 'User defined flag 1'
@@ -764,21 +769,25 @@ jobs:
764769
# run: echo 'hello world'
765770
# # cargo build --release --target-dir ./bin
766771

767-
# - name: Build for Ruby binary
768-
# simple bundle install to generate gemlock(puts them in directory vendor/bundle, and uses actual gemspec for deployment to get multi-architecture ), then build gem
769-
# https://bundler.io/man/bundle-install.1.html
772+
# - name: Build for Ruby binary
773+
# simple bundle install to generate gemlock(puts them in directory vendor/bundle, and uses actual gemspec for deployment to get multi-architecture ), then build gem
774+
# https://bundler.io/man/bundle-install.1.html
775+
- name: Set up Ruby # Fixed: Ruby setup was missing, causing "bundle: command not found" errors
776+
if: ${{ inputs.language == 'ruby' && inputs.build-profile == 'cli' }}
777+
uses: ruby/setup-ruby@v1
778+
with:
779+
ruby-version: '3.4'
770780
- name: 'Ruby build'
771781
if: ${{ inputs.language == 'ruby' && inputs.build-profile == 'cli' }}
772782
run: |
773-
echo "Ruby bundle here"
774-
# mkdir -p vendor
775-
# if [ -f "Gemfile.lock" ]; then
776-
# bundle install --deployment
777-
# else
778-
# echo "No .gemlock file found, creating it now"
779-
# bundle install --path vendor/bundle --deployment
780-
# fi
781-
# bundle exec rake build
783+
mkdir -p vendor
784+
if [ -f "Gemfile.lock" ]; then
785+
bundle install --deployment
786+
else
787+
echo "No Gemfile.lock found, creating it now"
788+
bundle install --path vendor/bundle # Fixed: Removed --deployment flag when lockfile doesn't exist
789+
fi
790+
bundle exec rake build
782791
783792
# - name: Configure git for private modules
784793
# env:
@@ -1304,6 +1313,7 @@ jobs:
13041313
generate-msft-sbom: ${{ inputs.generate-msft-sbom }}
13051314
license_scout: ${{ inputs.license_scout }}
13061315
go-private-modules: ${{ inputs.go-private-modules }}
1316+
run-bundle-install: ${{ inputs.run-bundle-install }} # Passed to sbom.yml to generate Gemfile.lock at runtime
13071317

13081318
quality-dashboard:
13091319
name: 'Reporting to quality dashboard'

.github/workflows/sbom.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ on:
6565
go-private-modules:
6666
required: false
6767
type: string
68+
run-bundle-install:
69+
description: 'Run bundle install before scanning to generate Gemfile.lock at runtime'
70+
required: false
71+
type: boolean
72+
default: false
6873

6974
env:
7075
# Set the default SBOM filename prefix
@@ -190,6 +195,13 @@ jobs:
190195
- name: Checkout source
191196
uses: actions/checkout@v6
192197

198+
- name: Set up Ruby and run bundle install
199+
if: ${{ inputs.run-bundle-install == true }}
200+
uses: ruby/setup-ruby@v1
201+
with:
202+
ruby-version: '3.4'
203+
bundler-cache: true
204+
193205
- name: Configure git for private Go modules
194206
env:
195207
GOPRIVATE: ${{ inputs.go-private-modules }}

0 commit comments

Comments
 (0)