Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow fixes and improvements #88

Merged
merged 13 commits into from
May 16, 2024
Merged
3 changes: 2 additions & 1 deletion .github/workflows/gem_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ jobs:
if: |
contains(inputs.rake_task, 'coverage') &&
inputs.runs_on == 'ubuntu-latest' &&
inputs.ruby_version == '3.2'
inputs.ruby_version == '3.2' &&
secrets.CODECOV_TOKEN
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/labeller.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: Labeller

on:
issues:
types:
- opened
- labeled
- unlabeled
pull_request_target:
types:
- opened
- labeled
- unlabeled
workflow_call:
inputs:
token:
default: ''
type: string

jobs:
label:
name: ${{ github.event.action }} ${{ github.event_name }}
# case if the workflow is called improperly
if: |
contains(fromJson('["puppetlabs", "puppet-toy-chest"]'), github.repository_owner) &&
contains(fromJson('["pull_request_target", "issues"]'), github.event_name) &&
contains(fromJson('["opened", "reopened", "labeled", "unlabeled"]'), github.event.action)
runs-on: ubuntu-latest
steps:

- uses: puppetlabs/[email protected]
name: Label issues or pull requests
with:
label_name: community
label_color: '5319e7'
org_membership: puppetlabs
fail_if_member: 'true'
token: ${{ secrets.IAC_COMMUNITY_LABELER }}
token: ${{ inputs.token != '' && inputs.token || secrets.IAC_COMMUNITY_TOKEN }}
44 changes: 39 additions & 5 deletions .github/workflows/mend_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,42 @@ name: mend

on:
workflow_call:
inputs:
api_key:
default: ''
type: string
token:
default: ''
type: string
product_name:
default: 'content-and-tooling'
type: string

jobs:
env:
MEND_API_KEY: ${{ secrets.MEND_API_KEY != '' && secrets.MEND_API_KEY || inputs.api_key }}
MEND_TOKEN: ${{ secrets.MEND_TOKEN != '' && secrets.MEND_TOKEN || inputs.token }}
PRODUCT_NAME: ${{ inputs.PRODUCT_NAME != '' && inputs.PRODUCT_NAME || inputs.product_name }}
REQUIRE_SECRETS: MEND_API_KEY MEND_TOKEN

jobs:
mend:
runs-on: "ubuntu-latest"
continue-on-error: ${{ contains(fromJson('["puppetlabs","puppet-toy-chest"]'), github.repository_owner) != true }}
steps:
- name: "check requirements"
run: |
declare -a MISSING
for V in ${REQUIRE_SECRETS} ; do
[[ -z "${!V}" ]] && MISSING+=($V)
done
if [ ${#MISSING[@]} -gt 0 ] ; then
echo "::warning::missing required secrets: ${MISSING[@]}"
exit 1
fi

# If we are on a PR, checkout the PR head sha, else checkout the default branch
- name: "Set the checkout ref"
if: success()
id: set_ref
run: |
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
Expand All @@ -21,32 +49,38 @@ jobs:
fi

- name: "checkout"
if: success()
uses: "actions/checkout@v4"
with:
fetch-depth: 1
ref: ${{ steps.set_ref.outputs.ref }}

- name: "setup ruby"
if: success()
uses: "ruby/setup-ruby@v1"
with:
ruby-version: 2.7

- name: "bundle lock"
if: success()
run: bundle lock

- uses: "actions/setup-java@v4"
if: success()
with:
distribution: "temurin"
java-version: "17"

- name: "download"
if: success()
run: curl -o wss-unified-agent.jar https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar

- name: "scan"
if: success()
run: java -jar wss-unified-agent.jar
env:
WS_APIKEY: ${{ secrets.MEND_API_KEY }}
WS_APIKEY: ${{ env.MEND_API_KEY }}
WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent
WS_USERKEY: ${{ secrets.MEND_TOKEN }}
WS_PRODUCTNAME: "content-and-tooling"
WS_PROJECTNAME: ${{ github.event.repository.name }}
WS_USERKEY: ${{ env.MEND_TOKEN }}
WS_PRODUCTNAME: ${{ env.PRODUCT_NAME }}
WS_PROJECTNAME: ${{ github.event.repository.name }}
21 changes: 19 additions & 2 deletions .github/workflows/module_acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ on:
required: false
default: ''
type: "string"

kernel_modules:
description: "Volume map host kernel /lib/modules into docker container"
default: true
type: boolean
disable_apparmor:
description: "Disable and stop apparmor"
default: false
type: boolean

jobs:

Expand Down Expand Up @@ -68,6 +75,16 @@ jobs:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Disable Apparmor"
if: ${{ inputs.disable_apparmor }}
run: |
if command -v apparmor_parser >/dev/null ; then
sudo find /etc/apparmor.d/ -maxdepth 1 -type f -exec ln -sf {} /etc/apparmor.d/disable/ \;
sudo apparmor_parser -R /etc/apparmor.d/disable/* || true
sudo systemctl disable apparmor
sudo systemctl stop apparmor
fi

- name: "Setup ruby"
uses: "ruby/setup-ruby@v1"
with:
Expand All @@ -82,7 +99,7 @@ jobs:

- name: "Provision environment"
run: |
if [[ "${{matrix.platforms.provider}}" == "docker" ]]; then
if [[ "${{ inputs.kernel_modules }}" == "true" ]] && [[ "${{matrix.platforms.provider}}" =~ docker* ]] ; then
DOCKER_RUN_OPTS="docker_run_opts: {'--volume': '/lib/modules/$(uname -r):/lib/modules/$(uname -r)'}"
else
DOCKER_RUN_OPTS=''
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/module_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ jobs:
release:
name: "Release"
runs-on: "ubuntu-latest"
if: github.repository_owner == 'puppetlabs'

steps:
- name: "Check Requirements"
run: |
if [[ -z "${{ secrets.FORGE_API_KEY }}" ]] ; then
echo "::error::missing required secret: FORGE_API_KEY"
exit 1
fi

- name: "Checkout"
uses: "actions/checkout@v4"
Expand Down
44 changes: 39 additions & 5 deletions .github/workflows/tooling_mend_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,42 @@ name: mend

on:
workflow_call:
inputs:
api_key:
default: ''
type: string
token:
default: ''
type: string
product_name:
default: 'DevX'
type: string

jobs:
env:
MEND_API_KEY: ${{ secrets.MEND_API_KEY != '' && secrets.MEND_API_KEY || inputs.api_key }}
MEND_TOKEN: ${{ secrets.MEND_TOKEN != '' && secrets.MEND_TOKEN || inputs.token }}
PRODUCT_NAME: ${{ inputs.PRODUCT_NAME != '' && inputs.PRODUCT_NAME || inputs.product_name }}
REQUIRE_SECRETS: MEND_API_KEY MEND_TOKEN

jobs:
mend:
runs-on: "ubuntu-latest"
continue-on-error: ${{ contains(fromJson('["puppetlabs","puppet-toy-chest"]'), github.repository_owner) != true }}
steps:
- name: "check requirements"
run: |
declare -a MISSING
for V in ${REQUIRE_SECRETS} ; do
[[ -z "${!V}" ]] && MISSING+=($V)
done
if [ ${#MISSING[@]} -gt 0 ] ; then
echo "::warning::missing required secrets: ${MISSING[@]}"
exit 1
fi

# If we are on a PR, checkout the PR head sha, else checkout the default branch
- name: "Set the checkout ref"
if: success()
id: set_ref
run: |
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
Expand All @@ -21,32 +49,38 @@ jobs:
fi

- name: "checkout"
if: success()
uses: "actions/checkout@v4"
with:
fetch-depth: 1
ref: ${{ steps.set_ref.outputs.ref }}

- name: "setup ruby"
if: success()
uses: "ruby/setup-ruby@v1"
with:
ruby-version: 2.7

- name: "bundle lock"
if: success()
run: bundle lock

- uses: "actions/setup-java@v4"
if: success()
with:
distribution: "temurin"
java-version: "17"

- name: "download"
if: success()
run: curl -o wss-unified-agent.jar https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar

- name: "scan"
if: success()
run: java -jar wss-unified-agent.jar
env:
WS_APIKEY: ${{ secrets.MEND_API_KEY }}
WS_APIKEY: ${{ env.MEND_API_KEY }}
WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent
WS_USERKEY: ${{ secrets.MEND_TOKEN }}
WS_PRODUCTNAME: "DevX"
WS_PROJECTNAME: ${{ github.event.repository.name }}
WS_USERKEY: ${{ env.MEND_TOKEN }}
WS_PRODUCTNAME: ${{ env.PRODUCT_NAME }}
WS_PROJECTNAME: ${{ github.event.repository.name }}