Skip to content

Handle missing tests folder gracefully #226

Handle missing tests folder gracefully

Handle missing tests folder gracefully #226

name: push-validate_workflows
# Validates workflow files on push
# yamllint disable-line rule:truthy
on:
push:
branches-ignore:
- v0
jobs:
init:
runs-on: 'ubuntu-latest'
steps:
- name: 'Write Report Header'
if: always()
uses: OXID-eSales/github-actions/begin_report@v4
with:
prefix: 'validate'
title: 'Workflow validation on ${{ github.repository }} by ${{ github.actor }}'
repository: '${{ github.server_url }}/${{ github.repository }}'
job: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
testplan: ''
debug: false
- name: 'Write Report'
if: always()
uses: OXID-eSales/github-actions/append_report@v4
with:
prefix: 'validate'
header: true
phase: lint
priority: '001'
debug: false
yamllint:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Lint yaml files
id: yamllint
uses: oxid-esales/github-actions/yamllint@v4
with:
format: 'github'
config_data: |
extends: default
ignore: .git/*
rules:
document-start: disable
line-length:
max: 160
level: warning
new-line-at-end-of-file:
level: warning
trailing-spaces:
level: warning
- name: 'Write yamllint Report'
if: always()
uses: OXID-eSales/github-actions/append_report@v4
with:
prefix: 'validate'
priority: '010'
phase: lint
title: ''
job: 'yamllint'
php: ''
mysql: ''
testplan: ''
status: ${{job.status}}
debug: false
actionlint:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Run actionlint
id: actionlint
uses: raven-actions/actionlint@v1
- name: actionlint Summary
if: always()
run: |
echo "Used actionlint version ${{ steps.actionlint.outputs.version-semver }}"
echo "Used actionlint release ${{ steps.actionlint.outputs.version-tag }}"
echo "actionlint ended with ${{ steps.actionlint.outputs.exit-code }} exit code"
echo "actionlint ended because '${{ steps.actionlint.outputs.exit-message }}'"
echo "actionlint found ${{ steps.actionlint.outputs.total-errors }} errors"
echo "actionlint checked ${{ steps.actionlint.outputs.total-files }} files"
echo "actionlint cache used: ${{ steps.actionlint.outputs.cache-hit }}"
- name: 'Write actionlint Report'
if: always()
uses: OXID-eSales/github-actions/append_report@v4
with:
prefix: 'validate'
priority: '020'
phase: lint
job: 'actionlint'
title: ''
php: ''
mysql: ''
testplan: ''
status: ${{job.status}}
debug: false
matchingyaml:
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Run Check that yaml files always match theiy yml counterpart
if: always()
run: |
RESULT=0
YML_FILES=$(find . -iname '*.yml')
for YML in ${YML_FILES}; do
COUNTERPART="${YML//.yml/.yaml}"
echo "Checking, if ${YML} matches ${COUNTERPART}"
if diff -y --suppress-common-lines --color=always "${YML}" "${COUNTERPART}"; then
echo -e "\033[0;32mOK: Files ${YML} and ${COUNTERPART} match!${LINE}"
else
echo -e "\033[0;31mError: Files ${YML} and ${COUNTERPART} differ!\033[0m"
RESULT=1
fi
done
YAML_FILES=$(find . -iname '*.yaml')
for YAML in ${YAML_FILES}; do
COUNTERPART="${YAML//.yaml/.yml}"
if [ -f "${COUNTERPART}" ]; then
echo "Checking, if ${YAML} matches ${COUNTERPART}"
if diff -y --suppress-common-lines --color=always "${YAML}" "${COUNTERPART}"; then
echo -e "\033[0;32mOK: Files ${YAML} and ${COUNTERPART} match!${LINE}"
else
echo -e "\033[0;31mError: Files ${YAML} and ${COUNTERPART} differ!\033[0m"
RESULT=1
fi
else
echo "No matching counterpart (${COUNTERPART}) for ${YAML}"
fi
done
if [ ${RESULT} -ne 0 ]; then
echo -e "\033[0;31mCheck failed, there are mismatches between yaml and yml files!\033[0m"
exit 1
fi
- name: 'Write actionlint Report'
if: always()
uses: OXID-eSales/github-actions/append_report@v4
with:
prefix: 'validate'
priority: '030'
phase: lint
job: 'matchingyaml'
title: ''
php: ''
mysql: ''
testplan: ''
status: ${{job.status}}
debug: false
finish:
if: always()
needs:
- init
- yamllint
- actionlint
- matchingyaml
runs-on: 'ubuntu-latest'
env:
SLACK_WEBHOOK: "${{ secrets.SLACK_WEBHOOK_URL }}"
steps:
- name: 'Output report'
uses: 'OXID-eSales/github-actions/generate_report@v4'
with:
prefix: 'validate'
slack_webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
title: 'Workflow validation on ${{ github.repository }} by ${{ github.actor }}'
compact: true
debug: false