Skip to content

Commit 49d0c59

Browse files
Merge pull request #55 from luchihoratiu/main
(MODULES-11073) Gather and set output data in GHA workflow
2 parents 76f9617 + c2a4f7c commit 49d0c59

File tree

2 files changed

+129
-68
lines changed

2 files changed

+129
-68
lines changed

.github/workflows/daily_unit_tests_with_nightly_puppet_gem.yaml

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

0 commit comments

Comments
 (0)