Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from kogitoapp/feature/add-pipelines
Browse files Browse the repository at this point in the history
Added pipelines for tests on PRs and releases on tags
  • Loading branch information
ZloeSabo authored Sep 8, 2021
2 parents 01d8f5c + 00a8685 commit f72d19c
Show file tree
Hide file tree
Showing 13 changed files with 625 additions and 69 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: CI

on: pull_request

jobs:
setup_matrix:
name: "Setup Test Matrix"
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.get-outputs.outputs.matrix }}
spec_matrix: ${{ steps.get-outputs.outputs.spec_matrix }}
env:
BUNDLE_WITHOUT: development:test:release
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
bundler-cache: true
- name: Run rake validate
run: bundle exec rake validate

- name: Setup Test Matrix
id: get-outputs
run: bundle exec matrix_from_metadata_v2

unit:
needs: setup_matrix
runs-on: ubuntu-20.04
if: ${{ needs.setup_matrix.outputs.spec_matrix != '{}' }}

strategy:
fail-fast: false
matrix: ${{fromJson(needs.setup_matrix.outputs.spec_matrix)}}

env:
PUPPET_GEM_VERSION: ${{ matrix.puppet_version }}
FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main'

name: "Spec: puppet ${{ matrix.puppet_version }} (ruby ${{ matrix.ruby_version }})"
steps:
- uses: actions/checkout@v2

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

- name: Print bundle environment
run: |
bundle env
- name: Run Static & Syntax Tests
run: |
bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop
- name: Run parallel_spec tests
run: |
bundle exec rake parallel_spec
acceptance:
needs: setup_matrix
runs-on: ubuntu-20.04
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}

strategy:
fail-fast: false
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}

name: "Acceptance: ${{matrix.platforms.label}}, ${{matrix.collection}}"
steps:
- uses: actions/checkout@v2

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

- name: Print bundle environment
run: |
bundle env
- name: Provision test environment
run: |
bundle exec rake 'litmus:provision[docker,${{ matrix.platforms.image }}]'
- name: Install agent
run: |
bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
- name: Install module
run: |
bundle exec rake 'litmus:install_module'
# - name: Display sysctl settings
# run: |
# bundle exec bolt command run 'sysctl -a' --targets localhost:2222 -i spec/fixtures/litmus_inventory.yaml

- name: Run acceptance tests
run: |
bundle exec rake 'litmus:acceptance:parallel'
- name: Remove test environment
if: ${{ always() }}
continue-on-error: true
run: |
if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then
bundle exec rake 'litmus:tear_down'
fi
29 changes: 29 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

on:
push:
tags:
- "*"

env:
BUNDLE_WITHOUT: development:test:system_tests

jobs:
deploy:
name: "deploy to forge"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
bundler-cache: true
- 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_API_KEY: "${{ secrets.PUPPET_FORGE_API_KEY }}"
run: bundle exec rake module:push
Loading

0 comments on commit f72d19c

Please sign in to comment.