Skip to content

Commit 3e1cdaf

Browse files
committed
feat(workflow): add GitHub Actions workflow for converting compilers to legacy
- Trigger on pull requests affecting specific paths and on manual dispatch - Provision and set up a test cluster using Bolt and Rake - Install Puppet Enterprise on the test cluster - Convert one compiler to legacy and verify the conversion - Tear down the test cluster after the workflow completes
1 parent 39d5f7d commit 3e1cdaf

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
name: Convert compiler to legacy
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/**/*
7+
- spec/**/*
8+
- lib/**/*
9+
- tasks/**/*
10+
- functions/**/*
11+
- types/**/*
12+
- plans/**/*
13+
- hiera/**/*
14+
- manifests/**/*
15+
- templates/**/*
16+
- files/**/*
17+
- metadata.json
18+
- Rakefile
19+
- Gemfile
20+
- provision.yaml
21+
- .rspec
22+
- .rubocop.yml
23+
- .puppet-lint.rc
24+
- .fixtures.yml
25+
branches: [main]
26+
push:
27+
workflow_dispatch:
28+
inputs:
29+
ssh-debugging:
30+
description: Boolean; whether or not to pause for ssh debugging
31+
required: true
32+
default: 'false'
33+
jobs:
34+
convert_compiler:
35+
name: Convert compilers to legacy
36+
runs-on: ubuntu-20.04
37+
env:
38+
BOLT_GEM: true
39+
BOLT_DISABLE_ANALYTICS: true
40+
LANG: en_US.UTF-8
41+
steps:
42+
- name: Start SSH session
43+
if: ${{ github.event.inputs.ssh-debugging == 'true' }}
44+
uses: luchihoratiu/debug-via-ssh@main
45+
with:
46+
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
47+
SSH_PASS: ${{ secrets.SSH_PASS }}
48+
- name: Checkout Source
49+
uses: actions/checkout@v2
50+
- name: Activate Ruby 2.7
51+
uses: ruby/setup-ruby@v1
52+
with:
53+
ruby-version: '2.7'
54+
bundler-cache: true
55+
- name: Print bundle environment
56+
if: ${{ github.repository_owner == 'puppetlabs' }}
57+
run: |
58+
echo ::group::info:bundler
59+
bundle env
60+
echo ::endgroup::
61+
- name: Provision test cluster
62+
timeout-minutes: 15
63+
run: |
64+
echo ::group::prepare
65+
mkdir -p $HOME/.ssh
66+
echo 'Host *' > $HOME/.ssh/config
67+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
68+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
69+
bundle exec rake spec_prep
70+
echo ::endgroup::
71+
echo ::group::provision
72+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
73+
--modulepath spec/fixtures/modules \
74+
provider=provision_service \
75+
image=almalinux-cloud/almalinux-8 \
76+
architecture=large-with-dr
77+
echo ::endgroup::
78+
echo ::group::certnames
79+
bundle exec bolt plan run peadm_spec::add_inventory_hostnames \
80+
--inventory spec/fixtures/litmus_inventory.yaml \
81+
--modulepath spec/fixtures/modules \
82+
--no-host-key-check \
83+
inventory_file=spec/fixtures/litmus_inventory.yaml
84+
echo ::endgroup::
85+
echo ::group::info:request
86+
cat request.json || true; echo
87+
echo ::endgroup::
88+
echo ::group::info:inventory
89+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
90+
echo ::endgroup::
91+
- name: Set up yq
92+
uses: frenck/action-setup-yq@v1
93+
with:
94+
version: v4.30.5
95+
- name: Install PE on test cluster
96+
timeout-minutes: 120
97+
run: |
98+
bundle exec bolt plan run peadm_spec::install_test_cluster \
99+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
100+
--modulepath spec/fixtures/modules \
101+
architecture=large-with-dr \
102+
console_password=${{ secrets.CONSOLE_PASSWORD }} \
103+
version=2023.7.0
104+
- name: Wait as long as the file ${HOME}/pause file is present
105+
if: ${{ always() && github.event.inputs.ssh-debugging == 'true' }}
106+
run: |
107+
while [ -f "${HOME}/pause" ] ; do
108+
echo "${HOME}/pause present, sleeping for 60 seconds..."
109+
sleep 60
110+
done
111+
echo "${HOME}/pause absent, continuing workflow."
112+
- name: Convert one compiler to legacy
113+
timeout-minutes: 120
114+
run: |
115+
primary=$(yq '.groups[].targets[] | select(.vars.role == "primary") | .name' spec/fixtures/litmus_inventory.yaml)
116+
compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | head -n 1)
117+
echo ::group::convert_compiler_to_legacy
118+
bundle exec bolt plan run peadm::convert_compiler_to_legacy \
119+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
120+
--modulepath spec/fixtures/modules \
121+
--no-host-key-check \
122+
primary_host=$primary \
123+
legacy_hosts=$compiler
124+
echo ::endgroup::
125+
- name: Check if compiler is converted
126+
timeout-minutes: 120
127+
run: |
128+
echo ::group::inventory
129+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
130+
echo ::endgroup::
131+
echo ::group::get_peadm_config
132+
primary=$(yq '.groups[].targets[] | select(.vars.role == "primary") | .name' spec/fixtures/litmus_inventory.yaml)
133+
compiler=$(yq '.groups[].targets[] | select(.vars.role == "compiler") | .name' spec/fixtures/litmus_inventory.yaml | head -n 1)
134+
bundle exec bolt task run peadm::get_peadm_config \
135+
--targets $primary \
136+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
137+
--modulepath spec/fixtures/modules \
138+
--no-host-key-check \
139+
--format json > peadm_config.json
140+
cat peadm_config.json
141+
echo ::endgroup::
142+
echo ::group::smoke_test
143+
legacy_compiler=$(yq '.items[0].value.params.legacy_compilers[0]' peadm_config.json)
144+
if [ "$compiler" != "$legacy_compiler" ]
145+
then
146+
echo "Compiler conversion failed, expected $compiler, got $legacy_compiler"
147+
exit 1
148+
fi
149+
echo ::endgroup::
150+
- name: Tear down test cluster
151+
if: ${{ always() }}
152+
continue-on-error: true
153+
run: |-
154+
if [ -f spec/fixtures/litmus_inventory.yaml ]; then
155+
echo ::group::tear_down
156+
bundle exec rake 'litmus:tear_down'
157+
echo ::endgroup::
158+
echo ::group::info:request
159+
cat request.json || true; echo
160+
echo ::endgroup::
161+
fi

0 commit comments

Comments
 (0)