This repository contains reusable workflows to reduce duplication in actions in the Foreman project.
At this moment it's considered experimental.
To call Rubocop within your CI, use the following workflow:
name: CI
on: pull_request
concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
rubocop:
name: Rubocop
uses: theforeman/actions/.github/workflows/rubocop.yml@v0To run the Foreman tests once Rubocop has passed, use the following workflow:
name: CI
on:
pull_request:
push:
branches:
- 'develop'
- '*-stable'
concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
rubocop:
name: Rubocop
uses: theforeman/actions/.github/workflows/rubocop.yml@v0
test:
name: Ruby
needs: rubocop
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: MY_PLUGINBy default, this will run with the Ruby/NodeJS combination that is configured in Foreman's .github/matrix.json.
The Foreman version is specified using foreman_version, which defaults to develop.
To test out pull request number 1234, you can use:
jobs:
test:
name: Ruby
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: MY_PLUGIN
foreman_version: refs/pull/1234/headYou can adjust this matrix by setting the matrix_include and matrix_exclude inputs to the workflow:
name: CI
on:
pull_request:
push:
branches:
- 'develop'
- '*-stable'
jobs:
test:
name: Ruby
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: MY_PLUGIN
matrix_include: '[{"ruby": "3.0", "node": "20"}]'
matrix_exclude: '[{"ruby": "2.5", "node": "10"}, {"ruby": "2.5", "node": "12"}]'You can run tests against multiple Foreman versions by using a matrix:
name: CI
on:
pull_request:
push:
branches:
- 'develop'
- '*-stable'
concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
test:
name: Ruby
strategy:
fail-fast: false
matrix:
foreman:
- 3.9-stable
- develop
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: MY_PLUGIN
foreman_version: ${{ matrix.foreman }}If you need to set additional environment variables (e.g. to handle specific dependencies in your Gemfile), you can provide them via environment_variables:
name: CI
on:
pull_request:
push:
branches:
- 'develop'
- '*-stable'
concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
rubocop:
name: Rubocop
uses: theforeman/actions/.github/workflows/rubocop.yml@v0
test:
name: Ruby
needs: rubocop
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: MY_PLUGIN
environment_variables: |
CUSTOM_ENV_VARIABLE_ONE=FOO
CUSTOM_ENV_VARIABLE_TWO=BARTo run the Foreman plugin JavaScript/React tests, use the following workflow:
name: JavaScript
on:
pull_request:
push:
branches:
- 'develop'
- '*-stable'
concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
test:
name: JavaScript
uses: theforeman/actions/.github/workflows/foreman_plugin_js.yml@v0
with:
plugin: MY_PLUGINBy default, this will run with the NodeJS versions that is configured in Foreman's .github/matrix.json.
You can alter the behavior the same way as with the Ruby tests.
Similar to the Foreman plugin test, this is aimed at Smart Proxy plugins.
Conceptually it verifies certain Ruby versions are supported and using test-gem.yml to run the tests.
name: CI
on: pull_request
concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
test:
name: Tests
uses: theforeman/actions/.github/workflows/smart_proxy_plugin.yml@v0It's possible to provide foreman_proxy_version via a parameter, but your Gemfile needs to respect this:
gem 'smart_proxy', github: 'theforeman/smart-proxy', branch: ENV.fetch('SMART_PROXY_BRANCH', 'develop')When that's done it becomes possible to test pull requests. For example, testing pull request number 1234:
jobs:
test:
name: Tests
uses: theforeman/actions/.github/workflows/smart_proxy_plugin.yml@v0
with:
foreman_proxy_version: refs/pull/1234/headTo test a simple gem that only needs Ruby and bundler, use the following workflow:
name: CI
on: pull_request
concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
test:
name: Tests
uses: theforeman/actions/.github/workflows/test-gem.yml@v0By default it uses bundle exec rake spec but it's possible to override the command:
jobs:
test:
name: Tests
uses: theforeman/actions/.github/workflows/test-gem.yml@v0
with:
command: bundle exec rake testA workflow that, on adding a /label breaks-robottelo comment to a PR, adds a label breaks-robottelo to that PR.
name: Label a PR `breaks-robottelo` on appropriate comment
on:
issue_comment:
types: [created]
jobs:
breaks-robottelo:
uses: theforeman/actions/.github/workflows/breaks-robottelo.yml@v0
permissions:
pull-requests: write
with:
repo: ${{ github.repository }}
issue: ${{ github.event.issue.number }}
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}This action is deprecated in favour of using Trusted Publishing with voxpupuli/ruby-release.
To release a gem, use the following workflow
name: Release
on:
push:
# Pattern matched against refs/tags
tags:
- '**'
jobs:
release:
name: Release gem
uses: theforeman/actions/.github/workflows/release-gem.yml@v0
with:
allowed_owner: MY_USERNAME
secrets:
api_key: ${{ secrets.RUBYGEM_API_KEY }}