diff --git a/.centurion/project_status.json b/.centurion/project_status.json new file mode 100644 index 0000000..e686e86 --- /dev/null +++ b/.centurion/project_status.json @@ -0,0 +1,8 @@ +{ + "schemaVersion": 1, + "label": "Project Status", + "message": "Active", + "namedLogo": "github", + "color": "green", + "style": "plastic" +} \ No newline at end of file diff --git a/.gitea/ISSUE_TEMPLATE/config.yml b/.gitea/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..8b76b04 --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,3 @@ +--- + +blank_issues_enabled: true diff --git a/.gitea/workflows/bump.yaml b/.gitea/workflows/bump.yaml new file mode 100644 index 0000000..b440705 --- /dev/null +++ b/.gitea/workflows/bump.yaml @@ -0,0 +1,243 @@ +--- + +name: 'Bump' + + +on: + workflow_call: + inputs: + CZ_PRE_RELEASE: + default: none + required: false + description: Create Pre-Release {alpha,beta,rc,none} + type: string + CZ_INCREMENT: + default: none + required: false + description: Type of increment to conduct {MAJOR,MINOR,PATCH,none} + type: string + secrets: + WORKFLOW_TOKEN: + description: Token used to create the tag (required to trigger 'tag' workflow) + required: true + + +jobs: + + bump: + name: 'Bump Version' + if: github.event.commits[0].author.name != 'nfc-bot' + runs-on: ubuntu-latest + outputs: + version-current: ${{ steps.version-current.outputs.value-out }} + version-new: ${{ steps.version-new.outputs.value-out }} + steps: + + + - name: Checkout Code - ${{ github.ref_name }} Branch + if: ${{ github.ref_name == 'master' }} + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + token: ${{ secrets.WORKFLOW_TOKEN }} + ref: development + + + - name: Checkout Code - ${{ github.ref_name }} Branch + if: ${{ github.ref_name != 'master' }} + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + token: ${{ secrets.WORKFLOW_TOKEN }} + ref: ${{ github.ref_name }} + + + - name: Install Commitizen + shell: bash + run: | + pip install \ + commitizen==3.28.0 + + + - name: Fetch Current Version + id: version-current + run: | + echo "value-out=$(cz version --project)" >> $GITHUB_OUTPUT + + + - name: Increment version with .cz.yaml + shell: bash + run: | + if [ "${{ inputs.CZ_PRE_RELEASE }}" != 'none' ]; then + + if [ "0${{ inputs.CZ_PRE_RELEASE }}" != '0' ]; then + + echo "[debug] Pre-Release detected: ${{ inputs.CZ_PRE_RELEASE }}"; + + export pre_release="--prerelease ${{ inputs.CZ_PRE_RELEASE }}"; + + fi; + + fi; + + if [ "${{ inputs.CZ_INCREMENT }}" != 'none' ]; then + + if [ "0${{ inputs.CZ_PRE_RELEASE }}" != '0' ]; then + + echo "[debug] Pre-Release detected: ${{ inputs.CZ_INCREMENT }}"; + + export increment="--increment ${{ inputs.CZ_INCREMENT }}"; + + fi; + + fi; + + cz bump \ + --files-only \ + ${pre_release} \ + ${increment} \ + --yes; + + + - name: Fetch Current Version + id: version-new + run: | + echo "value-out=$(cz version --project)" >> $GITHUB_OUTPUT + + + - name: ls + if: ${{ github.ref_name != 'master' }} + shell: bash + run: | + ls -la + + + - name: Update Changelog + shell: bash + run: | + cz changelog --dry-run --incremental --unreleased-version "${{ steps.version-new.outputs.value-out }}" > changelog-release.md + + + - name: Update Changelog + shell: bash + run: | + cz changelog --unreleased-version "${{ steps.version-new.outputs.value-out }}" + + + - name: Upload Release Changelog + if: ${{ steps.version-new.outputs.value-out }} + uses: actions/upload-artifact@v4 + with: + name: changelog-release + path: changelog-release.md + + + - name: Create Release Changelog + if: ${{ steps.version-new.outputs.value-out }} + shell: bash + run: | + rm changelog-release.md; + git status; + + + - name: Run Additional Actions + if: ${{ steps.version-current.outputs.value-out != steps.version-new.outputs.value-out }} + shell: bash + run: | + echo 'run script'; + if [ -f .github/additional_actions_bump.sh ]; then + + echo "[Info] Set ENV vars for script's usage"; + + export CURRENT_VERSION=${{ steps.version-current.outputs.value-out }} + + export NEW_VERSION=${{ steps.version-new.outputs.value-out }} + + echo "[Info] ***************************************"; + + echo "[Debug]CURRENT_VERSION=${CURRENT_VERSION}"; + + echo "[Debug]NEW_VERSION=${NEW_VERSION}"; + + echo "[Info] ***************************************"; + + chmod +x .github/additional_actions_bump.sh + + echo "[Debug] found additional action script .github/additional_actions_bump.sh"; + + echo "[Info] ***************************************"; + echo "[Debug] cat .github/additional_actions_bump.sh"; + echo "[Info] *************"; + + echo "[Debug] $(cat .github/additional_actions_bump.sh)"; + + echo "[Info] *************"; + echo "[Info] ***************************************"; + + .github/additional_actions_bump.sh + + fi + + + - name: Commit the changelog + if: ${{ steps.version-new.outputs.value-out && github.ref_name == 'master' }} + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: 'build: bump version ${{ steps.version-current.outputs.value-out }} -> ${{ steps.version-new.outputs.value-out }}' + branch: development + # file_pattern: '.' + commit_user_name: nfc-bot + commit_user_email: helpdesk@nofusscomputing.com + commit_author: nfc-bot + tagging_message: ${{ steps.version-new.outputs.value-out }} + skip_dirty_check: true + skip_fetch: true + skip_checkout: true + disable_globbing: true + + + - name: Commit the changelog + if: ${{ steps.version-new.outputs.value-out && github.ref_name != 'master'}} + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: 'build: bump version ${{ steps.version-current.outputs.value-out }} -> ${{ steps.version-new.outputs.value-out }}' + branch: ${{ github.ref_name }} + # file_pattern: '.' + commit_user_name: nfc-bot + commit_user_email: helpdesk@nofusscomputing.com + commit_author: nfc-bot + tagging_message: ${{ steps.version-new.outputs.value-out }} + skip_dirty_check: true + skip_fetch: true + skip_checkout: true + disable_globbing: true + + + - name: Configure git + shell: bash + run: | + git config --global user.email "helpdesk@nofusscomputing.com"; + git config --global user.name "nfc-bot"; + + + - name: Checkout master + if: ${{ github.ref_name == 'master' }} + shell: bash + run: | + git checkout master; + + + - name: Merge changes to master + if: ${{ github.ref_name == 'master' }} + shell: bash + run: | + git merge --no-ff development; + + + - name: Push changes + if: ${{ github.ref_name == 'master' }} + shell: bash + run: | + git push origin master; diff --git a/.gitea/workflows/conventional_commits.yaml b/.gitea/workflows/conventional_commits.yaml new file mode 100644 index 0000000..b160416 --- /dev/null +++ b/.gitea/workflows/conventional_commits.yaml @@ -0,0 +1,40 @@ +--- + +name: Conventional Commits + + +on: + pull_request: {} + push: + branches: + - 'development' + + +jobs: + + conventional-pr-title: + name: Conventional PR Title + runs-on: ubuntu-latest + steps: + + + - name: Conventional Commit PR Title + if: ${{ github.event_name == 'pull_request' }} + uses: agenthunt/conventional-commit-checker-action@v1.0.0 + with: + pr-title-regex: "^(.+)(?:(([^)s]+)))?: (.+)" + pr-body-regex: "(.*)" + + + conventional-commits: + name: Conventional Commits + runs-on: ubuntu-latest + steps: + + - name: Check Commits + uses: taskmedia/action-conventional-commits@v1.1.17 + with: + token: ${{ github.token }} + skip_merge: true + skip_revert: true + types: "build|bump|chore|ci|docs|feat|fix|perf|refactor|revert|style|test" diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..d847e5b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +--- + +blank_issues_enabled: false + +contact_links: + - name: New Issue + url: https://nofusscomputing.com/git/actions/action_python/issues + about: Create a new issue at the repositories home. \ No newline at end of file diff --git a/.github/workflows/python-integration.yaml b/.github/workflows/python-integration.yaml new file mode 100644 index 0000000..806e4f8 --- /dev/null +++ b/.github/workflows/python-integration.yaml @@ -0,0 +1,339 @@ +--- +name: 'Integration Test' + + +on: + workflow_call: + inputs: + POSTGRES_VERSIONS: + default: '[ "13", "14", "15", "16", "17" ]' + description: PostgreSQL Versions to test + required: false + type: string + PYTHON_VERSION: + default: '3.11' + description: Python Version to use + required: false + type: string + RABBITMQ_VERSIONS: + default: '[ "3.12", "3.13", "4.0", "4.1" ]' + description: PostgreSQL Versions to test + required: false + type: string + secrets: + WORKFLOW_TOKEN: + description: "token to clone with" + required: false + + +jobs: + + integration-test: + name: Integration Test + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + matrix: + postgres-version: ${{ fromJSON(inputs.POSTGRES_VERSIONS) }} + rabbitmq-version: ${{ fromJSON(inputs.RABBITMQ_VERSIONS) }} + continue-on-error: true + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + fetch-tags: 'true' + + + - name: Git + run: | + git fetch -fpvt + echo "latest tag commit $(git rev-list -n 1 $(git describe --tags --abbrev=0))" + + + - name: Set up Docker Compose + run: | + sudo apt-get update; + sudo apt-get install -y docker-compose; + echo '***************************'; + which docker-compose || true; + echo '***************************'; + docker compose version || true; + + + - name: Set up Python ${{ inputs.PYTHON_VERSION }} + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: ${{ inputs.PYTHON_VERSION }} + + + - name: Install Python Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements_dev.txt + + + - run: | + echo "::remove-matcher owner=python::" + + + - name: Run Tests + id: run-integration-test + continue-on-error: true + shell: bash + env: + CENTURION_RABBITMQ_IMAGE_TAG: ${{ matrix.rabbitmq-version }} + CENTURION_POSTGRES_IMAGE_TAG: ${{ matrix.postgres-version }} + run: | + export CENTURION_IMAGE_TAG=${GITHUB_SHA}; + make test-integration + + + - name: Trace + run: | + echo "PWD is [${PWD}]"; + ls -laR + + + - name: Test Report + if: success() || failure() + # uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 + uses: dorny/test-reporter@79b4b4400dc2354b89e9dd811ef9caa9bdd4f665 # main fix http errors see: https://github.com/dorny/test-reporter/pull/867 + id: test-report + with: + name: Integration Test Report [python_${{ inputs.PYTHON_VERSION }}-postgres_${{ matrix.postgres-version }}-rabbitmq_${{ matrix.rabbitmq-version }}] + path: 'integration.JUnit.xml' + reporter: java-junit + use-actions-summary: false + + + - name: Upload Junit Test Report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: integration-test-report-junit-python_${{ inputs.PYTHON_VERSION }}-postgres_${{ matrix.postgres-version }}-rabbitmq_${{ matrix.rabbitmq-version }} + path: integration.JUnit.xml + + - name: Upload Artifacts + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: integration-logs-python_${{ inputs.PYTHON_VERSION }}-postgres_${{ matrix.postgres-version }}-rabbitmq_${{ matrix.rabbitmq-version }} + path: | + app/log/ + artifacts/ + log/ + test/volumes/log/ + test/volumes/artifacts/ + + - name: log file check + if: success() || failure() + run: | + ls -la log/ || true; + ls -la app/log/ || true; + + + badge-endpoint-versions: + name: Publish Version Badge endpoint files + if: >- + (github.ref_name == 'master' || github.ref_name == 'development') + && + github.repository == 'nofusscomputing/centurion_erp' + needs: + - integration-test + runs-on: ubuntu-latest + steps: + + + - name: Create PostgreSQL Shields.io Endpoint.json + shell: bash + run: | + versions=$(echo '${{ inputs.POSTGRES_VERSIONS }}' | tr -d "[]\"" | tr ',' ' |' | xargs) + cat < badge_endpoint_integration_postgres_versions.json + { + "schemaVersion": 1, + "label": "PostgreSQL", + "message": "$versions", + "color": "#336791", + "style": "plastic" + } + EOF + + + - name: Upload Badge Endpoint json + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: badge_endpoint_integration_postgres_versions + path: badge_endpoint_integration_postgres_versions.json + + + - name: Create RabbitMQ Shields.io Endpoint.json + shell: bash + run: | + versions=$(echo '${{ inputs.RABBITMQ_VERSIONS }}' | tr -d "[]\"" | tr ',' ' |' | xargs) + cat < badge_endpoint_integration_rabbitmq_versions.json + { + "schemaVersion": 1, + "label": "RabbitMQ", + "message": "$versions", + "logoSvg": "", + "color": "#F60", + "style": "plastic" + } + EOF + + + - name: Upload Badge Endpoint json + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: badge_endpoint_integration_rabbitmq_versions + path: badge_endpoint_integration_rabbitmq_versions.json + + + - name: Checkout Endpoint Repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: 'nofusscomputing/.github' + ref: 'master' + token: ${{ secrets.WORKFLOW_TOKEN }} + path: 'endpoint_publish' + fetch-depth: '1' + show-progress: true + submodules: false + + + - name: Create Publish Directories + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + cd endpoint_publish; + echo "[Debug] PWD[${PWD}]"; + mkdir -p repositories/${{ github.repository }}/${{ github.ref_name }}; + ls -la; + + + - name: Create Publish Directories + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + # cd repositories/${{ github.repository }}/${{ github.ref_name }}; + echo "[Debug] PWD[${PWD}]"; + + + - name: Download Postgres Version Badge Endpoint json + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: badge_endpoint_integration_postgres_versions + + + - name: Download RabbitMQ Version Badge Endpoint json + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: badge_endpoint_integration_rabbitmq_versions + + + - name: Add endpoint file + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + + echo "[Debug] **************************** - cd endpoint_publish"; + + cd endpoint_publish; + + echo "[Debug] **************************** - ls -la"; + + ls -la + + echo "[Debug] ****************************"; + + echo "[Debug] PWD[${PWD}]"; + + echo "[Debug] **************************** - ls -la ../"; + + ls -la ../ + + echo "[Debug] **************************** - cp ../badge_endpoint_integration_postgres_versions.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_integration_postgres_versions.json"; + + cp ../badge_endpoint_integration_postgres_versions.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_integration_postgres_versions.json; + + echo "[Debug] **************************** - cp ../badge_endpoint_integration_rabbitmq_versions.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_integration_rabbitmq_versions.json"; + + cp ../badge_endpoint_integration_rabbitmq_versions.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_integration_rabbitmq_versions.json; + + echo "[Debug] **************************** - ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/"; + + ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/; + + + - name: Configure git + shell: bash + run: | + git config --global user.email "helpdesk@nofusscomputing.com"; + git config --global user.name "nfc-bot"; + + + - name: Git add + id: git-add + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git status; + echo "[Debug] ****************************"; + + if [ "$(git status -s)" ]; then + + echo "changed=true" > $GITHUB_OUTPUT; + + echo "[Info] Changes need to be committed"; + + else + + echo "changed=false" > $GITHUB_OUTPUT; + + echo "[Info] NO changes to be committed"; + + fi + + echo "[Debug] ****************************"; + + git add . + + + - name: Git commit + if: ${{ steps.git-add.outputs.changed == 'true' }} + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git commit -m "chore: add versions badge endpount file ${{ github.repository }}/${{ github.ref_name }}" + + + - name: git push + if: ${{ steps.git-add.outputs.changed == 'true' }} + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git push diff --git a/.github/workflows/python-package.yaml b/.github/workflows/python-package.yaml new file mode 100644 index 0000000..acb8fd3 --- /dev/null +++ b/.github/workflows/python-package.yaml @@ -0,0 +1,22 @@ +--- +name: 'Python Package' + + +on: + workflow_call: + + +jobs: + + build-and-inspect-package: + name: Build + runs-on: ubuntu-latest + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + + + - uses: hynek/build-and-inspect-python-package@v2 diff --git a/.github/workflows/python-post.yaml b/.github/workflows/python-post.yaml new file mode 100644 index 0000000..6547d60 --- /dev/null +++ b/.github/workflows/python-post.yaml @@ -0,0 +1,248 @@ +name: 'Python - Post' + +on: + workflow_call: +# +# When you import this workflow use this trigger +# as the example +# +# on: +# workflow_run: +# workflows: +# - CI +# branches-ignore: +# - master +# - development +# - feat-* +# types: +# - completed + + +permissions: + contents: read # python-report-test + actions: read # python-report-test + checks: write # python-report-test + + +jobs: + + + trace: + name: Trace + if: >- + github.event.workflow_run.conclusion == 'success' + && + github.event.workflow_run.event == 'pull_request' + && + github.event.workflow_run.head_repository.full_name != github.event.workflow_run.repository.full_name + runs-on: ubuntu-latest + steps: + + + - name: Trace + shell: bash + run: + echo "***************** export env vars ****************"; + export; + echo "***************** Do PR vars show? ****************"; + echo "${{ github.pull_request }}"; + echo "***************** ****************"; + + echo "***************** ****************"; + + + - name: "[Trace] Dump event payload" + shell: bash + run: | + jq . "$GITHUB_EVENT_PATH" + + + - name: "[Trace] Dump environment" + shell: bash + run: | + env | sort + + + - name: "[Trace] Dump GitHub contexts" + shell: bash + env: + GITHUB_CONTEXT: ${{ toJSON(github) }} + INPUTS_CONTEXT: ${{ toJSON(inputs) }} + VARS_CONTEXT: ${{ toJSON(vars) }} + ENV_CONTEXT: ${{ toJSON(env) }} + JOB_CONTEXT: ${{ toJSON(job) }} + STEPS_CONTEXT: ${{ toJSON(steps) }} + RUNNER_CONTEXT: ${{ toJSON(runner) }} + STRATEGY_CONTEXT: ${{ toJSON(strategy) }} + MATRIX_CONTEXT: ${{ toJSON(matrix) }} + NEEDS_CONTEXT: ${{ toJSON(needs) }} + run: | + echo "===== github =====" + echo "$GITHUB_CONTEXT" + + echo "===== inputs =====" + echo "$INPUTS_CONTEXT" + + echo "===== vars =====" + echo "$VARS_CONTEXT" + + echo "===== env =====" + echo "$ENV_CONTEXT" + + echo "===== job =====" + echo "$JOB_CONTEXT" + + echo "===== steps =====" + echo "$STEPS_CONTEXT" + + echo "===== runner =====" + echo "$RUNNER_CONTEXT" + + + + python-report-test-unit: + name: Unit Test Report + if: >- + github.event.workflow_run.conclusion == 'success' + && + github.event.workflow_run.event == 'pull_request' + && + github.event.workflow_run.head_repository.full_name != github.event.workflow_run.repository.full_name + runs-on: ubuntu-latest + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + + - name: Download Unit Test Report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: unit-test-results-3.11 + repository: nofusscomputing/centurion_erp + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + + - name: Unit Test Report + # uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 + uses: dorny/test-reporter@79b4b4400dc2354b89e9dd811ef9caa9bdd4f665 # main fix http errors see: https://github.com/dorny/test-reporter/pull/867 + id: test-report-unit + with: + # artifact: unit-test-results-${{ matrix.python-version }} + name: Unit Test Report [Python 3.11] + path: '*.xml' + reporter: java-junit + use-actions-summary: false + + + + python-report-test-functional: + name: Function Test Report + if: >- + github.event.workflow_run.conclusion == 'success' + && + github.event.workflow_run.event == 'pull_request' + && + github.event.workflow_run.head_repository.full_name != github.event.workflow_run.repository.full_name + runs-on: ubuntu-latest + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + + - name: Download Functional Test Report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: functional-test-results-3.11 + repository: nofusscomputing/centurion_erp + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + + - name: Functional Test Report + # uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 + uses: dorny/test-reporter@79b4b4400dc2354b89e9dd811ef9caa9bdd4f665 # main fix http errors see: https://github.com/dorny/test-reporter/pull/867 + id: test-report-functional + with: + # artifact: functional-test-results-${{ matrix.python-version }} + name: Functional Test Report [Python 3.11] + path: '*.xml' + reporter: java-junit + # fail-on-error: false + use-actions-summary: false + + + + python-report-coverage-unit: + name: Unit Test Coverage Report + if: >- + github.event.workflow_run.conclusion == 'success' + && + github.event.workflow_run.event == 'pull_request' + && + github.event.workflow_run.head_repository.full_name != github.event.workflow_run.repository.full_name + runs-on: ubuntu-latest + steps: + + + - name: Download Coverage Artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: code-coverage-results-3.11 + repository: nofusscomputing/centurion_erp + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + - name: Debug coverage summary + run: | + pwd + ls -la + file code-coverage-results.md || true + stat code-coverage-results.md || true + + + - name: create status check/comment for code coverage results + id: jest_coverage_check + uses: im-open/process-code-coverage-summary@e2984f897702d68619d358a834d80a74aa0d9840 # v2.3.1 + with: + github-token: ${{ github.token }} + summary-file: code-coverage-results.md + create-pr-comment: true + update-comment-if-one-exists: true + update-comment-key: "${{ env.GITHUB-JOB }}_${{ env.GITHUB-ACTION }}" + + + + python-report-coverage-functional: + name: Functional Test Coverage Report + if: >- + github.event.workflow_run.conclusion == 'success' + && + github.event.workflow_run.event == 'pull_request' + && + github.event.workflow_run.head_repository.full_name != github.event.workflow_run.repository.full_name + runs-on: ubuntu-latest + steps: + + + - name: Download Coverage Artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: functional-code-coverage-results-3.11 + repository: nofusscomputing/centurion_erp + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + + - name: create status check/comment for code coverage results + id: jest_coverage_check + uses: im-open/process-code-coverage-summary@e2984f897702d68619d358a834d80a74aa0d9840 # v2.3.1 + with: + github-token: ${{ github.token }} + summary-file: code-coverage-results.md + check-name: 'Functional Code Coverage' + create-pr-comment: true + update-comment-if-one-exists: true + update-comment-key: "${{ env.GITHUB-JOB }}_${{ env.GITHUB-ACTION }}" diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml new file mode 100644 index 0000000..a37f802 --- /dev/null +++ b/.github/workflows/python-publish.yaml @@ -0,0 +1,82 @@ +--- +name: 'Python Publish' + + +on: + workflow_call: + inputs: + PYTHON_PROJECT_NAME: + description: PyPi Package Project + required: true + type: string + + PYTHON_PROJECT_URL: + description: PyPi Package Project + default: pypi.org # pypi.org | test.pypi.org + required: false + type: string + + # secrets: + # password: + # required: true + +jobs: + + + pypi-publish: + name: Upload release to PyPI + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + + runs-on: ubuntu-latest + environment: + name: pypi + url: https://${{ inputs.PYTHON_PROJECT_URL}}/p/${{ inputs.PYTHON_PROJECT_NAME}}/ + permissions: + id-token: write + steps: + + - name: Download built artifact to dist/ + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: Packages + path: dist + + + # - name: Publish package distributions to PyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # skip-existing: true + # repository-url: https://${{ inputs.PYTHON_PROJECT_URL}}/project/${{ inputs.PYTHON_PROJECT_NAME}}/ + # user: ${{ secrets.NFC_PYPI_USERNAME }} + # password: ${{ secrets.NFC_PYPI_TOKEN }} + + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: '3.13' + + + - name: Install Twine + run: | + pip install twine + + + - name: Trace + run: | + ls -l; + echo '****************************************************'; + ls -l dist/; + + + - name: Publish package distributions to PyPI + # env: + # TWINE_USERNAME: __token__ + # TWINE_PASSWORD: ${{ secrets.NFC_PYPI_TOKEN }} + # TWINE_REPOSITORY: https://${{ inputs.PYTHON_PROJECT_URL}}/project/${{ inputs.PYTHON_PROJECT_NAME}}/ + run: | + twine upload \ + --verbose \ + --username __token__ \ + --password ${{ secrets.NFC_PYPI_TOKEN }} \ + dist/* diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml new file mode 100644 index 0000000..44a74de --- /dev/null +++ b/.github/workflows/python.yaml @@ -0,0 +1,2100 @@ +--- +name: 'Python' + + +on: + workflow_call: + inputs: + BRANCH: + description: Branch to run the Vulnerability scan on + required: false + type: string + DEFAULT_ONLY: + default: false + description: Should this run be for the default python version only + required: false + type: boolean + LINT: + default: true + description: Should pylint run + required: false + type: boolean + LINT_ERROR_ON_WARNING: + default: false + description: Should pylint return error on Warning + required: false + type: boolean + PYTHON_VERSION: + default: '3.11' + description: Default Python Version + required: false + type: string + PYTHON_VERSIONS: + default: '["3.10", "3.11","3.12","3.13"]' + description: Default Python Version + required: false + type: string + secrets: + WORKFLOW_TOKEN: + description: "token to clone with" + required: false + + +# env: +# TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2 # see https://github.com/nofusscomputing/action_python/issues/10 + + +jobs: + + init: + name: Meta + runs-on: ubuntu-latest + outputs: + changed-files: ${{ steps.changed-files.outputs.project_all_changed_files }} + doc-changed-files: ${{ steps.changed-files.outputs.docs_changed_files }} + py-changed-files: ${{ steps.changed-files.outputs.all_changed_files }} + pip-any-changed: ${{ steps.changed-files-pip.outputs.any_changed}} + py-any-changed: ${{ steps.changed-files.outputs.any_changed}} + tesy-changed-files: ${{ steps.changed-files.outputs.test_changed_files }} + requirements_set: ${{ steps.requirements_set.outputs.requirements }} + matrix_python_versions: ${{ steps.matrix_python_versions.outputs.MATRIX_PYTHON_VERSIONS }} + steps: + + + - name: Matrix python versions + id: matrix_python_versions + run: | + if [ "${{ inputs.DEFAULT_ONLY }}" == "true" ]; then + + echo 'MATRIX_PYTHON_VERSIONS=[ "${{ inputs.PYTHON_VERSION }}" ]' >> $GITHUB_OUTPUT + + else + + echo 'MATRIX_PYTHON_VERSIONS=${{ inputs.PYTHON_VERSIONS }}' >> $GITHUB_OUTPUT + + fi; + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + # fetch-depth: 100 + fetch-depth: 0 + + + - name: Get base branch name + id: base-branch-name + shell: bash + run: | + export CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD); + + if [ "${CURRENT_BRANCH}" == "development" ]; then + + BASE_BRANCH=master + + elif [ "${CURRENT_BRANCH}" == "feature-next-release" ]; then + + BASE_BRANCH=development + + elif [ "${CURRENT_BRANCH}" == "feat-next-release" ]; then + + BASE_BRANCH=development + + else + + if [ $(git rev-parse --verify feat-next-release) ]; then + + BASE_BRANCH=feat-next-release + + elif [ $(git rev-parse --verify feature-next-release) ]; then + + BASE_BRANCH=feature-next-release + + fi + + echo $BASE_BRANCH + + fi; + + echo "Base branch is ${BASE_BRANCH}"; + + echo BASE_BRANCH=${BASE_BRANCH} > $GITHUB_OUTPUT + + + - name: Trace + shell: bash + run: | + git log -5; + git branch; + + + - uses: nrwl/nx-set-shas@afb73a62d26e41464e9254689e1fd6122ee683c1 #v5.0.1 + id: setSHAs + with: + main-branch-name: ${{ steps.base-branch-name.outputs.BASE_BRANCH }} + + + # - uses: matheusraz/ref-sha@v1 + # id: get-sha + # with: + # ref: ${{ steps.base-branch-name.outputs.BASE_BRANCH }} + # length: 41 + + + - name: Get all files that have changed + id: changed-files + if: ${{ github.ref_name != 'master' && github.ref_name != 'development' && github.ref_type != 'tag' }} + uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6 + with: + files: | + **.py + !app/*/tests/ + !app/*/migrations/ + # base_sha: ${{ steps.setSHAs.outputs.base }} + # base_sha: ${{ steps.get-sha.outputs.sha }} + # base_sha: ${{ env.NX_BASE }} + base_sha: ${{ steps.base-branch-name.outputs.BASE_BRANCH }} + + + - name: List all changed files + # if: steps.changed-files.outputs.any_changed == 'true' + env: + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_and_modified_files }} + run: | + echo "changed: ${ALL_CHANGED_FILES}": + for file in ${ALL_CHANGED_FILES}; do + echo "$file was changed" + done + + + + - name: Get pip-file-changes + id: changed-files-pip + if: ${{ github.ref_name != 'master' && github.ref_name != 'development' && github.ref_type != 'tag' }} + uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6 + with: + files: | + requiremen*.txt + base_sha: ${{ steps.base-branch-name.outputs.BASE_BRANCH }} + + + - name: List all changed pip files + # if: steps.changed-files.outputs.any_changed == 'true' + env: + ALL_CHANGED_PIP_FILES: ${{ steps.changed-files-pip.outputs.all_changed_and_modified_files }} + run: | + echo "changed: ${ALL_CHANGED_PIP_FILES}": + for file in ${ALL_CHANGED_PIP_FILES}; do + echo "$file was changed" + done + + + + - name: Find requirements files + id: requirements_set + run: | + files=$(ls requirements*.txt | jq -R . | jq -s .) + echo "requirements<> "$GITHUB_OUTPUT" + echo "$files" >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + + + + lint: + name: Lint + needs: + - init + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: ${{ fromJson(needs.init.outputs.matrix_python_versions) }} + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + if: ${{ github.ref_name != 'master' && github.ref_name != 'development' && github.ref_type != 'tag' }} + + + - name: Set up Python ${{ matrix.python-version }} + if: ${{ github.ref_name != 'master' && github.ref_name != 'development' && github.ref_type != 'tag' }} + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: ${{ matrix.python-version }} + + + - name: Debug Python build environment + run: | + python --version || true; + echo '*******************************************'; + python -c "import sys; print(sys.executable)" || true; + echo '*******************************************'; + python -c "import sysconfig; print(sysconfig.get_config_var('CC'))" || true; + echo '*******************************************'; + gcc --version || true; + echo '*******************************************'; + sha256sum /opt/hostedtoolcache/Python/3.13.18/x64/include/python3.13/Python.h || true; + echo '*******************************************'; + grep -R '_PyInterpreterState_Get' /opt/hostedtoolcache/Python/3.13.18/x64/include/python3.13/ || true; + echo '*******************************************'; + pg_config --version || true; + echo '*******************************************'; + pg_config --includedir || true; + echo '*******************************************'; + pip cache list | grep psycopg || true; + echo '*******************************************'; + + + + - name: Install Dependencies ${{ matrix.python-version }} + if: ${{ github.ref_name != 'master' && github.ref_name != 'development' && github.ref_type != 'tag' }} + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements_dev.txt + + + + # + # PyLint C value + # + # [I]nformational messages that Pylint emits (do not contribute to your analysis score) + + # [R]efactor for a "good practice" metric violation + + # [C]onvention for coding standard violation + + # [W]arning for stylistic problems, or minor programming issues + + # [E]rror for important programming issues (i.e. most probably bug) + + # [F]atal for errors which prevented further processing + - name: Lint ${{ matrix.python-version }} + id: lint + if: inputs.LINT && needs.init.outputs.py-any-changed + shell: bash + env: + PY_CHANGED_FILES: ${{ needs.init.outputs.py-changed-files }} + run: | + set +e; + + echo "Primary Python version [${{ inputs.PYTHON_VERSION }}], Matrix Python Version [${{ matrix.python-version }}]"; + + if [ "${{ inputs.PYTHON_VERSION }}" != "${{ matrix.python-version }}" ]; then + + echo "Only show Github annotations for primary Python version: ${{ inputs.PYTHON_VERSION }}"; + + pylint \ + --py-version ${{ matrix.python-version }} \ + ${PY_CHANGED_FILES} || EXITCODE=$? + + else + + # available are debug, notice, warning, error + + export I=debug; + export R=notice; + export C=warning; + export W=warning; + export E=error; + export F=error; + + pylint --py-version ${{ matrix.python-version }} --msg-template "::${C} file={path},line={line},endLine={end_line},title={msg_id}::{msg} see " ${PY_CHANGED_FILES} | envsubst; + + export EXITCODE=${PIPESTATUS[0]} + + # pylint \ + # --py-version ${{ matrix.python-version }} \ + # --msg-template "::notice \ + # file={path}, \ + # line={line}, \ + # endLine={end_line}, \ + # title={msg_id}::{msg} see https://pylint.pycqa.org/en/latest/user_guide/messages/{category}/{symbol}.html" \ + # ${PY_CHANGED_FILES} || EXITCODE=$? + + fi; + + + echo "Exit code was $EXITCODE"; + + if [ "${EXITCODE}" ]; then + + echo "exit_code=${EXITCODE}" >> $GITHUB_OUTPUT + + else + + echo "exit_code=0" >> $GITHUB_OUTPUT + + fi + + echo "Exit code was ${EXITCODE}"; + + + + - name: Lint ${{ matrix.python-version }} Bitwise check exit code + id: lint-exit-type + if: inputs.LINT && needs.init.outputs.py-any-changed + shell: bash + env: + EXITCODE: ${{ steps.lint.outputs.exit_code }} + run: | + # Check error code for exit type + # https://pylint.pycqa.org/en/latest/user_guide/usage/run.html#exit-codes + + echo "PyLint uses an exit code that is bit-encoded which is bitwise checked for the severities found. "; + + if (( $EXITCODE & 1 )); then + + echo "Bitwise found: fatal"; + + echo "fatal=true" >> $GITHUB_OUTPUT + + else + + echo "fatal=false" >> $GITHUB_OUTPUT + + fi + + + if (( $EXITCODE & 2 )); then + + echo "Bitwise found: error"; + + echo "error=true" >> $GITHUB_OUTPUT + + else + + echo "error=false" >> $GITHUB_OUTPUT + + fi + + + if (( $EXITCODE & 4 )); then + + echo "Bitwise found: warning"; + + echo "warning=true" >> $GITHUB_OUTPUT + + else + + echo "warning=false" >> $GITHUB_OUTPUT + + fi + + + if (( $EXITCODE & 8 )); then + + echo "Bitwise found: refactor"; + + echo "refactor=true" >> $GITHUB_OUTPUT + + else + + echo "refactor=false" >> $GITHUB_OUTPUT + + fi + + + if (( $EXITCODE & 16 )); then + + echo "Bitwise found: convention"; + + echo "convention=true" >> $GITHUB_OUTPUT + + else + + echo "convention=false" >> $GITHUB_OUTPUT + + fi + + + if (( $EXITCODE & 32 )); then + + echo "Bitwise found: usage error"; + + echo "usage_error=true" >> $GITHUB_OUTPUT + + else + + echo "usage_error=false" >> $GITHUB_OUTPUT + + fi + + + + - name: Fail on Fatal + if: steps.lint-exit-type.outputs.fatal == 'true' + shell: bash + run: | + echo "Lint exit code was ${{ steps.lint.outputs.exit_code }}" + + + - name: Fail on Error + if: steps.lint-exit-type.outputs.error == 'true' + shell: bash + run: | + echo "Lint exit code was ${{ steps.lint.outputs.exit_code }}" + + + - name: Fail on Warning + if: steps.lint-exit-type.outputs.warning == 'true' + shell: bash + run: | + echo "Lint exit code was ${{ steps.lint.outputs.exit_code }}" + + + - name: Fail on Refactor + if: steps.lint-exit-type.outputs.refactor == 'true' + shell: bash + run: | + echo "Lint exit code was ${{ steps.lint.outputs.exit_code }}" + + + - name: Fail on Convention + if: steps.lint-exit-type.outputs.convention == 'true' + shell: bash + run: | + echo "Lint exit code was ${{ steps.lint.outputs.exit_code }}" + + + - name: Fail on Usage Error + if: steps.lint-exit-type.outputs.usage_error == 'true' + shell: bash + run: | + echo "Lint exit code was ${{ steps.lint.outputs.exit_code }}" + + + + + unit-test: + name: Unit Test + runs-on: ubuntu-latest + needs: + - init + - lint + if: github.event_name != 'schedule' + strategy: + max-parallel: 4 + matrix: + python-version: ${{ fromJson(needs.init.outputs.matrix_python_versions) }} + outputs: + unit-test-coverage: ${{ steps.run-unit-test.outputs.coverage }} + unit-test-branch_coverage: ${{ steps.run-unit-test.outputs.branch_coverage }} + continue-on-error: true + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: ${{ matrix.python-version }} + + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements_dev.txt + + + - run: | + echo "::remove-matcher owner=python::" + + + - name: Run Tests + id: run-unit-test + continue-on-error: true + shell: bash + run: | + pytest --cov-report xml:${PWD}/coverage.xml --cov-report html:${PWD}/coverage/ --cov-report json:${PWD}/coverage_unit.json --junit-xml=${PWD}/unit.JUnit.xml app/**/tests/unit; + echo coverage=$(echo "$(jq -r '.totals.percent_covered' coverage_unit.json) " | awk '{printf "%.4f%%", $1"%"}') > $GITHUB_OUTPUT + echo branch_coverage=$(echo "$(jq -r '.totals.covered_branches' coverage_unit.json) $(jq -r '.totals.num_branches' coverage_unit.json)" | awk '{covered=$1; total=$2; printf "%.4f%%", (covered/total*100)"%"}') >> $GITHUB_OUTPUT + + + - name: Trace + run: | + echo "PWD is [${PWD}]"; + ls -laR + + + - name: Upload Test Report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: unit-test-results-${{ matrix.python-version }} + path: unit.JUnit.xml + + + - name: Upload Coverage Report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: coverage-report-${{ matrix.python-version }} + path: coverage.xml + + + # - name: Upload Code Coverage + # if: >- + # ( + # github.event_name != 'pull_request' + # || github.event.pull_request.head.repo.full_name == github.repository + # ) + # && + # matrix.python-version == inputs.PYTHON_VERSION + # uses: actions/upload-code-coverage@bfa741d815a28cb064a8e3a0837e577457a017d5 # v1.4.3 + # with: + # file: coverage.xml + # language: Python + # label: Unit-${{ matrix.python-version }} + + + - name: Upload Coverage Report (json) + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: coverage-report-json-${{ matrix.python-version }} + path: coverage_unit.json + + + - name: Upload Coverage + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: coverage-${{ matrix.python-version }} + path: coverage/* + + - name: Upload Unit Coverage (rc) + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: coverage-rc-unit-${{ matrix.python-version }} + path: .coverage + include-hidden-files: true + + - name: Upload any logs + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: unit-test-centurion-logs-${{ matrix.python-version }} + path: log/* + include-hidden-files: true + + - name: log file check + run: | + ls -la log/ || true; + ls -la app/log/ || true; + + + functional-test: + name: Functional Test + runs-on: ubuntu-latest + needs: + - init + - lint + if: github.event_name != 'schedule' + strategy: + max-parallel: 4 + matrix: + python-version: ${{ fromJson(needs.init.outputs.matrix_python_versions) }} + outputs: + functional-test-coverage: ${{ steps.run-functional-test.outputs.coverage }} + functional-test-branch_coverage: ${{ steps.run-functional-test.outputs.branch_coverage }} + continue-on-error: true + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: ${{ matrix.python-version }} + + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements_dev.txt + + + - run: | + echo "::remove-matcher owner=python::" + + - name: Run Tests + id: run-functional-test + continue-on-error: true + shell: bash + run: | + pytest --cov-report xml:${PWD}/functional-coverage.xml --cov-report html:${PWD}/coverage/functional/ --cov-report json:${PWD}/coverage_functional.json --junit-xml=${PWD}/functional.JUnit.xml app/**/tests/functional; + echo coverage=$(echo "$(jq -r '.totals.percent_covered' coverage_functional.json) " | awk '{printf "%.4f%%", $1"%"}') > $GITHUB_OUTPUT + echo branch_coverage=$(echo "$(jq -r '.totals.covered_branches' coverage_functional.json) $(jq -r '.totals.num_branches' coverage_functional.json)" | awk '{covered=$1; total=$2; printf "%.4f%%", (covered/total*100)"%"}') >> $GITHUB_OUTPUT + + + - name: Trace + run: | + echo "PWD is [${PWD}]"; + ls -laR + + + - name: Upload Test Report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: functional-test-results-${{ matrix.python-version }} + path: functional.JUnit.xml + + + - name: Upload Coverage Report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: functional-coverage-report-${{ matrix.python-version }} + path: functional-coverage.xml + + + # - name: Upload Code Coverage + # if: >- + # ( + # github.event_name != 'pull_request' + # || github.event.pull_request.head.repo.full_name == github.repository + # ) + # && + # matrix.python-version == inputs.PYTHON_VERSION + # uses: actions/upload-code-coverage@bfa741d815a28cb064a8e3a0837e577457a017d5 # v1.4.3 + # with: + # file: functional-coverage.xml + # language: Python + # label: Unit-${{ matrix.python-version }} + + + - name: Upload Coverage Report (json) + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: functional-coverage-report-json-${{ matrix.python-version }} + path: coverage_functional.json + + + - name: Upload Coverage + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: functional-coverage-${{ matrix.python-version }} + path: coverage/functional/* + + - name: Upload Functional Coverage (rc) + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: coverage-rc-functional-${{ matrix.python-version }} + path: .coverage + include-hidden-files: true + + - name: Upload any logs + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: functional-test-centurion-logs-${{ matrix.python-version }} + path: log/* + include-hidden-files: true + + - name: log file check + run: | + ls -la log/ || true; + ls -la app/log/ || true; + + + combines_report: + name: Create Combined Test Reports + needs: + - init + # - unit-test + - report + # - functional-test + - functional-report + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: ${{ fromJson(needs.init.outputs.matrix_python_versions) }} + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: ${{ matrix.python-version }} + + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements_dev.txt + + + - name: Trace 'ls -la' + shell: bash + run: | + ls -la; + + + - name: Download Unit Test Report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + if: success() || failure() + with: + name: coverage-rc-unit-${{ matrix.python-version }} + + + - name: Rename Unit Test Report + shell: bash + run: | + ls -la; + mv .coverage .coverage.unit; + + + - name: Download Functional Test Report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + if: success() || failure() + with: + name: coverage-rc-functional-${{ matrix.python-version }} + + + - name: Rename Functional Test Report + shell: bash + run: | + ls -la; + mv .coverage .coverage.functional; + + + - name: Trace 'ls -la' + shell: bash + run: | + ls -la; + + + - name: Combine Reports + shell: bash + run: | + coverage combine; + + + - name: Trace 'ls -la' + shell: bash + run: | + ls -la; + + + - name: Create Combined Report - HTML + shell: bash + run: | + mkdir -p artifacts/combined-coverage-report-html; + coverage html -d artifacts/html; + + + - name: Create Combined Report - XML + shell: bash + run: | + coverage xml -o artifacts/combined-coverage.xml; + + + # - name: Upload Code Coverage + # if: >- + # ( + # github.event_name != 'pull_request' + # || github.event.pull_request.head.repo.full_name == github.repository + # ) + # && + # matrix.python-version == inputs.PYTHON_VERSION + # uses: actions/upload-code-coverage@bfa741d815a28cb064a8e3a0837e577457a017d5 # v1.4.3 + # with: + # file: artifacts/combined-coverage.xml; + # language: Python + # label: Combined Coverage + + + - name: Create Combined Report - json + shell: bash + run: | + coverage json -o artifacts/combined-coverage.json; + + + - name: keep combine artifact + shell: bash + run: | + mkdir -p artifacts/coverage/combined; + mv .coverage artifacts/coverage/combined/ || true; + + + - name: Code Coverage Report + uses: irongut/CodeCoverageSummary@v1.3.0 + # if: >- + # matrix.python-version == inputs.PYTHON_VERSION + with: + filename: artifacts/combined-coverage.xml + badge: true + fail_below_min: true + format: markdown + hide_branch_rate: false + hide_complexity: false + indicators: true + output: both + thresholds: '60 85' + + + - name: keep combine artifact + shell: bash + # if: >- + # matrix.python-version == inputs.PYTHON_VERSION + run: | + mkdir -p artifacts/coverage/combined; + mv code-coverage-results.md artifacts/coverage/code-coverage-combined-results.md; + + + - name: create status check/comment for code coverage results + id: jest_coverage_check + uses: im-open/process-code-coverage-summary@e2984f897702d68619d358a834d80a74aa0d9840 # v2.3.1 + # if: >- + # ( + # success() || failure() + # ) + # && + # github.event_name != 'pull_request' + # && + # matrix.python-version == inputs.PYTHON_VERSION + if: >- + ( + success() || failure() + ) + && + github.event_name != 'pull_request' + with: + github-token: ${{ github.token }} + summary-file: artifacts/coverage/code-coverage-combined-results.md + check-name: 'Combined Code Coverage ${{ matrix.python-version }}' + create-pr-comment: true + update-comment-if-one-exists: true + update-comment-key: "${{ env.GITHUB-JOB }}_${{ env.GITHUB-ACTION }}" + + + - name: Obtain coverage data + id: coverage-combined + # if: >- + # matrix.python-version == inputs.PYTHON_VERSION + shell: bash + run: | + echo coverage=$(echo "$(jq -r '.totals.percent_covered' artifacts/combined-coverage.json) " | awk '{printf "%.4f%%", $1"%"}') > $GITHUB_OUTPUT + echo branch_coverage=$(echo "$(jq -r '.totals.covered_branches' artifacts/combined-coverage.json) $(jq -r '.totals.num_branches' artifacts/combined-coverage.json)" | awk '{covered=$1; total=$2; printf "%.4f%%", (covered/total*100)"%"}') >> $GITHUB_OUTPUT + + + + - name: Download Unit Test Stats json + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 # v7.0.1 + # if: success() || failure() + with: + name: unit-test-stats-${{ matrix.python-version }} + + + + - name: Download Functional Test Stats json + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + # if: success() || failure() + with: + name: functional-test-stats-${{ matrix.python-version }} + + + - name: Obtain coverage data + id: stats-combined + # if: >- + # matrix.python-version == inputs.PYTHON_VERSION + shell: bash + run: | + echo sudo apt update; + echo sudo apt install -y jq; + ls -la; + echo '*******'; + cat test_stats_unit.json; + echo '*******'; + cat test_stats_functional.json; + echo '*******'; + echo $(jq -r '.passed // 0' test_stats_unit.json); + echo '*******'; + echo $(jq -r '.passed // 0' test_stats_functional.json); + echo '*******'; + echo "passed=$(($(jq -r '.passed // 0' test_stats_unit.json) + $(jq -r '.passed // 0' test_stats_functional.json)))" >> $GITHUB_OUTPUT + echo "skipped=$(($(jq -r '.skipped // 0' test_stats_unit.json) + $(jq -r '.skipped // 0' test_stats_functional.json)))" >> $GITHUB_OUTPUT + echo "failed=$(($(jq -r '.failed // 0' test_stats_unit.json) + $(jq -r '.failed // 0' test_stats_functional.json)))" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT; + + + + - name: Create Shields.io Endpoint.json + # if: success() || failure() + shell: bash + run: | + echo ' + { + "schemaVersion": 1, + "label": "Combined Tests", + "message": "${{ steps.stats-combined.outputs.passed }} passed | ${{ steps.stats-combined.outputs.skipped }} skipped | ${{ steps.stats-combined.outputs.failed }} failed", + "logoSvg": "python-logo", + "color": "#4584b6", + "style": "plastic" + }' > artifacts/endpoint_combined_stats.json + + + + + - name: Create Shields.io Endpoint.json for coverage + # if: >- + # ( + # success() || failure() + # ) + # && + # matrix.python-version == inputs.PYTHON_VERSION + shell: bash + run: | + echo "[Debug] ****************************"; + + echo "[Debug] PWD[${PWD}]"; + + echo "[Debug] **************************** - create file"; + + echo ' + { + "schemaVersion": 1, + "label": "Combined Code Coverage", + "message": "${{ steps.coverage-combined.outputs.coverage }} Line | ${{ steps.coverage-combined.outputs.branch_coverage }} Branch", + "logoSvg": "python-logo", + "color": "#4584b6", + "style": "plastic" + }' > artifacts/badge_endpoint_coverage_combined.json; + + echo "[Debug] **************************** cat artifacts/badge_endpoint_coverage_combined.json"; + + + - name: Upload Combined Test results artifacts + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: coverage-combined-unit-function-html-${{ matrix.python-version }} + path: artifacts/* + include-hidden-files: true + + + + + + ################################################################################################################################ + # + # Future Plan: + # + # with command: `git diff --name-only $(git rev-parse feature-next-release) HEAD` + # to get a list of files to create a coverage html report with just the changed files. + # + ################################################################################################################################ + + + + + + + + + + + + + + + + + + # should only run on dev/master and tag + report: + name: Create Test Reports + needs: + - init + - unit-test + if: >- + github.event_name != 'schedule' + && + github.event_name != 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: read + actions: read + checks: write + strategy: + max-parallel: 4 + matrix: + python-version: ${{ fromJson(needs.init.outputs.matrix_python_versions) }} + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + + - name: Trace 'ls -la' + shell: bash + run: | + ls -la; + + + - name: Download Test Report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + if: success() || failure() + with: + name: unit-test-results-${{ matrix.python-version }} + + + - name: Trace 'ls -la' + shell: bash + run: | + ls -la; + + + - name: Test Report + if: success() || failure() + # uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 + uses: dorny/test-reporter@79b4b4400dc2354b89e9dd811ef9caa9bdd4f665 # main fix http errors see: https://github.com/dorny/test-reporter/pull/867 + id: test-report + with: + # artifact: unit-test-results-${{ matrix.python-version }} + name: Unit Test Report [Python ${{ matrix.python-version }}] + path: '*.xml' + reporter: java-junit + use-actions-summary: false + + + - name: Trace 'ls -la' + if: success() || failure() + shell: bash + run: | + ls -la; + + + - name: Create Test Stats + if: success() || failure() + shell: bash + run: | + echo ' + { + "passed": ${{ steps.test-report.outputs.passed }}, + "skipped": ${{ steps.test-report.outputs.skipped }}, + "failed": ${{ steps.test-report.outputs.failed }} + } + ' > test_stats_unit.json; + + + - name: Upload Test Stats json + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: unit-test-stats-${{ matrix.python-version }} + path: test_stats_unit.json + + + - name: Create Shields.io Endpoint.json + if: success() || failure() + shell: bash + run: | + echo ' + { + "schemaVersion": 1, + "label": "Unit Test", + "message": "${{ steps.test-report.outputs.passed }} passed | ${{ steps.test-report.outputs.skipped }} skipped | ${{ steps.test-report.outputs.failed }} failed", + "logoSvg": "python-logo", + "color": "#4584b6", + "style": "plastic" + }' > endpoint_${{ matrix.python-version }}.json + + + - name: Upload Badge Endpoint json + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: unit-test-shield-endpoint-${{ matrix.python-version }} + path: endpoint_${{ matrix.python-version }}.json + + + # should only run on dev/master and tag + functional-report: + name: Create Test Reports (Functional) + needs: + - init + - functional-test + if: >- + github.event_name != 'schedule' + && + github.event_name != 'pull_request' + runs-on: ubuntu-latest + permissions: + contents: read + actions: read + checks: write + strategy: + max-parallel: 4 + matrix: + python-version: ${{ fromJson(needs.init.outputs.matrix_python_versions) }} + steps: + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + + - name: Trace 'ls -la' + shell: bash + run: | + ls -la; + + + - name: Download Test Report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + if: success() || failure() + with: + name: functional-test-results-${{ matrix.python-version }} + + + - name: Trace 'ls -la' + shell: bash + run: | + ls -la; + + + - name: Test Report + # uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 + uses: dorny/test-reporter@79b4b4400dc2354b89e9dd811ef9caa9bdd4f665 # main fix http errors see: https://github.com/dorny/test-reporter/pull/867 + id: test-report + with: + # artifact: functional-test-results-${{ matrix.python-version }} + name: Functional Test Report [Python ${{ matrix.python-version }}] + path: '*.xml' + reporter: java-junit + # fail-on-error: false + use-actions-summary: false + + + - name: Trace 'ls -la' + if: success() || failure() + shell: bash + run: | + ls -la; + + + - name: Create Test Stats + if: success() || failure() + shell: bash + run: | + echo ' + { + "passed": ${{ steps.test-report.outputs.passed }}, + "skipped": ${{ steps.test-report.outputs.skipped }}, + "failed": ${{ steps.test-report.outputs.failed }} + } + ' > test_stats_functional.json; + + + - name: Upload Test Stats json + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: functional-test-stats-${{ matrix.python-version }} + path: test_stats_functional.json + + + - name: Create Shields.io Endpoint.json + if: success() || failure() + shell: bash + run: | + echo ' + { + "schemaVersion": 1, + "label": "Functional Test", + "message": "${{ steps.test-report.outputs.passed }} passed | ${{ steps.test-report.outputs.skipped }} skipped | ${{ steps.test-report.outputs.failed }} failed", + "logoSvg": "python-logo", + "color": "#4584b6", + "style": "plastic" + }' > endpoint_functional_${{ matrix.python-version }}.json + + + - name: Upload Badge Endpoint json + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: functional-test-shield-endpoint-${{ matrix.python-version }} + path: endpoint_functional_${{ matrix.python-version }}.json + + + + coverage-report: + name: Create Coverage report + needs: + - unit-test + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [ "${{ inputs.PYTHON_VERSION }}" ] + steps: + + - name: Run Tests + shell: bash + run: | + ls -l; + + - name: Download Coverage Artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: coverage-report-${{ matrix.python-version }} + github-token: ${{ github.token }} + + - name: ls + shell: bash + if: success() || failure() + run: | + ls -l; + + - name: Code Coverage Report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: coverage.xml + badge: true + fail_below_min: true + format: markdown + hide_branch_rate: false + hide_complexity: false + indicators: true + output: both + thresholds: '60 85' + + + - name: ls + shell: bash + if: success() || failure() + run: | + ls -l; + + + - name: create status check/comment for code coverage results + id: jest_coverage_check + uses: im-open/process-code-coverage-summary@e2984f897702d68619d358a834d80a74aa0d9840 # v2.3.1 + if: >- + ( + success() || failure() + ) + && + github.event_name != 'pull_request' + with: + github-token: ${{ github.token }} + summary-file: code-coverage-results.md + check-name: 'Unit Code Coverage' + create-pr-comment: true + update-comment-if-one-exists: true + update-comment-key: "${{ env.GITHUB-JOB }}_${{ env.GITHUB-ACTION }}" + + - name: Upload Coverage Summary + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: code-coverage-results-${{ matrix.python-version }} + path: code-coverage-results.md + + + + coverage-report-functional: + name: Create Coverage report (Functional) + needs: + - functional-test + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [ "${{ inputs.PYTHON_VERSION }}" ] + steps: + + - name: Run Tests + shell: bash + run: | + ls -l; + + - name: Download Coverage Artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + if: success() || failure() + with: + name: functional-coverage-report-${{ matrix.python-version }} + github-token: ${{ github.token }} + + - name: ls + shell: bash + if: success() || failure() + run: | + ls -l; + + - name: Code Coverage Report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: functional-coverage.xml + badge: true + fail_below_min: true + format: markdown + hide_branch_rate: false + hide_complexity: false + indicators: true + output: both + thresholds: '60 85' + + + - name: ls + shell: bash + if: success() || failure() + run: | + ls -l; + + + - name: create status check/comment for code coverage results + id: jest_coverage_check + uses: im-open/process-code-coverage-summary@e2984f897702d68619d358a834d80a74aa0d9840 # v2.3.1 + if: >- + ( + success() || failure() + ) + && + github.event_name != 'pull_request' + with: + github-token: ${{ github.token }} + summary-file: code-coverage-results.md + check-name: 'Functional Code Coverage' + create-pr-comment: true + update-comment-if-one-exists: true + update-comment-key: "${{ env.GITHUB-JOB }}_${{ env.GITHUB-ACTION }}" + + - name: Upload Coverage Summary + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: success() || failure() + with: + name: functional-code-coverage-results-${{ matrix.python-version }} + path: code-coverage-results.md + + + + badge-endpoint: + name: Publish Badge endpoint files + if: >- + (github.ref_name == 'master' || github.ref_name == 'development' || github.ref_name == 'feat-next-release') + && + github.event_name != 'schedule' + && + github.repository == 'nofusscomputing/centurion_erp' + needs: + - unit-test + - report + strategy: + max-parallel: 4 + matrix: + python-version: [ "${{ inputs.PYTHON_VERSION }}" ] + runs-on: ubuntu-latest + steps: + + - name: Checkout Endpoint Repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: 'nofusscomputing/.github' + ref: 'master' + token: ${{ secrets.WORKFLOW_TOKEN }} + path: 'endpoint_publish' + fetch-depth: '1' + show-progress: true + submodules: false + + + - name: Create Publish Directories + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + cd endpoint_publish; + echo "[Debug] PWD[${PWD}]"; + mkdir -p repositories/${{ github.repository }}/${{ github.ref_name }}; + ls -la; + + + - name: Create Publish Directories + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + # cd repositories/${{ github.repository }}/${{ github.ref_name }}; + echo "[Debug] PWD[${PWD}]"; + + + - name: Download Badge Endpoint json + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: unit-test-shield-endpoint-${{ matrix.python-version }} + + + - name: Add endpoint file + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + + echo "[Debug] **************************** - cd endpoint_publish"; + + cd endpoint_publish; + + echo "[Debug] **************************** - ls -la"; + + ls -la + + echo "[Debug] ****************************"; + + echo "[Debug] PWD[${PWD}]"; + + echo "[Debug] **************************** - ls -la ../"; + + ls -la ../ + + echo "[Debug] **************************** - cp ../endpoint_${{ matrix.python-version }}.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_unit_test.json"; + + cp ../endpoint_${{ matrix.python-version }}.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_unit_test.json; + + echo "[Debug] **************************** - ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/"; + + ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/; + + + + - name: Create Shields.io Endpoint.json for coverage + if: success() || failure() + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + cd endpoint_publish; + echo "[Debug] ****************************"; + + echo "[Debug] PWD[${PWD}]"; + + echo "[Debug] **************************** - create file"; + + echo ' + { + "schemaVersion": 1, + "label": "Unit Test Coverage", + "message": "${{ needs.unit-test.outputs.unit-test-coverage }} Line | ${{ needs.unit-test.outputs.unit-test-branch_coverage }} Branch", + "logoSvg": "python-logo", + "color": "#4584b6", + "style": "plastic" + }' > repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_coverage.json; + + echo "[Debug] **************************** cat repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_coverage.json"; + + cat repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_coverage.json; + + + + - name: Configure git + shell: bash + run: | + git config --global user.email "helpdesk@nofusscomputing.com"; + git config --global user.name "nfc-bot"; + + + - name: Git add + id: git-add + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git status; + echo "[Debug] ****************************"; + + if [ "$(git status -s)" ]; then + + echo "changed=true" > $GITHUB_OUTPUT; + + echo "[Info] Changes need to be committed"; + + else + + echo "changed=false" > $GITHUB_OUTPUT; + + echo "[Info] NO changes to be committed"; + + fi + + echo "[Debug] ****************************"; + + git add . + + + - name: Git commit + if: ${{ steps.git-add.outputs.changed == 'true' }} + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git commit -m "chore: add badge endpount file ${{ github.repository }}/${{ github.ref_name }}" + + + - name: git push + if: ${{ steps.git-add.outputs.changed == 'true' }} + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git push + + + + badge-endpoint-functional: + name: Publish Badge endpoint files (Functional) + if: >- + (github.ref_name == 'master' || github.ref_name == 'development' || github.ref_name == 'feat-next-release') + && + github.event_name != 'schedule' + && + github.repository == 'nofusscomputing/centurion_erp' + needs: + - functional-test + - functional-report + strategy: + max-parallel: 4 + matrix: + python-version: [ "${{ inputs.PYTHON_VERSION }}" ] + runs-on: ubuntu-latest + steps: + + - name: Checkout Endpoint Repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: 'nofusscomputing/.github' + ref: 'master' + token: ${{ secrets.WORKFLOW_TOKEN }} + path: 'endpoint_publish' + fetch-depth: '1' + show-progress: true + submodules: false + + + - name: Create Publish Directories + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + cd endpoint_publish; + echo "[Debug] PWD[${PWD}]"; + mkdir -p repositories/${{ github.repository }}/${{ github.ref_name }}; + ls -la; + + + - name: Create Publish Directories + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + # cd repositories/${{ github.repository }}/${{ github.ref_name }}; + echo "[Debug] PWD[${PWD}]"; + + + - name: Download Badge Endpoint json + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: functional-test-shield-endpoint-${{ matrix.python-version }} + + + - name: Add endpoint file + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + + echo "[Debug] **************************** - cd endpoint_publish"; + + cd endpoint_publish; + + echo "[Debug] **************************** - ls -la"; + + ls -la + + echo "[Debug] ****************************"; + + echo "[Debug] PWD[${PWD}]"; + + echo "[Debug] **************************** - ls -la ../"; + + ls -la ../ + + echo "[Debug] **************************** - cp ../endpoint_functional_${{ matrix.python-version }}.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_functional_test.json"; + + cp ../endpoint_functional_${{ matrix.python-version }}.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_functional_test.json; + + echo "[Debug] **************************** - ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/"; + + ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/; + + + + - name: Create Shields.io Endpoint.json for coverage + if: success() || failure() + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + cd endpoint_publish; + echo "[Debug] ****************************"; + + echo "[Debug] PWD[${PWD}]"; + + echo "[Debug] **************************** - create file"; + + echo ' + { + "schemaVersion": 1, + "label": "Functional Test Coverage", + "message": "${{ needs.functional-test.outputs.functional-test-coverage }} Line | ${{ needs.functional-test.outputs.functional-test-branch_coverage }} Branch", + "logoSvg": "python-logo", + "color": "#4584b6", + "style": "plastic" + }' > repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_coverage_functional.json; + + echo "[Debug] **************************** cat repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_coverage_functional.json"; + + cat repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_coverage_functional.json; + + + + - name: Configure git + shell: bash + run: | + git config --global user.email "helpdesk@nofusscomputing.com"; + git config --global user.name "nfc-bot"; + + + - name: Git add + id: git-add + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git status; + echo "[Debug] ****************************"; + + if [ "$(git status -s)" ]; then + + echo "changed=true" > $GITHUB_OUTPUT; + + echo "[Info] Changes need to be committed"; + + else + + echo "changed=false" > $GITHUB_OUTPUT; + + echo "[Info] NO changes to be committed"; + + fi + + echo "[Debug] ****************************"; + + git add . + + + - name: Git commit + if: ${{ steps.git-add.outputs.changed == 'true' }} + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git commit -m "chore: add badge endpount file ${{ github.repository }}/${{ github.ref_name }}" + + + - name: git push + if: ${{ steps.git-add.outputs.changed == 'true' }} + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git push + + + + badge-endpoint-combined: + name: Publish Badge endpoint files (Combined) + if: >- + (github.ref_name == 'master' || github.ref_name == 'development' || github.ref_name == 'feat-next-release') + && + github.event_name != 'schedule' + && + github.repository == 'nofusscomputing/centurion_erp' + needs: + - combines_report + strategy: + max-parallel: 4 + matrix: + python-version: [ "${{ inputs.PYTHON_VERSION }}" ] + runs-on: ubuntu-latest + steps: + + - name: Checkout Endpoint Repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: 'nofusscomputing/.github' + ref: 'master' + token: ${{ secrets.WORKFLOW_TOKEN }} + path: 'endpoint_publish' + fetch-depth: '1' + show-progress: true + submodules: false + + + - name: Create Publish Directories + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + cd endpoint_publish; + echo "[Debug] PWD[${PWD}]"; + mkdir -p repositories/${{ github.repository }}/${{ github.ref_name }}; + ls -la; + + + # - name: Create Publish Directories + # shell: bash + # run: | + # echo "[Debug] PWD[${PWD}]"; + # # cd repositories/${{ github.repository }}/${{ github.ref_name }}; + # echo "[Debug] PWD[${PWD}]"; + + + - name: Download Badge Endpoint json + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: coverage-combined-unit-function-html-${{ matrix.python-version }} + + + - name: Add endpoint file + shell: bash + run: | + cd endpoint_publish; + ls -la; + cp ../badge_endpoint_coverage_combined.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_coverage_combined.json; + cp ../endpoint_combined_stats.json repositories/${{ github.repository }}/${{ github.ref_name }}/endpoint_combined_stats.json + echo "[Debug] **************************** - ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/"; + + ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/; + + + + + - name: Configure git + shell: bash + run: | + git config --global user.email "helpdesk@nofusscomputing.com"; + git config --global user.name "nfc-bot"; + + + - name: Git add + id: git-add + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git status; + echo "[Debug] ****************************"; + + if [ "$(git status -s)" ]; then + + echo "changed=true" > $GITHUB_OUTPUT; + + echo "[Info] Changes need to be committed"; + + else + + echo "changed=false" > $GITHUB_OUTPUT; + + echo "[Info] NO changes to be committed"; + + fi + + echo "[Debug] ****************************"; + + git add . + + + - name: Git commit + if: ${{ steps.git-add.outputs.changed == 'true' }} + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git commit -m "chore: add badge endpount file ${{ github.repository }}/${{ github.ref_name }}" + + + - name: git push + if: ${{ steps.git-add.outputs.changed == 'true' }} + shell: bash + run: | + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + cd endpoint_publish; + echo "[Debug] ****************************"; + ls -la + echo "[Debug] ****************************"; + echo "[Debug] PWD[${PWD}]"; + echo "[Debug] ****************************"; + git push + + + vulnerability-scan: + name: PIP file Scan (requirements.txt) + runs-on: ubuntu-latest + needs: + - init + permissions: + contents: read # Required to checkout and read repo files + security-events: write # Required to upload SARIF files to Security tab + strategy: + fail-fast: false + matrix: + requirements: ${{ fromJSON(needs.init.outputs.requirements_set) }} + steps: + + - name: Resolve branch + run: | + echo "BRANCH=${{ inputs.BRANCH || github.ref_name }}" >> $GITHUB_ENV + + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + if: github.event_name == 'schedule' + with: + ref: ${{ env.BRANCH }} + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + if: github.event_name != 'schedule' + + + - name: Run Trivy vulnerability scanner against ${{ matrix.requirements }} + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + with: + scan-type: 'fs' + ignore-unfixed: false + format: 'sarif' + output: 'trivy-results.sarif' + severity: 'LOW,MEDIUM,HIGH,CRITICAL' + scan-ref: ${{ matrix.requirements }} + exit-code: 0 + + + - name: Upload ${{ matrix.requirements }} scan results to GitHub Security tab + if: github.event_name != 'pull_request' + uses: github/codeql-action/upload-sarif@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 + with: + sarif_file: 'trivy-results.sarif' + + + - name: Upload scan results ${{ matrix.requirements }} sarif Report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: python-scan-results-${{ matrix.requirements }}-sarif + path: trivy-results.sarif + + + + vulnerability-report: + name: Create Reports + needs: + - init + - vulnerability-scan + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + requirements: ${{ fromJSON(needs.init.outputs.requirements_set) }} + steps: + + + - name: Fetch scan results ${{ matrix.requirements }}(sarif Report) + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: python-scan-results-${{ matrix.requirements }}-sarif + + + - run: | + echo "${PWD}" || echo "couldnt PWD"; + + echo "1"; + + ls -la; + + echo "2"; + + mkdir -p ${{ runner.temp }}/_github_home/ || echo "could not make"; + + echo "2.1"; + + ls -la ${{ runner.temp }}/_github_home/; + + echo "3"; + + mv -f trivy-results.sarif ${{ runner.temp }}/_github_home/trivy-results.sarif; + + echo "4"; + + ls -la ${{ runner.temp }}/_github_home/; + + + + - name: Convert Sarif -> Markdown + if: success() || failure() + id: sarif-to-markdown + uses: 11notes/action-sarif-to-markdown@bc689850bd33a1037ea1d0a609ab4ea14b3c4396 # v1.2.0 + with: + sarif_file: trivy-results.sarif + + + - name: Print Report + run: echo '${{ steps.sarif-to-markdown.outputs.markdown }}'; + + + - name: Create Report Artifact + run: | + ls -la ${{ runner.temp }}/_github_home/sarif.md; + + echo "## PIP File Scan of \`${{ matrix.requirements }}\`" > vulnerability-report.md; + echo "" >> vulnerability-report.md; + echo ">[!tip]" >> vulnerability-report.md; + echo ">" >> vulnerability-report.md; + echo "> _If this report shows nothing, it means there was nothing found._" >> vulnerability-report.md; + echo "" >> vulnerability-report.md; + echo -n "#" >> vulnerability-report.md; + cat ${{ runner.temp }}/_github_home/sarif.md >> vulnerability-report.md; + + + - name: Upload scan results + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: python-vulnerability-report-${{ matrix.requirements }} + path: vulnerability-report.md + + + + pull-request-report-comment: + if: >- + github.ref_type != 'tag' + && + github.event_name != 'schedule' + && + github.event_name != 'pull_request' + needs: + - init + - vulnerability-scan + - vulnerability-report + runs-on: ubuntu-latest + name: Comment on Pull Request (Python Scan) + strategy: + fail-fast: false + matrix: + requirements: ${{ fromJSON(needs.init.outputs.requirements_set) }} + steps: + + + - name: Find Current Pull Request + uses: jwalton/gh-find-current-pr@f3d61b485d2801773f7a07b2aaa3306bd8f8e653 #v1.3.5 + id: finder + # with: + # sha: ${{ github.event.pull_request.head.sha }} + + - name: Create PR VAR + shell: bash + run: + if [ "0${{ steps.finder.outputs.pr }}" != "0" ]; then + + echo "FOUND_PR_NUM=${{ steps.finder.outputs.pr }}" >> $GITHUB_ENV; + + fi; + + if [ "${{ github.event_name }}" == "pull_request" ]; then + + echo "FOUND_PR_NUM=${{ github.event.pull_request.number }}" >> $GITHUB_ENV; + + fi + + + + - name: Fetch Vulnerability Report + if: ${{ env.FOUND_PR_NUM != '' }} + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # V8.0.1 + with: + name: python-vulnerability-report-${{ matrix.requirements }} + + + - name: Capture scan results + if: ${{ env.FOUND_PR_NUM != '' }} + run: | + content=$(cat vulnerability-report.md | head -c 65000) + echo "report<> $GITHUB_ENV + echo "$content" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + + - name: Comment scan results on PR + if: ${{ env.FOUND_PR_NUM != '' }} + uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 + with: + number: ${{ env.FOUND_PR_NUM }} + header: Python ${{ matrix.requirements }} Scan Results + message: | + ${{ env.report }} \ No newline at end of file diff --git a/README.md b/README.md index 4990dab..cb30912 100644 --- a/README.md +++ b/README.md @@ -1 +1,82 @@ -# No Fuss Computing - GH Action / Workflow for Python Projects \ No newline at end of file + + +# No Fuss Computing - GH Action / Workflow for Python Projects + +
+ +![Endpoint Badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fnofusscomputing%2Faction_python%2Frefs%2Fheads%2Fdevelopment%2F.centurion%2Fproject_status.json) + + + +---- + +
+ +![GitHub forks](https://img.shields.io/github/forks/nofusscomputing/action_python?logo=github&style=plastic&color=000000&labell=Forks) ![GitHub stars](https://img.shields.io/github/stars/nofusscomputing/action_python?color=000000&logo=github&style=plastic) ![Github Watchers](https://img.shields.io/github/watchers/nofusscomputing/action_python?color=000000&label=Watchers&logo=github&style=plastic) + + + +
+ +This project is hosted on our [Gitea](https://nofusscomputing.com/git/actions/python) instance and has a read-only copy hosted on [Github](https://nofusscomputing.com/git/nofusscomputing/action_python) + +---- + +**Stable Branch** + +---- + +**Development Branch** + +---- +
+ +
+ +links: + +- [Issues](https://nofusscomputing.com/git/actions/python/issues) + +- [Merge Requests (Pull Requests)](https://nofusscomputing.com/git/actions/python/pulls) + + +To use this workflow within your project add a file at path `.github/workflows/ci.yaml` or add the job to your existing CI file. + + +``` yaml + +--- + +name: 'CI' + +on: + push: + branches: + - '**' + tags: + - '*' + + +jobs: + + + python: + name: 'Python' + uses: nofusscomputing/action_python/.github/workflows/python.yaml@development + secrets: + WORKFLOW_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + +``` + + + +## Contributing + +All contributions for this project must be conducted from our [Gitea](https://nofusscomputing.com/git/pytest/simplified). + +For further details on contributing please refer to the [contribution guide](CONTRIBUTING.md). + + +## Other + +This repo is release under this [license](LICENSE)