Skip to content

Commit aa289a8

Browse files
authored
Merge pull request #87 from danielparks/simplify-acceptance
Simplify acceptance tests in CI
2 parents c76cd05 + 63941c2 commit aa289a8

File tree

3 files changed

+46
-29
lines changed

3 files changed

+46
-29
lines changed

.github/workflows/pr-checks.yaml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
name: PR checks
22

33
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- $default-branch
84
pull_request:
5+
workflow_dispatch:
96

107
env:
118
# Enable rspec color output
@@ -17,7 +14,7 @@ jobs:
1714
runs-on: ubuntu-latest
1815

1916
steps:
20-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
2118
- name: Install PDK
2219
run: |
2320
set -ex
@@ -46,7 +43,7 @@ jobs:
4643
runs-on: ubuntu-latest
4744

4845
steps:
49-
- uses: actions/checkout@v3
46+
- uses: actions/checkout@v4
5047
- uses: ruby/setup-ruby@v1
5148
with:
5249
ruby-version: "2.7"
@@ -57,30 +54,40 @@ jobs:
5754
name: Acceptance tests
5855
strategy:
5956
matrix:
60-
os:
61-
- ubuntu-latest
62-
agent:
63-
- puppet7
64-
- puppet8
57+
include:
58+
- os: ubuntu-latest
59+
puppet: 6
60+
- os: ubuntu-latest
61+
puppet: 7
62+
- os: ubuntu-latest
63+
puppet: 8
6564
runs-on: ${{ matrix.os }}
6665

6766
steps:
68-
- uses: actions/checkout@v3
67+
- uses: actions/checkout@v4
6968
- name: Install Puppet
7069
run: |
7170
set -ex
72-
distro=$(lsb_release -cs)
73-
deb_name="${{ matrix.agent }}-release-${distro}.deb"
74-
curl -sSO "https://apt.puppet.com/${deb_name}"
75-
sudo dpkg -i "$deb_name"
76-
rm "$deb_name"
77-
sudo apt-get update -qq
78-
sudo apt-get install -qy puppet-agent pdk
79-
- name: Build module
80-
run: pdk build
81-
- name: Install module
82-
run: sudo -E /opt/puppetlabs/bin/puppet module install pkg/*.tar.gz
71+
case ${{ matrix.os }} in
72+
macos*)
73+
brew install --cask puppetlabs/puppet/puppet-agent-${{ matrix.puppet }}
74+
brew install --cask puppetlabs/puppet/pdk
75+
;;
76+
ubuntu*)
77+
distro=$(lsb_release -cs)
78+
deb_name="puppet${{ matrix.puppet }}-release-${distro}.deb"
79+
curl -sSO "https://apt.puppet.com/${deb_name}"
80+
sudo dpkg -i "$deb_name"
81+
rm "$deb_name"
82+
sudo apt-get update -qq
83+
sudo apt-get install -qy puppet-agent pdk
84+
;;
85+
*)
86+
echo ::error::Unsupported platform
87+
exit 1
88+
;;
89+
esac
8390
- name: Install PDK dependencies
84-
run: sudo -E pdk bundle install
91+
run: sudo -E /opt/puppetlabs/pdk/bin/pdk bundle install
8592
- name: Run acceptance tests
86-
run: sudo -E pdk bundle exec rake litmus:acceptance:localhost
93+
run: sudo -E /opt/puppetlabs/pdk/bin/pdk bundle exec rake litmus:acceptance:localhost

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@
8282
],
8383
"pdk-version": "3.0.1",
8484
"template-url": "https://github.com/danielparks/pdk-templates#main",
85-
"template-ref": "heads/main-0-g516808d"
85+
"template-ref": "heads/main-0-gde8efe4"
8686
}

spec/spec_helper_acceptance.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@
88

99
# For some reason litmusimage/ubuntu:22.04 doesn’t come with sudo.
1010
RSpec.configure do |config|
11-
config.before(:suite) do
12-
litmus = Class.new.extend(PuppetLitmus)
13-
litmus.apply_manifest("package { 'sudo': }", catch_failures: true)
11+
if RUBY_PLATFORM.include?('linux')
12+
config.before(:suite) do
13+
litmus = Class.new.extend(PuppetLitmus)
14+
litmus.apply_manifest("package { 'sudo': }", catch_failures: true)
15+
end
16+
end
17+
end
18+
19+
def home
20+
if RUBY_PLATFORM.include?('darwin')
21+
'/Users'
22+
else
23+
'/home'
1424
end
1525
end
1626

0 commit comments

Comments
 (0)