Skip to content

Commit cce15c6

Browse files
authored
Merge pull request #156 from OpenVoxProject/packaging
Pull openbolt-vanagon repo into packaging directory
2 parents 2c13a97 + c8b88b9 commit cce15c6

104 files changed

Lines changed: 3780 additions & 49 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: Build openbolt
3+
4+
permissions:
5+
contents: read
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
ref:
11+
description: 'Tag to build'
12+
required: true
13+
project_name:
14+
description: 'The vanagon project to build'
15+
required: false
16+
default: 'openbolt'
17+
platform_list:
18+
description: 'A comma-separated list of platforms to build for. Do not include spaces. If not provided, will use the default list of platform supported by OpenVox.'
19+
required: false
20+
type: string
21+
vanagon_branch:
22+
description: 'The branch of the vanagon repository to use'
23+
required: false
24+
type: string
25+
default: 'main'
26+
upload_to_s3:
27+
description: 'Whether to upload the built artifacts to S3. If false, the artifacts will only be uploaded as workflow artifacts.'
28+
required: false
29+
type: boolean
30+
default: true
31+
use_dev:
32+
description: 'Use the "dev" branch of the shared-actions repo'
33+
required: false
34+
type: boolean
35+
default: false
36+
37+
jobs:
38+
build:
39+
if: ${{ github.event.inputs.use_dev == 'false' }}
40+
uses: 'openvoxproject/shared-actions/.github/workflows/build_vanagon.yml@main'
41+
with:
42+
ref: ${{ inputs.ref }}
43+
project_name: ${{ inputs.project_name }}
44+
platform_list: ${{ inputs.platform_list }}
45+
vanagon_branch: ${{ inputs.vanagon_branch }}
46+
upload_to_s3: ${{ inputs.upload_to_s3 }}
47+
working_directory: 'packaging'
48+
secrets: inherit
49+
build_dev:
50+
if: ${{ github.event.inputs.use_dev == 'true' }}
51+
uses: 'openvoxproject/shared-actions/.github/workflows/build_vanagon.yml@dev'
52+
with:
53+
ref: ${{ inputs.ref }}
54+
project_name: ${{ inputs.project_name }}
55+
platform_list: ${{ inputs.platform_list }}
56+
vanagon_branch: ${{ inputs.vanagon_branch }}
57+
upload_to_s3: ${{ inputs.upload_to_s3 }}
58+
working_directory: 'packaging'
59+
secrets: inherit

.github/workflows/prepare_release.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Version to be released.'
8-
required: false
9-
default: ''
7+
description: 'Version to be released'
8+
required: true
109
type: string
1110
base-branch:
1211
description: 'The branch that will be used as the origin for the release branch.'
1312
required: false
14-
default: ''
13+
default: 'main'
1514
type: string
1615

1716
permissions: {}
@@ -20,9 +19,8 @@ jobs:
2019
prepare_release:
2120
uses: OpenVoxProject/shared-actions/.github/workflows/prepare_release.yml@main
2221
with:
23-
allowed_owner: 'OpenVoxProject'
24-
base-branch: ${{ github.event.inputs.base-branch }}
25-
version: ${{ github.event.inputs.version }}
22+
version: ${{ inputs.version }}
23+
base-branch: ${{ inputs.base-branch }}
2624
secrets:
2725
github_pat: ${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}
28-
ssh_private_key: ${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}
26+
ssh_private_key: ${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}

.github/workflows/promote.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Promote Component
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
component:
7+
description: 'Component name to promote'
8+
required: true
9+
type: string
10+
ref:
11+
description: 'Git ref/tag to promote. For puppet-runtime, use the tag that has been built and uploaded to openvox-artifacts.'
12+
required: true
13+
type: string
14+
branch:
15+
description: 'Branch to promote to (defaults to main)'
16+
required: false
17+
default: 'main'
18+
type: string
19+
20+
permissions: {}
21+
22+
env:
23+
GIT_AUTHOR_NAME: OpenVoxProjectBot
24+
GIT_AUTHOR_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com
25+
GIT_COMMITTER_NAME: OpenVoxProjectBot
26+
GIT_COMMITTER_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com
27+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
28+
29+
jobs:
30+
promote:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v6
35+
with:
36+
ref: ${{ inputs.branch }}
37+
token: ${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}
38+
39+
- name: Add SSH key
40+
run: |
41+
mkdir -p ~/.ssh
42+
echo "${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}" > ~/.ssh/github_actions
43+
chmod 600 ~/.ssh/github_actions
44+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
45+
ssh-add ~/.ssh/github_actions
46+
47+
- name: Setup git
48+
run: |
49+
git config --global user.email "$GIT_AUTHOR_EMAIL"
50+
git config --global user.name "$GIT_AUTHOR_NAME"
51+
git config --global gpg.format ssh
52+
git config --global user.signingkey ~/.ssh/github_actions
53+
git config --global commit.gpgsign true
54+
git config --global tag.gpgsign true
55+
56+
- name: Validate component exists
57+
run: |
58+
component="${{ inputs.component }}"
59+
if [[ ! -f "packaging/configs/components/${component}.json" ]]; then
60+
echo "::error::Could not find packaging/configs/components/${component}.json"
61+
exit 1
62+
fi
63+
64+
- name: Generate component JSON
65+
id: generate
66+
run: |
67+
component="${{ inputs.component }}"
68+
ref="${{ inputs.ref }}"
69+
70+
if [[ "${component}" == "puppet-runtime" ]]; then
71+
# Munge the ref: replace - with .
72+
munged="${ref//-/.}"
73+
json="{\"location\":\"https://s3.osuosl.org/openvox-artifacts/${component}/${ref}/\",\"version\":\"${munged}\"}"
74+
else
75+
json="{\"url\":\"https://github.com/openvoxproject/${component}.git\",\"ref\":\"${ref}\"}"
76+
fi
77+
78+
echo "json=${json}" >> "$GITHUB_OUTPUT"
79+
echo "Generated JSON: ${json}"
80+
81+
- name: Write component JSON
82+
run: |
83+
component="${{ inputs.component }}"
84+
echo '${{ steps.generate.outputs.json }}' > "packaging/configs/components/${component}.json"
85+
echo "Wrote packaging/configs/components/${component}.json:"
86+
cat "packaging/configs/components/${component}.json"
87+
88+
- name: Create Pull Request
89+
uses: peter-evans/create-pull-request@v7
90+
with:
91+
commit-message: "Promote ${{ inputs.component }} ${{ inputs.ref }}"
92+
branch: "promote/${{ inputs.component }}/${{ inputs.ref }}"
93+
delete-branch: true
94+
title: "Promote ${{ inputs.component }} ${{ inputs.ref }}"
95+
token: ${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}
96+
assignees: '${{ github.triggering_actor }}'
97+
author: '${{ env.GIT_AUTHOR_NAME }} <${{ env.GIT_AUTHOR_EMAIL }}>'
98+
committer: '${{ env.GIT_COMMITTER_NAME }} <${{ env.GIT_COMMITTER_EMAIL }}>'
99+
base: ${{ inputs.branch }}
100+
body: |
101+
Automated promotion of ${{ inputs.component }} to ref ${{ inputs.ref }}.

.github/workflows/release.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'Version to be released.'
8-
required: false
9-
default: ''
7+
description: 'Version to be released'
8+
required: true
109
type: string
1110
base-branch:
1211
description: 'The branch where we do this release.'
1312
required: false
14-
default: ''
13+
default: 'main'
1514
type: string
1615

1716
permissions: {}
@@ -20,9 +19,9 @@ jobs:
2019
release:
2120
uses: OpenVoxProject/shared-actions/.github/workflows/release.yml@main
2221
with:
23-
allowed_owner: 'OpenVoxProject'
24-
base-branch: ${{ github.event.inputs.base-branch }}
25-
version: ${{ github.event.inputs.version }}
22+
version: ${{ inputs.version }}
23+
base-branch: ${{ inputs.base-branch }}
24+
bump_to_rc_after_release: false
2625
secrets:
2726
github_pat: ${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}
28-
ssh_private_key: ${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}
27+
ssh_private_key: ${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}

.rubocop.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ AllCops:
1111
- .vendor/**/*
1212
- spec/fixtures/**/*
1313
- modules/**/*
14+
15+
Style/SymbolProc:
16+
Enabled: false
17+
18+
Naming/FileName:
19+
Enabled: false
20+
21+
Layout/LineLength:
22+
Max: 150
23+
24+
Style/FetchEnvVar:
25+
Enabled: false

Gemfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
44

5+
def location_for(place, fake_version = nil)
6+
if place.is_a?(String) && place =~ /^((?:git[:@]|https:)[^#]*)#(.*)/
7+
[fake_version, { git: Regexp.last_match(1), branch: Regexp.last_match(2), require: false }].compact
8+
elsif place.is_a?(String) && place =~ %r{^file://(.*)}
9+
['>= 0', { path: File.expand_path(Regexp.last_match(1)), require: false }]
10+
else
11+
[place, { require: false }]
12+
end
13+
end
14+
515
# Disable analytics when running in development
616
ENV['BOLT_DISABLE_ANALYTICS'] = 'true'
717

@@ -26,7 +36,10 @@ group(:release, optional: true) do
2636
end
2737

2838
group(:packaging) do
39+
gem 'json'
2940
gem 'packaging', '~> 0.105'
41+
gem 'rake'
42+
gem 'vanagon', *location_for(ENV['VANAGON_LOCATION'] || 'https://github.com/openvoxproject/vanagon#main')
3043
end
3144

3245
local_gemfile = File.join(__dir__, 'Gemfile.local')

Rakefile

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
# frozen_string_literal: true
22

3-
# rubocop:disable Lint/SuppressedException
4-
begin
5-
# Needed for Vanagon component ship job. Jenkins automatically sets 'BUILD_ID'.
6-
# Packaging tasks should not be loaded unless running in Jenkins.
7-
if ENV['BUILD_ID']
8-
require 'packaging'
9-
Pkg::Util::RakeUtils.load_packaging_tasks
3+
require 'open3'
4+
require 'rake'
5+
6+
RED = "\033[31m"
7+
GREEN = "\033[32m"
8+
RESET = "\033[0m"
9+
10+
def run_command(cmd, silent: true, print_command: false, report_status: false)
11+
puts "#{GREEN}Running #{cmd}#{RESET}" if print_command
12+
output = ''
13+
Open3.popen2e(cmd) do |_stdin, stdout_stderr, thread|
14+
stdout_stderr.each do |line|
15+
puts line unless silent
16+
output += line
17+
end
18+
exitcode = thread.value.exitstatus
19+
unless exitcode.zero?
20+
err = "#{RED}Command failed! Command: #{cmd}, Exit code: #{exitcode}"
21+
# Print details if we were running silent
22+
err += "\nOutput:\n#{output}" if silent
23+
err += RESET
24+
abort err
25+
end
26+
puts "#{GREEN}Command finished with status #{exitcode}#{RESET}" if report_status
1027
end
11-
rescue LoadError
28+
output.chomp
1229
end
13-
# rubocop:enable Lint/SuppressedException
1430

1531
begin
1632
require 'github_changelog_generator/task'

acceptance/setup/git/pre-suite/020_install.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module Bolt
3737
end
3838

3939
step "Build gem" do
40-
build_command = "cd bolt; gem build bolt.gemspec"
40+
build_command = "cd bolt; gem build openbolt.gemspec"
4141
case bolt['platform']
4242
when /windows/
4343
execute_powershell_script_on(bolt, build_command)

bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@
55
# Makes a query to [puppetdb](https://puppet.com/docs/puppetdb/latest/index.html)
66
# using Bolt's PuppetDB client.
77
Puppet::Functions.create_function(:puppetdb_query) do
8-
# rubocop:disable Layout/LineLength
98
# Make a query to PuppetDB.
109
#
1110
# @param query A PQL query.
1211
# Learn more about [Puppet's query language](https://puppet.com/docs/puppetdb/latest/api/query/tutorial-pql.html), PQL.
1312
# @return Results of the PuppetDB query.
1413
# @example Request certnames for all nodes
1514
# puppetdb_query('nodes[certname] {}')
16-
# rubocop:enable Layout/LineLength
1715
dispatch :make_query do
1816
param 'Variant[String, Array[Data]]', :query
1917
return_type 'Array[Data]'
2018
end
2119

22-
# rubocop:disable Layout/LineLength
2320
# Make a query to a named PuppetDB instance.
2421
#
2522
# @param query A PQL query.
@@ -28,7 +25,6 @@
2825
# @return Results of the PuppetDB query.
2926
# @example Request certnames for all nodes using a named PuppetDB instance
3027
# puppetdb_query('nodes[certname] {}', 'instance-1')
31-
# rubocop:enable Layout/LineLength
3228
dispatch :make_query_with_instance do
3329
param 'Variant[String, Array[Data]]', :query
3430
param 'String', :instance

lib/bolt/apply_result.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ def self.invalid_report_error(result)
5252
missing_keys = expected_report_keys.reject { |k| result.value.include?(k) }
5353

5454
unless missing_keys.empty?
55-
if result['_output']
56-
# rubocop:disable Layout/LineLength
57-
msg = "Report result contains an '_output' key. Catalog application might have printed extraneous output to stdout: #{result['_output']}"
58-
# rubocop:enable Layout/LineLength
59-
else
60-
msg = "Report did not contain all expected keys missing: #{missing_keys.join(', ')}"
61-
end
55+
msg = if result['_output']
56+
"Report result contains an '_output' key. Catalog application might have printed extraneous output to stdout: #{result['_output']}"
57+
else
58+
"Report did not contain all expected keys missing: #{missing_keys.join(', ')}"
59+
end
6260

6361
{ 'msg' => msg,
6462
'kind' => 'bolt/invalid-report' }

0 commit comments

Comments
 (0)