Skip to content

Commit

Permalink
Merge pull request #206 from puppetlabs/CONT-723-Implement_reusable_w…
Browse files Browse the repository at this point in the history
…orkflows

(CONT-723) - Implement reusable workflows
  • Loading branch information
LukasAud authored Mar 13, 2023
2 parents d8c3c7e + 15e3eaf commit 93b5bf3
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 95 deletions.
48 changes: 12 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,21 @@ on:
pull_request:
branches:
- "main"
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
spec:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-latest"
ruby:
- 2.5
- 2.7

steps:
- name: "checkout"
uses: "actions/checkout@v3"

- name: "setup ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: "bundle environment"
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::
- name: "rubocop"
run: |
bundle exec rubocop
- name: "spec"
run: |
bundle exec rake spec
ruby_version:
- '2.5'
- '2.7'
name: "spec (ruby ${{ matrix.ruby_version }})"
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
secrets: "inherit"
with:
ruby_version: ${{ matrix.ruby_version }}

acceptance:
needs: "spec"
Expand All @@ -54,12 +30,12 @@ jobs:
- "windows-latest"
- "windows-2019"
puppet:
- 6
- 7
- '~> 6'
- '~> 7'
include:
- puppet: 6
- puppet: '~> 6'
ruby: 2.5
- puppet: 7
- puppet: '~> 7'
ruby: 2.7
env:
PUPPET_GEM_VERSION: ${{ matrix.puppet }}
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: "nightly"

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
spec:
strategy:
fail-fast: false
matrix:
ruby_version:
- '2.5'
- '2.7'
name: "spec (ruby ${{ matrix.ruby_version }})"
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main"
secrets: "inherit"
with:
ruby_version: ${{ matrix.ruby_version }}

acceptance:
needs: "spec"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- "windows-latest"
- "windows-2019"
puppet:
- 6
- 7
include:
- puppet: 6
ruby: 2.5
- puppet: 7
ruby: 2.7
env:
PUPPET_GEM_VERSION: ${{ matrix.puppet }}

steps:
- name: "checkout"
uses: "actions/checkout@v3"

- name: "setup ruby"
uses: "ruby/setup-ruby@v1"
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: "bundle environment"
run: |
echo ::group::bundler environment
bundle env
echo ::endgroup::
- name: "setup winrm"
shell: "powershell"
run: |
Get-ChildItem WSMan:\localhost\Listener\ -OutVariable Listeners | Format-List * -Force
$HTTPListener = $Listeners | Where-Object -FilterScript { $_.Keys.Contains('Transport=HTTP') }
If ($HTTPListener.Count -eq 0) {
winrm create winrm/config/Listener?Address=*+Transport=HTTP
winrm e winrm/config/listener
}
- name: "acceptance"
shell: "powershell"
run: |
bundle exec rake dsc:acceptance:spec_prep
bundle exec rake dsc:acceptance:spec
71 changes: 15 additions & 56 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,20 @@
name: "release"
name: "Release"

on:
workflow_dispatch:
inputs:
target:
description: "The target for the release. This can be a commit sha or a branch."
required: false
default: "main"

jobs:
release:
name: "release"
runs-on: "ubuntu-latest"
if: github.repository_owner == 'puppetlabs'

steps:

- name: "checkout"
uses: "actions/checkout@v3"
with:
ref: ${{ github.ref }}
clean: true
fetch-depth: 0

- name: "setup ruby"
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true

- name: "get version"
id: "get_version"
run: |
echo "::set-output name=version::$(jq --raw-output .version metadata.json)"
- name: "build gem"
run: |
bundle exec rake build
- name: "publish gem"
run: |
gem push ./pkg/*.gem
env:
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}

- name: "update module readme"
run: |
mv pwshlib.md README.md
- name: "build module"
uses: "docker://puppet/pdk:latest"
with:
args: 'build'

- name: "publish module"
uses: "docker://puppet/pdk:latest"
with:
args: 'release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force'

- name: "create release"
run: |
gh release create v${{ steps.get_version.outputs.version }} ./pkg/*.gem ./pkg/*.tar.gz --title v${{ steps.get_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

gem_release:
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release.yml@main"
with:
target: "${{ github.event.inputs.target }}"
secrets: "inherit"

module_release:
uses: "puppetlabs/cat-github-actions/.github/workflows/module_release.yml@main"
secrets: "inherit"
12 changes: 10 additions & 2 deletions .github/workflows/release_prep.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "release prep"
name: "Release Prep"

on:
workflow_dispatch:
Expand All @@ -7,10 +7,18 @@ on:
description: "The target for the release. This can be a commit sha or a branch."
required: false
default: "main"
version:
description: "Version of gem to be released."
required: true

jobs:
release_prep:
gem_release_prep:
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_release_prep.yml@main"
with:
target: "${{ github.event.inputs.target }}"
version: "${{ github.event.inputs.version }}"
secrets: "inherit"

module_release_prep:
uses: "puppetlabs/cat-github-actions/.github/workflows/module_release_prep.yml@main"
secrets: "inherit"
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end
group :puppet do
gem 'pdk', '~> 1.0'
if ENV['PUPPET_GEM_VERSION']
gem 'puppet', "~> #{ENV['PUPPET_GEM_VERSION']}"
gem 'puppet', ENV['PUPPET_GEM_VERSION']
else
gem 'puppet'
end
Expand Down

0 comments on commit 93b5bf3

Please sign in to comment.