puppetlabs/puppetlabs-peadm

Add a Github Action to run validation and unit testing on PRs

timidri opened this issue · 0 comments

Example workflow:

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  spec:
    name: "Spec Tests"
    runs-on: ubuntu-20.04
    strategy:
      fail-fast: false
      matrix:
        include:
          - puppet_ver: '~> 6'
            ruby_ver: 2.5
          - puppet_ver: '~> 7'
            ruby_ver: 2.7
    steps:
      - name: Checkout Source
        uses: actions/checkout@v2

      - name: Activate Ruby ${{ matrix.ruby_ver }}
        uses: ruby/setup-ruby@v1
        env:
          PUPPET_GEM_VERSION: ${{ matrix.puppet_ver }}
        with:
          ruby-version: ${{ matrix.ruby_ver }}
          bundler-cache: true

      - name: Print Bundler Environment
        env:
          PUPPET_GEM_VERSION: ${{ matrix.puppet_ver }}
        run: |
          bundle env

      - name: Code Validation
        env:
          PUPPET_GEM_VERSION: ${{ matrix.puppet_ver }}
        run: |
          bundle exec rake check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint

      - name: Parallel Spec Tests
        env:
          PUPPET_GEM_VERSION: ${{ matrix.puppet_ver }}
        run: |
          bundle exec rake parallel_spec