Skip to content

Commit f42bf16

Browse files
(MODULES-11260) Replace daily with dispatchable GHA workflow
1 parent 57d655d commit f42bf16

File tree

2 files changed

+139
-69
lines changed

2 files changed

+139
-69
lines changed

.github/workflows/daily_unit_tests_with_nightly_puppet_gem.yaml

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
name: '[Dispatched] Unit Tests with nightly Puppet gem'
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
pa_ref:
8+
description: 'Puppet Agent SHA to use in this run'
9+
required: true
10+
11+
jobs:
12+
set_output_data:
13+
name: 'Prepare input and output data'
14+
runs-on: 'ubuntu-latest'
15+
outputs:
16+
puppet_sha: ${{ steps.setup_world.outputs.puppet_sha }}
17+
ruby_version: ${{ steps.setup_world.outputs.ruby_version }}
18+
puppet_version: ${{ steps.setup_world.outputs.puppet_version }}
19+
puppet_short_commit: ${{ steps.setup_world.outputs.puppet_short_commit }}
20+
21+
steps:
22+
- name: Gather and set data
23+
id: setup_world
24+
run: |
25+
pa_ref=${{ github.event.inputs.pa_ref }}
26+
res=$(curl -s https://raw.githubusercontent.com/puppetlabs/puppet-agent/${pa_ref}/configs/components/puppet.json)
27+
puppet_remote=$(echo $res | cut -d '"' -f 4)
28+
puppet_sha=$(echo $res | cut -d '"' -f 8)
29+
mkdir puppet
30+
pushd puppet
31+
git init
32+
git remote add origin ${puppet_remote}
33+
git fetch
34+
puppet_short_commit=$(git describe ${puppet_sha} | sed -r 's/-/./g' | rev | cut -c 4- | rev)
35+
puppet_version=${puppet_short_commit:0:1}
36+
popd
37+
rm -rf puppet
38+
39+
case $puppet_version in
40+
6)
41+
ruby_version='2.5'
42+
;;
43+
7)
44+
ruby_version='2.7'
45+
;;
46+
esac
47+
echo "::set-output name=puppet_sha::$puppet_sha"
48+
echo "::set-output name=ruby_version::$ruby_version"
49+
echo "::set-output name=puppet_version::$puppet_version"
50+
echo "::set-output name=puppet_short_commit::$puppet_short_commit"
51+
- name: "Puppet Agent SHA: ${{ github.event.inputs.pa_ref }}"
52+
run: "echo ${{ github.event.inputs.pa_ref }}"
53+
54+
- name: "Puppet SHA: ${{ steps.setup_world.outputs.puppet_sha }}"
55+
run: "echo ${{ steps.setup_world.outputs.puppet_sha }}"
56+
57+
- name: "Puppet Short Commit: ${{ steps.setup_world.outputs.puppet_short_commit }}"
58+
run: "echo ${{ steps.setup_world.outputs.puppet_short_commit }}"
59+
60+
- name: "Puppet Version: ${{ steps.setup_world.outputs.puppet_version }}"
61+
run: "echo ${{ steps.setup_world.outputs.puppet_version }}"
62+
63+
- name: "Ruby Version: ${{ steps.setup_world.outputs.ruby_version }}"
64+
run: "echo ${{ steps.setup_world.outputs.ruby_version }}"
65+
66+
unit_tests_with_nightly_puppet_gem:
67+
name: ${{ matrix.os_type }} / Puppet${{ needs.set_output_data.outputs.puppet_version }} gem / Ruby${{ needs.set_output_data.outputs.ruby_version }}
68+
needs: set_output_data
69+
env:
70+
puppet_version: ${{ needs.set_output_data.outputs.puppet_version }}
71+
ruby_version: ${{ needs.set_output_data.outputs.ruby_version }}
72+
73+
strategy:
74+
matrix:
75+
os: [ 'ubuntu-18.04', 'macos-10.15', 'windows-2019' ]
76+
include:
77+
- os: 'ubuntu-18.04'
78+
os_type: 'Linux'
79+
env_set_cmd: 'export '
80+
gem_file_postfix: '.gem'
81+
- os: 'macos-10.15'
82+
os_type: 'macOS'
83+
env_set_cmd: 'export '
84+
gem_file_postfix: '-universal-darwin.gem'
85+
- os: 'windows-2019'
86+
os_type: 'Windows'
87+
env_set_cmd: '$env:'
88+
gem_file_postfix: '-x64-mingw32.gem'
89+
90+
runs-on: ${{ matrix.os }}
91+
steps:
92+
- name: Checkout code
93+
uses: actions/checkout@v2
94+
95+
- name: Install ruby version ${{ env.ruby_version }}
96+
uses: ruby/setup-ruby@v1
97+
with:
98+
ruby-version: ${{ env.ruby_version }}
99+
100+
- name: Install the given nightly puppet${{ env.puppet_version }} gem
101+
run: |
102+
sleep_time=0
103+
until [ $sleep_time -ge 15 ]
104+
do
105+
curl --location http://nightlies.puppet.com/downloads/gems/puppet${{ env.puppet_version }}-nightly/puppet-${{ needs.set_output_data.outputs.puppet_short_commit }}${{ matrix.gem_file_postfix }} --output puppet.gem
106+
gem install puppet.gem -N && break
107+
sleep_time=$((sleep_time*2+1))
108+
echo "Retrying download and install of gem in $sleep_time seconds..."
109+
sleep $sleep_time
110+
done
111+
shell: bash
112+
113+
- name: Prepare testing environment with bundler
114+
run: |
115+
git config --global core.longpaths true
116+
bundle config set system 'true'
117+
bundle config set --local without 'release'
118+
${{ matrix.env_set_cmd }}PUPPET_GEM_VERSION=${{ needs.set_output_data.outputs.puppet_short_commit }}
119+
bundle update --jobs 4 --retry 3
120+
- name: Run unit tests
121+
run: bundle exec rake parallel_spec
122+
123+
notify-via-slack:
124+
name: Notify workflow conclusion via Slack
125+
if: ${{ always() }}
126+
needs: [set_output_data, unit_tests_with_nightly_puppet_gem]
127+
runs-on: 'ubuntu-latest'
128+
steps:
129+
- uses: luchihoratiu/[email protected]
130+
with:
131+
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
132+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
133+
NOTIFY_ONLY_ON_CONCLUSION_CHANGE: 'true'
134+
EXTRA_INFORMATION: ':github_actions: Run number: ${{ github.run_id }} \n
135+
:puppet: Puppet Agent SHA: ${{ github.event.inputs.pa_ref }} \n
136+
:puppet: Puppet SHA: ${{ needs.set_output_data.outputs.puppet_sha }} \n
137+
:puppet: Puppet Short Commit: ${{ needs.set_output_data.outputs.puppet_short_commit }} \n
138+
:puppet: Puppet Version: ${{ needs.set_output_data.outputs.puppet_version }} \n
139+
:ruby: Ruby Version: ${{ needs.set_output_data.outputs.ruby_version }} \n'

0 commit comments

Comments
 (0)