Skip to content

Commit

Permalink
Add language property to service entity
Browse files Browse the repository at this point in the history
  • Loading branch information
gwthm-in committed Nov 24, 2023
1 parent 7e6ad76 commit 7c97c1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions port-packages/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def extract_ruby_packages
return unless File.exist?('Gemfile.lock')

in_specification_block = false
version_pattern = /(~>|=>|>|=|<=|<)/

File.readlines('Gemfile.lock').each do |line|
line.strip!
Expand All @@ -71,6 +72,7 @@ def extract_ruby_packages
in_specification_block = true
elsif in_specification_block && line =~ /^(\S+)\s+\(([^,]+),.*\)$/
name, version = $1, $2
version.gsub!(version_pattern, '').strip!
$packages << {"properties" => {"name" => name, "version" => version, "language" => "Ruby"}, "blueprint" => "package", "identifier" => "#{name}@#{version}", "title" => "#{name}@#{version}"}
elsif line.empty? && in_specification_block
in_specification_block = false
Expand Down
14 changes: 14 additions & 0 deletions port-service/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ inputs:
required: true
description: 'Client secret'
testCoverage:
default: 0
required: false
descripition: 'Service test coverage'
sonarStatus:
Expand All @@ -30,6 +31,18 @@ runs:
run: |
echo "identifiers=$(echo '${{steps.extract-packages.outputs.packages}}' | jq --compact-output -r '[.[] | .identifier]')" >> "$GITHUB_OUTPUT"
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7' # Not needed with a .ruby-version file

- name: "Service language"
id: service-language
shell: bash
run: |
gem install github-linguist
language=`github-linguist | head -1 | awk '{print $3}'`
echo "language=$language" >> "$GITHUB_OUTPUT"
# Extract packages from package manager version file based on the language.
- name: "Readme content"
id: readme
Expand All @@ -51,6 +64,7 @@ runs:
"url": "${{ github.server_url }}/${{ github.repository }}",
"README": "${{ steps.readme.outputs.readme }}",
"about": "${{ github.event.repository.description }}",
"language": "${{ steps.service-language.outputs.language }}",
"test_coverage": "${{ inputs.testCoverage }}",
"sonar_status": "${{ inputs.sonarStatus }}"
}
Expand Down
2 changes: 2 additions & 0 deletions port-service/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def extract_ruby_packages
return unless File.exist?('Gemfile.lock')

in_specification_block = false
version_pattern = /(~>|=>|>|=|<=|<)/

File.readlines('Gemfile.lock').each do |line|
line.strip!
Expand All @@ -71,6 +72,7 @@ def extract_ruby_packages
in_specification_block = true
elsif in_specification_block && line =~ /^(\S+)\s+\(([^,]+),.*\)$/
name, version = $1, $2
version.gsub!(version_pattern, '').strip!
$packages << {"properties" => {"name" => name, "version" => version, "language" => "Ruby"}, "blueprint" => "package", "identifier" => "#{name}@#{version}", "title" => "#{name}@#{version}"}
elsif line.empty? && in_specification_block
in_specification_block = false
Expand Down

0 comments on commit 7c97c1f

Please sign in to comment.