diff --git a/.github/workflows/automerge-dependabot-prs-into-collected-branch.yml b/.github/workflows/automerge-dependabot-prs-into-collected-branch.yml index 6021872..72b997e 100644 --- a/.github/workflows/automerge-dependabot-prs-into-collected-branch.yml +++ b/.github/workflows/automerge-dependabot-prs-into-collected-branch.yml @@ -1,38 +1,71 @@ -# This script seperate major and minor but we do merge them into the same branch. -# Having two steps allows us to easily turn off major changes in future and then script them to their own branch and pipeline. -name: Auto-merge Dependabot PRs into collected branch +# qqqq in development +# this script seperate major and minor but we do merge them into the same branch. +# having two steps allows us to easily turn off major changes in future and then script them to their own branch and pipeline. +name: auto-merge dependabot prs into collected branch on: pull_request: types: [opened, synchronize] - branches: [Automatic_version_update_dependabot] # Make sure this matches your actual branch name + branches: [Automatic_version_update_dependabot] + permissions: contents: write pull-requests: write + checks: read jobs: + debug: + runs-on: ubuntu-latest + steps: + - name: debug info + run: | + echo "actor: ${{ github.actor }}" + echo "pr title: ${{ github.event.pull_request.title }}" + echo "github event_name: ${{ github.event_name }}" + echo "target branch: ${{ github.event.pull_request.base.ref }}" + echo "source branch: ${{ github.event.pull_request.head.ref }}" + echo "PR Number: ${{ github.event.pull_request.number }}" + + # Branch rules ensure doesnt auto merge if shouldnt auto-merge: runs-on: ubuntu-latest - if: github.actor == 'dependabot[bot]' + # qqqq add in after testing if: github.actor == 'dependabot[bot]' steps: - - name: Extract update type + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Set up GitHub CLI + run: | + # Install GitHub CLI (gh) + sudo apt-get update + sudo apt-get install gh + + - name: extract update type id: extract + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - PR_TITLE="${{ github.event.pull_request.title }}" - if [[ $PR_TITLE == *"(major)"* ]]; then + echo "get pr title" + pr_title="${{ github.event.pull_request.title }}" + echo "PR title: $pr_title" + if [[ "$pr_title" == *"(major)"* ]]; then echo "update_type=major" >> $GITHUB_OUTPUT + echo "Detected major update" else echo "update_type=minor_or_patch" >> $GITHUB_OUTPUT + echo "Detected minor or patch update" fi - - name: Auto-merge minor and patch updates + - name: auto-merge minor and patch updates if: steps.extract.outputs.update_type == 'minor_or_patch' - run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}" + run: | + gh pr merge --auto --merge "${{ github.event.pull_request.number }}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Auto-merge major updates + - name: auto-merge major updates if: steps.extract.outputs.update_type == 'major' - run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}" + run: | + gh pr merge --auto --merge "${{ github.event.pull_request.number }}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/automerge-dependabot-prs-into-collected-branch.yml-works-defunct b/.github/workflows/automerge-dependabot-prs-into-collected-branch.yml-works-defunct new file mode 100644 index 0000000..4f20747 --- /dev/null +++ b/.github/workflows/automerge-dependabot-prs-into-collected-branch.yml-works-defunct @@ -0,0 +1,99 @@ +# qqqq this does add auto merge but seems to trigger on the first set of checks git guardian (it seems), +# also it calls for checks not specifically for out branch +# so an approach based one the branch is likely better +name: auto-merge dependabot prs into collected branch +on: + # pull_request: + # synchronize + # types: [opened, synchronize] + # branches: [Automatic_version_update_dependabot] # make sure this matches your actual branch name + check_suite: + types: [completed] + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + checks: read + +jobs: + debug: + runs-on: ubuntu-latest + steps: + - name: debug info + run: | + echo "actor: ${{ github.actor }}" + echo "pr title: ${{ github.event.pull_request.title }}" + echo "github event_name: ${{ github.event_name }}" + echo "github event_suite conlusion: ${{ github.event.check_suite.conclusion }}" + echo "target branch: ${{ github.event.pull_request.base.ref }}" + echo "source branch: ${{ github.event.pull_request.head.ref }}" + echo "Check Suite ID: ${{ github.event.check_suite.id }}" + echo "Conclusion: ${{ github.event.check_suite.conclusion }}" + echo "Target Branch: ${{ github.event.check_suite.pull_requests[0].base.ref }}" + echo "PR Number: ${{ github.event.check_suite.pull_requests[0].number }}" + + - name: Dump event payload + run: | + echo "==== EVENT NAME ====" + echo "${{ github.event_name }}" + echo "==== RAW CHECK_SUITE PAYLOAD ====" + echo '${{ toJson(github.event.check_suite) }}' + echo "==== PRs in this check suite ====" + echo '${{ toJson(github.event.check_suite.pull_requests) }}' + + + auto-merge: + runs-on: ubuntu-latest + # if: github.event.check_suite.pull_requests[0].base.ref == 'main' + # if dependabot and checks ran + # if: (github.event_name != 'check_suite' || github.event.check_suite.conclusion == 'success') + # qqqq put back in later if: (github.actor == 'dependabot[bot]' || github.event_name == 'workflow_dispatch')&& (github.event_name != 'check_suite' || github.event.check_suite.conclusion == 'success') + + + # qqqq add in after testing && github.actor == 'dependabot[bot]' + if: github.event.check_suite.conclusion == 'success' && github.event.check_suite.pull_requests[0].base.ref == 'Automatic_version_update_dependabot' + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + + - name: Set up GitHub CLI + run: | + # Install GitHub CLI (gh) + sudo apt-get update + sudo apt-get install gh + + - name: extract update type + id: extract + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "get pr number" + pr_number=${{ github.event.check_suite.pull_requests[0].number }} + echo "PR title: $pr_number" + # pr_title="${{ github.event.pull_request.title }}" + pr_title=$(gh pr view "$pr_number" --json title --jq .title) + echo "PR title: $pr_title" + if [[ $pr_title == *"(major)"* ]]; then + echo "update_type=major" >> $GITHUB_OUTPUT + else + echo "update_type=minor_or_patch" >> $GITHUB_OUTPUT + fi + + - name: auto-merge minor and patch updates + if: steps.extract.outputs.update_type == 'minor_or_patch' + # auto should set the the request to merge once checks complete + # qqqq could squash for cleaner? --squash "${{ github.event.pull_request.html_url }}" + # run: gh pr merge --auto 1 + run: gh pr merge --auto --merge ${{ github.event.check_suite.pull_requests[0].number }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: auto-merge major updates + if: steps.extract.outputs.update_type == 'major' + # auto should set the the request to merge once checks complete + # qqqq could squash for cleaner? --squash "${{ github.event.pull_request.html_url }}" + # run: gh pr merge --auto 1 + run: gh pr merge --auto --merge ${{ github.event.check_suite.pull_requests[0].number }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/collected-dependabot-staging-to-master.yml b/.github/workflows/collected-dependabot-staging-to-master.yml-disabled similarity index 94% rename from .github/workflows/collected-dependabot-staging-to-master.yml rename to .github/workflows/collected-dependabot-staging-to-master.yml-disabled index 822ba31..5a1332e 100644 --- a/.github/workflows/collected-dependabot-staging-to-master.yml +++ b/.github/workflows/collected-dependabot-staging-to-master.yml-disabled @@ -1,3 +1,4 @@ +# qqqq in development name: Collected Dependabot Promotion From Staging To Master on: schedule: @@ -22,7 +23,7 @@ jobs: id: changes run: | git fetch origin Automatic_collected_dependabot_staging:Automatic_collected_dependabot_staging - git fetch origin master:master # or main/master - whatever your prod branch is + git fetch origin master:master if git diff --quiet master Automatic_collected_dependabot_staging; then echo "has_changes=false" >> $GITHUB_OUTPUT diff --git a/.github/workflows/collected-dependabot-to-staging.yml b/.github/workflows/collected-dependabot-to-staging.yml-disabled similarity index 98% rename from .github/workflows/collected-dependabot-to-staging.yml rename to .github/workflows/collected-dependabot-to-staging.yml-disabled index 4306f22..b3dba35 100644 --- a/.github/workflows/collected-dependabot-to-staging.yml +++ b/.github/workflows/collected-dependabot-to-staging.yml-disabled @@ -1,3 +1,5 @@ +# qqqq in development + name: Dependabot Collected Promotion To Staging # this logic will require branch ruleset checks of running the dev pipeline on: diff --git a/.github/workflows/reuseable-ci-checks.yml b/.github/workflows/reuseable-ci-checks.yml index 172443c..9523b66 100644 --- a/.github/workflows/reuseable-ci-checks.yml +++ b/.github/workflows/reuseable-ci-checks.yml @@ -340,7 +340,9 @@ jobs: # Echo the entire artifact list for debugging purposes echo "Artifact List: $ARTIFACT_LIST" - ARTIFACT_URL=$(echo "$ARTIFACT_LIST" | jq -r '.artifacts[] | select(.name=="coverage-report") | .url') + #qqqq worked mostly ARTIFACT_URL=$(echo "$ARTIFACT_LIST" | jq -r '.artifacts[] | select(.name=="coverage-report") | .url') + ARTIFACT_URL=$(echo "$ARTIFACT_LIST" | jq -r '.artifacts | map(select(.name=="coverage-report")) | sort_by(.created_at) | last | .url') + # Echo the artifact URL to confirm echo "Artifact URL: $ARTIFACT_URL" diff --git a/.github/workflows/workflow-readme.md b/.github/workflows/workflow-readme.md index e008223..f26f5c6 100644 --- a/.github/workflows/workflow-readme.md +++ b/.github/workflows/workflow-readme.md @@ -85,64 +85,41 @@ The individual steps also automatically pass so can see if any error at the end - autoverging is being tried for major and minor - branch checks must pass for merge on automated_version - checks required but overrideable for all workflows +- dependabot secret names to match repos ones where need to share +- dependabot not need to build package later brnch does + +## Dependabot Pipeline (AI generatated diag) + +```mermaid +flowchart TD + %% Dependabot PR to initial branch + A[Dependabot PR] --> B[Automatic_version_update_dependabot] + + %% Checks on the dependabot branch + B --> C[Run Checks] + C --> C1[Commit name check ❌ skipped] + C --> C2[Branch name check ❌ skipped] + C --> C3[Build as release] + C --> C4[Unit tests] + C --> C5[E2E tests] + + %% Weekly merge to staging + B -->|Weekly merge via collected-dependabot-to-staging.yml| D[Automatic_collected_dependabot_staging] + + %% Staging checks and dev build + D --> E[Run Checks & Dev Build] + E --> E1[Checks again] + E --> E2[Build dev package] + E --> E3[Showcase dev page] + + %% Weekly merge to master + D -->|Weekly merge via collected-dependabot-staging-to-master.yml| F[Master] +``` + ## Versioning Via semantic release and recorded as a generate c# file used by a blazor component ## Alternative Approaches -``` -name: Pull Request Checks - -# ⚠️ pull_request_target is dangerous it allows secrets to be used by forks and bots, ⚠️ -# ⚠️ we want dependabot only to be using these secrets so addition logic requires an "if" for every job ⚠️ -# We will restrict it by making pull_request_target only for the Automatic_version_update_dependabot and then use -# an if to ensure its only by dependabot - -on: - pull_request: - branches: ['**'] # Run on all branches - branches-ignore: ['dependabot/**'] # Skip Dependabot PRs - pull_request_target: - branches: ['Automatic_version_update_dependabot'] # Base branch for Dependabot PRs - workflow_dispatch: - -jobs: - dummy: - if: | - (github.actor == 'dependabot[bot]' && - startsWith(github.head_ref, 'dependabot/') && - github.event_name == 'pull_request_target') - || - (github.actor != 'dependabot[bot]' && github.event_name == 'pull_request') - runs-on: ubuntu-latest - steps: - - name: Dummy Step - run: echo "This is a dummy job to allow workflow_dispatch" - - pull-request-call-reusable-ci-checks-workflow: - if: | - (github.actor == 'dependabot[bot]' && - startsWith(github.head_ref, 'dependabot/') && - github.event_name == 'pull_request_target') - || - (github.actor != 'dependabot[bot]' && github.event_name == 'pull_request') - name: Pull Request run CI Checks - uses: ./.github/workflows/reuseable-ci-checks.yml - needs: dummy - with: - runall: true - - # could try secrets:inherit QQQQ - secrets: - UNITTESTS_APPSETTINGS_DEVELOPMENT: ${{ secrets.UNITTESTS_APPSETTINGS_DEVELOPMENT }} - WASMSTATICCLIENT_APPSETTINGS_DEVELOPMENT: ${{ secrets.WASMSTATICCLIENT_APPSETTINGS_DEVELOPMENT }} - WASMSERVERHOSTCLIENT_APPSETTINGS_DEVELOPMENT: ${{ secrets.WASMSERVERHOSTCLIENT_APPSETTINGS_DEVELOPMENT }} - WASMSERVERHOST_APPSETTINGS_DEVELOPMENT: ${{ secrets.WASMSERVERHOST_APPSETTINGS_DEVELOPMENT }} - TEL_GIT_PACKAGES_TOKEN: ${{secrets.NUGETKEY }} - - UNITTESTS_APPSETTINGS_PRODUCTION: ${{ secrets.UNITTESTS_APPSETTINGS_PRODUCTION }} - WASMSTATICCLIENT_APPSETTINGS_PRODUCTION: ${{ secrets.WASMSTATICCLIENT_APPSETTINGS_PRODUCTION }} - WASMSERVERHOSTCLIENT_APPSETTINGS_PRODUCTION: ${{ secrets.WASMSERVERHOSTCLIENT_APPSETTINGS_PRODUCTION }} - WASMSERVERHOST_APPSETTINGS_PRODUCTION: ${{ secrets.WASMSERVERHOST_APPSETTINGS_PRODUCTION }} - -``` +- dont use pull-request-target for security reasons if can avoid it and if do use ifs to control it based on what branch and who is calling the workflow +- can use secrets inherits might have been better for reuseable checks which because triggered by other workflows can directly access repo secrets instead need them passing diff --git a/.gitignore b/.gitignore index fad9453..ca74745 100644 --- a/.gitignore +++ b/.gitignore @@ -237,3 +237,4 @@ TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/Logs/* # Generated version info files TELBlazor.Components/TELBlazorPackageVersion/VersionInfo*.cs /.github/workflows/test.yml +/Optimisation Notes.md diff --git a/README.md b/README.md index 404d9b3..4ec4215 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ the ability to produce static prerendered html. The prerendered html is written - **Node.js 18+** and npm - **Git** configured with your credentials - **PowerShell 5.1+** +- **Longfile names enabled on the system** > ⚠️ **Important:** All commands in this guide require **PowerShell running as Administrator** ### Quick Setup ⚡ @@ -116,6 +117,10 @@ The project should now work. See other sections for what projects to run, and co > ⚠️ read the contribution section before creating a branch or commits ⚠️ +### Trouble Shooting +- Longpaths may be required if E2E Client is not building. + - Follow [microsoft docs](https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry) + - or Win + R -> type regedit -> path to the option HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem -> set LongPathsEnabled to 1 ### Getting Started with the Project following Setup