Skip to content

[pre-commit.ci] pre-commit autoupdate #203

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #203

Workflow file for this run

---
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2025 The Linux Foundation
# Action test/validation workflow
name: 'Test GitHub Action 🧪'
# yamllint disable-line rule:truthy
on:
workflow_dispatch:
push:
branches: ['main']
pull_request:
branches: ['main']
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
permissions: {}
jobs:
### Test the GitHub Action in this Repository ###
tests:
name: 'Action Testing'
runs-on: 'ubuntu-24.04'
permissions:
contents: read
steps:
- name: 'Checkout repository'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# Perform setup prior to running test(s)
- name: 'Checkout sample project repository'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: 'lfreleng-actions/test-python-project'
path: 'test-python-project'
- name: "Run action: ${{ github.repository }}"
id: test-static
uses: ./
with:
path_prefix: 'test-python-project'
- name: "Update pyproject.toml for dynamic versioning"
shell: bash
run: |
# Update pyproject.toml for dynamic versioning
echo "Copying dynamic pyproject.toml to test-python-project"
cp resources/dynamic-pyproject.toml test-python-project/pyproject.toml
- name: "Run action: ${{ github.repository }}"
id: test-dynamic
uses: ./
with:
path_prefix: 'test-python-project'
- name: "Validate action output: ${{ github.repository }}"
shell: bash
# yamllint disable rule:line-length
run: |
# Validate Action Output
if [ "${{ steps.test-static.outputs.python_project_file }}" \
!= "pyproject.toml" ]; then
echo 'Unexpected return value for: python_project_file ❌'
echo "Returned: ${{ steps.test-static.outputs.python_project_file }}"
echo 'Expected: pyproject.toml'
ERROR='true'
fi
if [ "${{ steps.test-static.outputs.versioning_type }}" \
!= "static" ]; then
echo 'Unexpected return value for: versioning_type ❌'
echo "Returned: ${{ steps.test-static.outputs.versioning_type }}"
echo 'Expected: static'
ERROR='true'
fi
if [ "${{ steps.test-dynamic.outputs.versioning_type }}" \
!= "dynamic" ]; then
echo 'Unexpected return value for: versioning_type ❌'
echo "Returned: ${{ steps.test-dynamic.outputs.versioning_type }}"
echo 'Expected: dynamic'
ERROR='true'
fi
if [ "${{ steps.test-static.outputs.python_project_name }}" \
!= 'lfreleng-test-python-project' ]; then
echo 'Unexpected return value for: python_project_name ❌'
echo "Returned: ${{ steps.test-static.outputs.python_project_name }}"
echo 'Expected: lfreleng-test-python-project'
ERROR='true'
fi
if [ "${{ steps.test-static.outputs.python_package_name }}" \
!= 'lfreleng_test_python_project' ]; then
echo 'Unexpected return value for: python_package_name ❌'
echo "Returned: ${{ steps.test-static.outputs.python_project_name }}"
echo 'Expected: lfreleng_test_python_project'
ERROR='true'
fi
if [ "$ERROR" != 'true' ]; then
echo 'All tests passed ✅'
else
echo 'At least one test failed ❌'
exit 1
fi