build #855
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
workflow_dispatch: | |
push: | |
branches: ['*'] | |
tags: | |
- v* | |
pull_request: | |
type: [opened, reopened, edited] | |
schedule: | |
# run every night at midnight | |
- cron: '0 0 * * *' | |
jobs: | |
unit: | |
name: 'unit - ${{matrix.name}} - puppet (${{matrix.puppet}})' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# note: actions/setup-ruby only allows using a major.minor release of ruby | |
- ruby: '2.7' | |
puppet: "7.0" | |
check: "check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" | |
name: 'static' | |
- ruby: '2.5' | |
puppet: "6.0" | |
check: "parallel_spec" | |
name: 'spec' | |
- ruby: '2.7' | |
puppet: "7.0" | |
check: "parallel_spec" | |
name: 'spec' | |
- ruby: '2.7' | |
puppet: "7.0" | |
check: 'strings:generate[,,,,,,"--fail-on-warning"]' | |
name: "documentation" | |
env: | |
CHECK: '${{ matrix.check }}' | |
PUPPET_GEM_VERSION: '~> ${{ matrix.puppet }}' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Ruby | |
uses: actions/setup-ruby@v1 | |
with: | |
ruby-version: '${{ matrix.ruby }}' | |
- name: Bundle prep | |
run: | | |
gem install bundler | |
bundle -v | |
rm -f Gemfile.lock | |
# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" | |
# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" | |
# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" | |
[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION | |
gem --version | |
bundle -v | |
bundle config path vendor/bundle | |
bundle config without 'system_tests' | |
bundle lock | |
# restore cache AFTER doing 'bundle lock' so that Gemfile.lock exists | |
- uses: actions/cache@v2 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-unit-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-unit- | |
- name: Bundle install | |
run: | | |
bundle install --jobs $(nproc) --retry 3 | |
- name: Test | |
run: | | |
bundle exec rake $CHECK | |
unit-python: | |
name: 'unit - ${{matrix.name}} - python (${{matrix.python}})' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# note: actions/setup-python only allows using a major.minor releases | |
- python: '3.8' | |
make_target: 'python3' | |
name: 'bolt tasks' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: '${{ matrix.python }}' | |
- uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-${{ matrix.python }}-pip-unit-${{ hashFiles('**/requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.python }}-pip-unit- | |
- name: Python prep | |
run: | | |
pip install virtualenv | |
- name: Test | |
run: | | |
make ${{ matrix.make_target }} | |
integration: | |
name: 'integration - ${{matrix.name}}' | |
needs: | |
- unit | |
- unit-python | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# note: actions/setup-ruby only allows using a major.minor release of ruby | |
- ruby: '2.7' | |
name: 'centos7-puppet6' | |
- ruby: '2.7' | |
name: 'centos7-puppet7' | |
- ruby: '2.7' | |
name: 'rocky8-puppet6' | |
- ruby: '2.7' | |
name: 'rocky8-puppet7' | |
- ruby: '2.7' | |
name: 'ubuntu18-puppet6' | |
- ruby: '2.7' | |
name: 'ubuntu18-puppet7' | |
- ruby: '2.7' | |
name: 'ubuntu20-puppet6' | |
- ruby: '2.7' | |
name: 'ubuntu20-puppet7' | |
env: | |
CHECK: '${{ matrix.check }}' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Ruby | |
uses: actions/setup-ruby@v1 | |
with: | |
ruby-version: '${{ matrix.ruby }}' | |
- name: Bundle prep | |
run: | | |
gem install bundler | |
bundle -v | |
rm -f Gemfile.lock | |
# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" | |
# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" | |
# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" | |
[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION | |
gem --version | |
bundle -v | |
# note: this path is relative to the Gemfile path below | |
bundle config path vendor/bundle | |
bundle config without 'system_tests' | |
# note: using custom gemfile for kitchen tests | |
bundle config gemfile build/kitchen/Gemfile | |
bundle lock | |
# restore cache AFTER doing 'bundle lock' so that Gemfile.lock exists | |
- uses: actions/cache@v2 | |
with: | |
# note: this path is the Gemfile + path from above, so it's different than the base level Gemfile cache | |
path: build/kitchen/vendor/bundle | |
key: ${{ runner.os }}-${{ matrix.name }}-${{ matrix.ruby }}-gems-integration-v3-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.name }}-${{ matrix.ruby }}-gems-integration-v3- | |
- name: Bundle install | |
run: | | |
bundle install --jobs $(nproc) --retry 3 | |
- name: Test | |
run: | | |
bundle exec kitchen test --debug ${{ matrix.name }} | |
deploy: | |
name: 'deploy - forge' | |
needs: | |
- unit | |
- unit-python | |
- integration | |
runs-on: ubuntu-latest | |
# only run deploy on tags that start with 'v' | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
# define a "strategy" here so we can use ruby/puppet as variables below | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# note: actions/setup-ruby only allows using a major.minor release of ruby | |
- ruby: '2.5' | |
puppet: "6.0" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Ruby | |
uses: actions/setup-ruby@v1 | |
with: | |
ruby-version: '${{ matrix.ruby }}' | |
- name: Bundle prep | |
run: | | |
gem install bundler | |
bundle -v | |
rm -f Gemfile.lock | |
# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" | |
# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" | |
# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" | |
[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION | |
gem --version | |
bundle -v | |
bundle config path vendor/bundle | |
bundle config without 'system_tests' | |
bundle lock | |
# restore cache AFTER doing 'bundle lock' so that Gemfile.lock exists | |
- uses: actions/cache@v2 | |
with: | |
# note: we are using the gems-unit cache here since it's the same and can take | |
# advantage for the cache we already have from the previous 'unit' job | |
path: vendor/bundle | |
key: ${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-unit-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-unit- | |
- name: Bundle install | |
run: | | |
bundle install --jobs $(nproc) --retry 3 | |
- name: Build and Deploy | |
env: | |
# configure secrets here: | |
# https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets | |
BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}' | |
BLACKSMITH_FORGE_PASSWORD: '${{ secrets.PUPPET_FORGE_PASSWORD }}' | |
# use puppet-blacksmith rake tasks to build and deploy the module | |
run: | | |
bundle exec rake module:build | |
bundle exec rake module:push | |
slack-notification: | |
name: Slack notification for failed master builds | |
if: always() | |
needs: | |
- unit | |
- unit-python | |
- integration | |
runs-on: ubuntu-latest | |
steps: | |
- name: Workflow conclusion | |
# this step creates an environment variable WORKFLOW_CONCLUSION and is the most reliable way to check the status of previous jobs | |
uses: technote-space/workflow-conclusion-action@v2 | |
- name: CI Run Failure Slack Notification | |
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' && github.ref == 'refs/heads/master' }} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
uses: voxmedia/github-action-slack-notify-build@v1 | |
with: | |
channel: puppet | |
status: FAILED | |
color: danger |