diff --git a/.github/actions/build/verify-structure/action.yml b/.github/actions/build/verify-structure/action.yml index 142df6f..31e509e 100644 --- a/.github/actions/build/verify-structure/action.yml +++ b/.github/actions/build/verify-structure/action.yml @@ -1,6 +1,16 @@ name: Run Build job - Verify Structure description: Download and verify the structure of the built wheel package. +inputs: + expected-directories: + description: 'Newline-separated list of directories expected to exist relative to site-packages' + required: false + default: '' + expected-files: + description: 'Newline-separated list of files expected to exist relative to site-packages' + required: false + default: '' + runs: using: composite steps: @@ -36,14 +46,48 @@ runs: # Check for required directories in site-packages echo "Checking required directories in site-packages..." + REQUIRED_DIRS=( + "${SITE_PACKAGES}" "${SITE_PACKAGES}/${{ env.PACKAGE_NAME }}" ) + REQUIRED_FILES=() + + # Build array of required directories + if [ -n "${{ inputs.expected-directories }}" ]; then + while IFS= read -r dir; do + if [ -n "$dir" ]; then + REQUIRED_DIRS+=("${SITE_PACKAGES}/${dir}") + fi + done <<< "${{ inputs.expected-directories }}" + fi + + # Build array of required files + if [ -n "${{ inputs.expected-files }}" ]; then + while IFS= read -r file; do + if [ -n "$file" ]; then + REQUIRED_FILES+=("${SITE_PACKAGES}/${file}") + fi + done <<< "${{ inputs.expected-files }}" + fi + # Check for required directories in site-packages + echo "Checking required directories in site-packages..." for dir in "${REQUIRED_DIRS[@]}"; do if [ ! -d "$dir" ]; then echo "Required directory not found: $dir" exit 1 fi done + + # Check for required files in site-packages + if [ ${#REQUIRED_FILES[@]} -gt 0 ]; then + echo "Checking required files in site-packages..." + for file in "${REQUIRED_FILES[@]}"; do + if [ ! -f "$file" ]; then + echo "Required file not found: $file" + exit 1 + fi + done + fi shell: bash diff --git a/.github/actions/setup/set-package-name/action.yml b/.github/actions/setup/set-package-name/action.yml deleted file mode 100644 index 2341112..0000000 --- a/.github/actions/setup/set-package-name/action.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Set Package Name -description: Sets the PACKAGE_NAME environment variable by replacing hyphens with underscores in the repository name. - -runs: - using: composite - steps: - - name: Set package name - run: | - REPO_NAME="${{ github.event.repository.name }}" - echo "PACKAGE_NAME=${REPO_NAME//-/_}" >> $GITHUB_ENV - shell: bash diff --git a/.github/actions/setup/setup-uv-python/action.yml b/.github/actions/setup/setup-uv-python/action.yml index 355e7f1..e72bbe4 100644 --- a/.github/actions/setup/setup-uv-python/action.yml +++ b/.github/actions/setup/setup-uv-python/action.yml @@ -13,3 +13,8 @@ runs: uses: actions/setup-python@v6 with: python-version-file: ".python-version" + - name: Set package name + run: | + REPO_NAME="${{ github.event.repository.name }}" + echo "PACKAGE_NAME=${REPO_NAME//-/_}" >> $GITHUB_ENV + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 135fc8b..e5fb4e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,10 +13,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - - uses: ./.github/actions/setup/set-package-name - if: ${{ github.event.repository.name == 'template-python' }} - - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - if: ${{ github.event.repository.name != 'template-python' }} - uses: ./.github/actions/build/build-wheel if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/build/build-wheel@main @@ -27,10 +23,6 @@ jobs: needs: build-wheel steps: - uses: actions/checkout@v6 - - uses: ./.github/actions/setup/set-package-name - if: ${{ github.event.repository.name == 'template-python' }} - - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - if: ${{ github.event.repository.name != 'template-python' }} - uses: ./.github/actions/build/verify-structure if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/build/verify-structure@main diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6455dca..f368253 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,10 +49,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - - uses: ./.github/actions/setup/set-package-name - if: ${{ github.event.repository.name == 'template-python' }} - - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - if: ${{ github.event.repository.name != 'template-python' }} - uses: ./.github/actions/ci/bandit if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/bandit@main diff --git a/.here b/.here new file mode 100644 index 0000000..e69de29 diff --git a/docs/WORKFLOWS.md b/docs/WORKFLOWS.md index 951522f..0e55230 100644 --- a/docs/WORKFLOWS.md +++ b/docs/WORKFLOWS.md @@ -65,21 +65,6 @@ steps: --- -**set-package-name:** -- Description: Sets the `PACKAGE_NAME` environment variable by replacing hyphens with underscores in the repository name. -- Location: `set-package-name/action.yml` -- Steps: - - Derives `PACKAGE_NAME` from `github.event.repository.name` using bash parameter expansion (`${REPO_NAME//-/_}`) - - Writes the result to `$GITHUB_ENV` so it is available to all subsequent steps - -Usage: -```yaml -steps: - - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main -``` - ---- - ### CI Actions (`/ci/**/action.yml`) **validate-pyproject:** @@ -155,7 +140,6 @@ steps: Usage: ```yaml steps: - - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - uses: javidahmed64592/template-python/.github/actions/ci/bandit@main ``` @@ -216,7 +200,6 @@ steps: Usage: ```yaml steps: - - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - uses: javidahmed64592/template-python/.github/actions/build/build-wheel@main ``` @@ -229,16 +212,27 @@ steps: - Uses the `install-python-core` action - Downloads the wheel artifact (named `{PACKAGE_NAME}_wheel`) - Installs the wheel using `uv pip install` - - Verifies that the package directory exists in site-packages - - Fails if required package structure is missing + - Verifies that `site-packages` and the package directory exist + - Optionally verifies additional directories and files specified in inputs + - Fails if any required structure is missing Usage: ```yaml steps: - - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - uses: javidahmed64592/template-python/.github/actions/build/verify-structure@main ``` +Advanced usage with additional checks: +```yaml +steps: + - uses: javidahmed64592/template-python/.github/actions/build/verify-structure@main + with: + expected-directories: | + static + expected-files: | + static/index.html +``` + ## Workflows (`./github/workflows`) The following workflows ensure Python codebases are robust and thoroughly tested.