pipecraft 0.0.0-releaseit → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +126 -108
  2. package/dist/cli/index.d.ts +69 -0
  3. package/dist/cli/index.d.ts.map +1 -1
  4. package/dist/cli/index.js +94 -22
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/generators/init.tpl.d.ts +70 -0
  7. package/dist/generators/init.tpl.d.ts.map +1 -1
  8. package/dist/generators/init.tpl.js +100 -8
  9. package/dist/generators/init.tpl.js.map +1 -1
  10. package/dist/generators/workflows.tpl.d.ts +86 -0
  11. package/dist/generators/workflows.tpl.d.ts.map +1 -1
  12. package/dist/generators/workflows.tpl.js +101 -9
  13. package/dist/generators/workflows.tpl.js.map +1 -1
  14. package/dist/templates/actions/calculate-version.yml.tpl.d.ts +47 -0
  15. package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
  16. package/dist/templates/actions/calculate-version.yml.tpl.js +72 -3
  17. package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
  18. package/dist/templates/actions/create-pr.yml.tpl.d.ts +14 -0
  19. package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
  20. package/dist/templates/actions/create-pr.yml.tpl.js +22 -2
  21. package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
  22. package/dist/templates/actions/create-release.yml.tpl.d.ts +18 -0
  23. package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -0
  24. package/dist/templates/actions/create-release.yml.tpl.js +141 -0
  25. package/dist/templates/actions/create-release.yml.tpl.js.map +1 -0
  26. package/dist/templates/actions/create-tag.yml.tpl.d.ts +14 -0
  27. package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
  28. package/dist/templates/actions/create-tag.yml.tpl.js +22 -2
  29. package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
  30. package/dist/templates/actions/detect-changes.yml.tpl.d.ts +70 -0
  31. package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
  32. package/dist/templates/actions/detect-changes.yml.tpl.js +98 -2
  33. package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
  34. package/dist/templates/actions/manage-branch.yml.tpl.d.ts +14 -0
  35. package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
  36. package/dist/templates/actions/manage-branch.yml.tpl.js +22 -2
  37. package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
  38. package/dist/templates/actions/promote-branch.yml.tpl.d.ts +14 -0
  39. package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
  40. package/dist/templates/actions/promote-branch.yml.tpl.js +50 -7
  41. package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
  42. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +114 -1
  43. package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -1
  44. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +479 -74
  45. package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -1
  46. package/dist/types/index.d.ts +231 -8
  47. package/dist/types/index.d.ts.map +1 -1
  48. package/dist/types/index.js +9 -0
  49. package/dist/types/index.js.map +1 -1
  50. package/dist/utils/ast-path-operations.d.ts.map +1 -1
  51. package/dist/utils/ast-path-operations.js +24 -11
  52. package/dist/utils/ast-path-operations.js.map +1 -1
  53. package/dist/utils/config.d.ts +63 -0
  54. package/dist/utils/config.d.ts.map +1 -1
  55. package/dist/utils/config.js +71 -0
  56. package/dist/utils/config.js.map +1 -1
  57. package/dist/utils/github-setup.d.ts +323 -2
  58. package/dist/utils/github-setup.d.ts.map +1 -1
  59. package/dist/utils/github-setup.js +551 -23
  60. package/dist/utils/github-setup.js.map +1 -1
  61. package/dist/utils/idempotency.d.ts +147 -7
  62. package/dist/utils/idempotency.d.ts.map +1 -1
  63. package/dist/utils/idempotency.js +143 -15
  64. package/dist/utils/idempotency.js.map +1 -1
  65. package/dist/utils/logger.d.ts +134 -0
  66. package/dist/utils/logger.d.ts.map +1 -0
  67. package/dist/utils/logger.js +153 -0
  68. package/dist/utils/logger.js.map +1 -0
  69. package/dist/utils/preflight.d.ts +223 -12
  70. package/dist/utils/preflight.d.ts.map +1 -1
  71. package/dist/utils/preflight.js +216 -16
  72. package/dist/utils/preflight.js.map +1 -1
  73. package/dist/utils/versioning.d.ts +160 -8
  74. package/dist/utils/versioning.d.ts.map +1 -1
  75. package/dist/utils/versioning.js +179 -15
  76. package/dist/utils/versioning.js.map +1 -1
  77. package/package.json +26 -5
  78. package/.claude/settings.local.json +0 -35
  79. package/.github/actions/calculate-version/action.yml +0 -106
  80. package/.github/actions/create-pr/action.yml +0 -122
  81. package/.github/actions/create-release/action.yml +0 -74
  82. package/.github/actions/create-tag/action.yml +0 -94
  83. package/.github/actions/detect-changes/action.yml +0 -62
  84. package/.github/actions/manage-branch/action.yml +0 -113
  85. package/.github/actions/promote-branch/action.yml +0 -352
  86. package/.github/example/workflows/job.analyze.code.yml +0 -26
  87. package/.github/example/workflows/job.analyze.docker.yml +0 -32
  88. package/.github/example/workflows/job.app.api.deploy.yml +0 -127
  89. package/.github/example/workflows/job.app.api.test.yml +0 -102
  90. package/.github/example/workflows/job.app.docs.deploy.yml +0 -40
  91. package/.github/example/workflows/job.app.docs.test.yml +0 -50
  92. package/.github/example/workflows/job.app.web.deploy.yml +0 -96
  93. package/.github/example/workflows/job.app.web.test.yml +0 -49
  94. package/.github/example/workflows/job.changes.yml +0 -82
  95. package/.github/example/workflows/job.create-pr.yml +0 -96
  96. package/.github/example/workflows/job.env-check.yml +0 -43
  97. package/.github/example/workflows/job.fast-forward.yml +0 -103
  98. package/.github/example/workflows/job.lint.yml +0 -64
  99. package/.github/example/workflows/job.pr-name.yml +0 -70
  100. package/.github/example/workflows/job.pr-squash-name.yml +0 -27
  101. package/.github/example/workflows/job.tag.yml +0 -38
  102. package/.github/example/workflows/job.version.yml +0 -99
  103. package/.github/example/workflows/lib.plugin-base.publish.yml +0 -59
  104. package/.github/example/workflows/pipe.yml +0 -178
  105. package/.github/example/workflows/scripts/fastforward.sh +0 -51
  106. package/.github/example/workflows/scripts/pipe-cleaner.sh +0 -70
  107. package/.github/scripts/fastforward.sh +0 -51
  108. package/.github/scripts/pipe-cleaner.sh +0 -70
  109. package/.github/workflows/pipeline.yml +0 -220
  110. package/.github/workflows/pr-title-check.yml +0 -70
  111. package/.github/workflows/publish.yml +0 -39
  112. package/.pipecraftrc.json +0 -78
  113. package/.release-it.cjs +0 -71
  114. package/PIPELINE_TESTING_PLAN.md +0 -499
  115. package/TRUNK_FLOW_PLAN.md +0 -401
  116. package/assets/logo_banner.png +0 -0
  117. package/assets/logo_banner.webp +0 -0
  118. package/docs/USER_JOURNEY_ERRORS.md +0 -352
  119. package/eslint.config.js +0 -77
  120. package/examples/basic-config.json +0 -41
  121. package/examples/monorepo-config.json +0 -49
  122. package/examples/usage.md +0 -289
  123. package/scripts/debug-workflows.sh +0 -339
  124. package/scripts/parse-pipeline.js +0 -29
  125. package/scripts/test-job-order.cjs +0 -140
  126. package/scripts/validate-pipeline.cjs +0 -379
  127. package/scripts/verify-job-order.sh +0 -30
  128. package/src/cli/index.ts +0 -414
  129. package/src/generators/init.tpl.ts +0 -126
  130. package/src/generators/workflows.tpl.ts +0 -80
  131. package/src/templates/actions/calculate-version.yml.tpl.ts +0 -124
  132. package/src/templates/actions/create-pr.yml.tpl.ts +0 -147
  133. package/src/templates/actions/create-tag.yml.tpl.ts +0 -112
  134. package/src/templates/actions/detect-changes.yml.tpl.ts +0 -87
  135. package/src/templates/actions/manage-branch.yml.tpl.ts +0 -132
  136. package/src/templates/actions/promote-branch.yml.tpl.ts +0 -364
  137. package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +0 -706
  138. package/src/types/index.ts +0 -64
  139. package/src/utils/README-ast-path-operations.md +0 -390
  140. package/src/utils/ast-path-operations.ts +0 -581
  141. package/src/utils/config.ts +0 -64
  142. package/src/utils/github-setup.ts +0 -558
  143. package/src/utils/idempotency.ts +0 -215
  144. package/src/utils/preflight.ts +0 -306
  145. package/src/utils/versioning.ts +0 -244
  146. package/tests/README.md +0 -229
  147. package/tests/TEST_STRUCTURE.md +0 -256
  148. package/tests/act/run-act-tests.sh +0 -345
  149. package/tests/debugging/debug-utils.ts +0 -538
  150. package/tests/debugging/debug-workflow.test.ts +0 -339
  151. package/tests/debugging/debug-workflows.sh +0 -339
  152. package/tests/debugging/iterative-debug.ts +0 -652
  153. package/tests/debugging/run-debug-tests.sh +0 -431
  154. package/tests/fixtures/basic-config.json +0 -51
  155. package/tests/fixtures/invalid-config.json +0 -9
  156. package/tests/fixtures/pipeline-generated.yml +0 -235
  157. package/tests/fixtures/pipeline-preserve-comments.yml +0 -245
  158. package/tests/fixtures/pipeline-user-modified.yml +0 -245
  159. package/tests/fixtures/test-config.json +0 -58
  160. package/tests/github-live/README.md +0 -250
  161. package/tests/github-local/JOB_WORKFLOW_TESTS.md +0 -296
  162. package/tests/github-local/README.md +0 -240
  163. package/tests/github-local/run-all-tests.sh +0 -422
  164. package/tests/github-local/test-job-workflows.sh +0 -631
  165. package/tests/github-local/test-pipeline-workflow.sh +0 -440
  166. package/tests/integration/generators.test.ts +0 -578
  167. package/tests/integration/path-based-template.test.ts +0 -510
  168. package/tests/integration/simple-path-based.test.ts +0 -415
  169. package/tests/setup.ts +0 -56
  170. package/tests/unit/ast-path-operations-extended.test.ts +0 -302
  171. package/tests/unit/cli.test.ts +0 -541
  172. package/tests/unit/config-extended.test.ts +0 -412
  173. package/tests/unit/config.test.ts +0 -152
  174. package/tests/unit/github-setup.test.ts +0 -189
  175. package/tests/unit/idempotency-isolated.test.ts +0 -297
  176. package/tests/unit/job-order.test.ts +0 -157
  177. package/tests/unit/pipeline-path-based.test.ts +0 -511
  178. package/tests/unit/validate-pipeline.test.ts +0 -384
  179. package/tests/unit/versioning-extended.test.ts +0 -279
  180. package/tests/unit/versioning.test.ts +0 -241
  181. package/tsconfig.debug.json +0 -17
  182. package/tsconfig.json +0 -28
  183. package/vitest.config.ts +0 -51
@@ -1,178 +0,0 @@
1
- name: Test and Deploy
2
-
3
- on:
4
- push:
5
- branches-ignore:
6
- - 'temp-*'
7
- workflow_dispatch:
8
- inputs:
9
- migration_input:
10
- description: 'Perform Migration'
11
- default: false
12
- required: true
13
- type: boolean
14
- seed_input:
15
- description: 'Perform Seed'
16
- default: false
17
- required: true
18
- type: boolean
19
-
20
-
21
- # Custom event type
22
- jobs:
23
-
24
- env-check:
25
- secrets: inherit
26
- uses: ./.github/workflows/job.env-check.yml
27
-
28
- debug-env:
29
- needs: [env-check]
30
- runs-on: ubuntu-latest
31
- steps:
32
- - name: Debug Environment Variables
33
- run: |
34
- echo "project_id: ${{ needs.env-check.outputs.project_id }}"
35
- echo "bucket: ${{ needs.env-check.outputs.bucket }}"
36
-
37
- # LINTING
38
- lint:
39
- secrets: inherit
40
- uses: ./.github/workflows/job.lint.yml
41
-
42
- # CHANGE DETECTION
43
- changes:
44
- secrets: inherit
45
- uses: ./.github/workflows/job.changes.yml
46
-
47
- # # SECURITY
48
- code-analyze:
49
- needs: [changes]
50
- secrets: inherit
51
- uses: ./.github/workflows/job.analyze.code.yml
52
-
53
- docker-analyze:
54
- needs: [changes]
55
- secrets: inherit
56
- uses: ./.github/workflows/job.analyze.docker.yml
57
-
58
- # TESTING
59
- api-test:
60
- needs: [changes, lint]
61
- if: ${{ needs.changes.outputs.api == 'true' }}
62
- secrets: inherit
63
- uses: ./.github/workflows/job.app.api.test.yml
64
-
65
- web-test:
66
- needs: [changes, lint]
67
- if: ${{ needs.changes.outputs.web == 'true' }}
68
- secrets: inherit
69
- uses: ./.github/workflows/job.app.web.test.yml
70
-
71
- docs-test:
72
- needs: [changes, lint]
73
- # Needs to be run even when updates are only to the website
74
- # Could be updated, using rsync to just target the docs directory in GCS
75
- if: ${{ needs.changes.outputs.docs == 'true' || needs.changes.outputs.web == 'true' }}
76
- secrets: inherit
77
- uses: ./.github/workflows/job.app.docs.test.yml
78
-
79
-
80
- # VERSIONING
81
- versioning:
82
- needs: [api-test, web-test, docs-test, docker-analyze, code-analyze, changes, lint]
83
- # allows the versioning job to run even if api-test or web-test is skipped
84
- if:
85
- ${{
86
- always() && (
87
- (
88
- needs.api-test.result == 'success' ||
89
- needs.web-test.result == 'success' ||
90
- needs.docs-test.result == 'success' ||
91
- needs.changes.outputs.cicd == 'true'
92
- ) && (
93
- needs.api-test.result != 'failure' &&
94
- needs.web-test.result != 'failure' &&
95
- needs.docs-test.result != 'failure' &&
96
- needs.lint.result != 'failure'
97
- )
98
- ) || (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/test' || github.ref == 'refs/heads/main') }}
99
- secrets: inherit
100
- uses: ./.github/workflows/job.version.yml
101
-
102
-
103
-
104
- # DEPLOYMENTS
105
- api-deploy:
106
- needs: [versioning, changes, env-check]
107
- if: ${{
108
- always() &&
109
- needs.changes.outputs.api == 'true' &&
110
- needs.versioning.outputs.version != '' && (
111
- github.ref == 'refs/heads/develop' ||
112
- github.ref == 'refs/heads/test' ||
113
- github.ref == 'refs/heads/main'
114
- ) }}
115
- secrets: inherit
116
- uses: ./.github/workflows/job.app.api.deploy.yml
117
- with:
118
- version: ${{ needs.versioning.outputs.version }}
119
- project_id: ${{ needs.env-check.outputs.project_id }}
120
-
121
- docs-deploy:
122
- needs: [versioning, changes]
123
- # Disabled and rolled into web-deploy
124
- if: ${{ !always() && (needs.changes.outputs.docs == 'true') && needs.versioning.outputs.version != '' && github.ref == 'refs/heads/main' }}
125
- secrets: inherit
126
- uses: ./.github/workflows/job.app.docs.deploy.yml
127
- with:
128
- version: ${{ needs.versioning.outputs.version }}
129
-
130
- web-deploy:
131
- needs: [versioning, changes, env-check]
132
- if:
133
- ${{
134
- always() && (
135
- needs.changes.outputs.web == 'true' ||
136
- needs.changes.outputs.docs == 'true'
137
- ) && needs.versioning.outputs.version != '' && (
138
- github.ref == 'refs/heads/develop' ||
139
- github.ref == 'refs/heads/test' ||
140
- github.ref == 'refs/heads/main'
141
- ) }}
142
- secrets: inherit
143
- uses: ./.github/workflows/job.app.web.deploy.yml
144
- with:
145
- project_id: ${{ needs.env-check.outputs.project_id }}
146
- bucket: ${{ needs.env-check.outputs.bucket }}
147
-
148
- create-pr:
149
- needs: [api-deploy, web-deploy, docs-deploy, versioning]
150
- # runs if any of the deployments are successful and non-failure
151
- # and the version is not empty
152
- # and the branch is develop or test
153
- if:
154
- ${{
155
- always() && (
156
- (
157
- needs.api-deploy.result == 'success' ||
158
- needs.web-deploy.result == 'success' ||
159
- needs.docs-deploy.result == 'success' ||
160
- needs.versioning.result == 'success'
161
- ) && (
162
- needs.api-deploy.result != 'failure' &&
163
- needs.web-deploy.result != 'failure' &&
164
- needs.docs-deploy.result != 'failure' &&
165
- needs.versioning.result != 'failure'
166
- ) && needs.versioning.outputs.version != ''
167
- ) && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/test') }}
168
- secrets: inherit
169
- uses: ./.github/workflows/job.create-pr.yml
170
- with:
171
- version: ${{ needs.versioning.outputs.version }}
172
-
173
- tag-version:
174
- needs: [create-pr, versioning]
175
- if: ${{ always() && needs.versioning.outputs.version != '' }}
176
- uses: ./.github/workflows/job.tag.yml
177
- with:
178
- version: ${{ needs.versioning.outputs.version }}
@@ -1,51 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Set environment variables for testing
4
- PR_HEAD="temp-test-v0.1.1" # Example PR head branch
5
- PR_BASE="temp-test-v0.1.0" # Example PR base branch
6
-
7
- # Verify PR Source is a Fake Branch
8
- if [[ ! "$PR_HEAD" =~ ^temp-(test|main)-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
9
- echo "Skipping: PR did not come from an auto-generated fake branch."
10
- exit 1
11
- fi
12
-
13
- # Extract version and base branch from the PR branch name
14
- BASE_BRANCH=$(echo "$PR_BASE" | cut -d'-' -f1)
15
- OLD_VERSION=$(echo "$PR_BASE" | cut -d'-' -f2-)
16
- NEXT_VERSION=$(echo "$PR_HEAD" | cut -d'-' -f2-)
17
-
18
- echo "BASE_BRANCH=$BASE_BRANCH"
19
- echo "OLD_VERSION=$OLD_VERSION"
20
- echo "NEXT_VERSION=$NEXT_VERSION"
21
-
22
- # Checkout Repository
23
- git fetch origin $PR_HEAD:$PR_HEAD
24
- git checkout $PR_HEAD
25
-
26
- # # Set Up Git
27
- # git config user.name "github-actions[bot]"
28
- # git config user.email "github-actions[bot]@users.noreply.github.com"
29
-
30
- git rev-parse $PR_HEAD
31
-
32
- # Get Latest Commit from Head Branch
33
- COMMIT_HASH=$(git rev-parse $PR_HEAD)
34
-
35
- if [[ -z "$COMMIT_HASH" ]]; then
36
- echo "Failed to find commit for branch $PR_HEAD"
37
- exit 1
38
- fi
39
-
40
- # echo "Found commit: $COMMIT_HASH"
41
-
42
- # # Fast Forward Target Branch
43
- # git fetch origin
44
- # git checkout $BASE_BRANCH
45
- # git merge --ff-only $COMMIT_HASH
46
- # git push origin $BASE_BRANCH
47
-
48
- # # Delete Temporary Branches
49
- # NEW_BRANCH="temp-${BASE_BRANCH}-${NEXT_VERSION}"
50
- # git push origin --delete $NEW_BRANCH
51
- # echo "Temporary branch $NEW_BRANCH deleted"
@@ -1,70 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Set variables
4
- GITHUB_TOKEN=$GITHUB_PERSONAL_ACCESS_TOKEN # Replace with your GitHub token
5
- REPO_OWNER="nasa-madi" # Replace with the repository owner (your GitHub username or org)
6
- REPO_NAME="madi" # Replace with the repository name
7
- OLDER_THAN_DATE="2025-03-11" # Specify the date in YYYY-MM-DD format, older workflows will be deleted
8
-
9
- DRY_RUN=false
10
-
11
- # Convert the date into a timestamp
12
- DATE_TIMESTAMP=$(date -j -f "%Y-%m-%d" "$OLDER_THAN_DATE" "+%s")
13
- echo $DATE_TIMESTAMP
14
-
15
- # Loop through pages of workflow runs
16
- PAGE=1
17
- WORKFLOW_RUN_IDS=""
18
- while true; do
19
- echo "Page: $PAGE"
20
- # Get a page of workflow runs for the repository
21
- WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
22
- "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs?per_page=100&page=$PAGE")
23
-
24
- # Clean the JSON response by removing newlines and replacing unescaped \n with \\n
25
- CLEANED_WORKFLOW_RUNS=$(echo "$WORKFLOW_RUNS" | tr '\n' ' ' | sed 's/\\n/\\\\n/g')
26
-
27
- # Extract the workflow run IDs and their created dates
28
- PAGE_RUN_IDS=$(echo "$CLEANED_WORKFLOW_RUNS" | jq -r ".workflow_runs[] | select((.created_at | fromdateiso8601) < $DATE_TIMESTAMP ) | .id")
29
-
30
- # Break the loop if no more runs are found
31
- if [ -z "$PAGE_RUN_IDS" ]; then
32
- break
33
- fi
34
-
35
- # Append the current page's run IDs to the list
36
- WORKFLOW_RUN_IDS="$WORKFLOW_RUN_IDS $PAGE_RUN_IDS"
37
-
38
- # Increment the page number
39
- PAGE=$((PAGE + 1))
40
- done
41
-
42
- # # Get all workflow runs for the repository
43
- # WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
44
- # "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs?per_page=100&page=2")
45
-
46
- # # Clean the JSON response by removing newlines and replacing unescaped \n with \\n
47
- # CLEANED_WORKFLOW_RUNS=$(echo "$WORKFLOW_RUNS" | tr '\n' ' ' | sed 's/\\n/\\\\n/g')
48
-
49
- # WORKFLOW_RUN_IDS=$(echo "$CLEANED_WORKFLOW_RUNS" | jq -r ".workflow_runs[] | select((.created_at | fromdateiso8601) < $DATE_TIMESTAMP ) | .id")
50
-
51
-
52
- echo "$WORKFLOW_RUN_IDS"
53
-
54
- # Loop through and handle the workflow runs that are older than the specified date
55
- for RUN_ID in $WORKFLOW_RUN_IDS; do
56
- if [ "$DRY_RUN" = "true" ]; then
57
- echo "Dry run: Would delete workflow run ID: $RUN_ID"
58
- else
59
- echo "Deleting workflow run ID: $RUN_ID"
60
- DELETE_RESPONSE=$(curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
61
- "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID")
62
-
63
- # Check if the deletion was successful
64
- if [[ $(echo "$DELETE_RESPONSE" | jq -r '.message') == "Not Found" ]]; then
65
- echo "Error: Failed to delete workflow run ID: $RUN_ID"
66
- else
67
- echo "Successfully deleted workflow run ID: $RUN_ID"
68
- fi
69
- fi
70
- done
@@ -1,51 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Set environment variables for testing
4
- PR_HEAD="temp-test-v0.1.1" # Example PR head branch
5
- PR_BASE="temp-test-v0.1.0" # Example PR base branch
6
-
7
- # Verify PR Source is a Fake Branch
8
- if [[ ! "$PR_HEAD" =~ ^temp-(test|main)-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
9
- echo "Skipping: PR did not come from an auto-generated fake branch."
10
- exit 1
11
- fi
12
-
13
- # Extract version and base branch from the PR branch name
14
- BASE_BRANCH=$(echo "$PR_BASE" | cut -d'-' -f1)
15
- OLD_VERSION=$(echo "$PR_BASE" | cut -d'-' -f2-)
16
- NEXT_VERSION=$(echo "$PR_HEAD" | cut -d'-' -f2-)
17
-
18
- echo "BASE_BRANCH=$BASE_BRANCH"
19
- echo "OLD_VERSION=$OLD_VERSION"
20
- echo "NEXT_VERSION=$NEXT_VERSION"
21
-
22
- # Checkout Repository
23
- git fetch origin $PR_HEAD:$PR_HEAD
24
- git checkout $PR_HEAD
25
-
26
- # # Set Up Git
27
- # git config user.name "github-actions[bot]"
28
- # git config user.email "github-actions[bot]@users.noreply.github.com"
29
-
30
- git rev-parse $PR_HEAD
31
-
32
- # Get Latest Commit from Head Branch
33
- COMMIT_HASH=$(git rev-parse $PR_HEAD)
34
-
35
- if [[ -z "$COMMIT_HASH" ]]; then
36
- echo "Failed to find commit for branch $PR_HEAD"
37
- exit 1
38
- fi
39
-
40
- # echo "Found commit: $COMMIT_HASH"
41
-
42
- # # Fast Forward Target Branch
43
- # git fetch origin
44
- # git checkout $BASE_BRANCH
45
- # git merge --ff-only $COMMIT_HASH
46
- # git push origin $BASE_BRANCH
47
-
48
- # # Delete Temporary Branches
49
- # NEW_BRANCH="temp-${BASE_BRANCH}-${NEXT_VERSION}"
50
- # git push origin --delete $NEW_BRANCH
51
- # echo "Temporary branch $NEW_BRANCH deleted"
@@ -1,70 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Set variables
4
- GITHUB_TOKEN=$GITHUB_PERSONAL_ACCESS_TOKEN # Replace with your GitHub token
5
- REPO_OWNER="nasa-madi" # Replace with the repository owner (your GitHub username or org)
6
- REPO_NAME="madi" # Replace with the repository name
7
- OLDER_THAN_DATE="2025-03-11" # Specify the date in YYYY-MM-DD format, older workflows will be deleted
8
-
9
- DRY_RUN=false
10
-
11
- # Convert the date into a timestamp
12
- DATE_TIMESTAMP=$(date -j -f "%Y-%m-%d" "$OLDER_THAN_DATE" "+%s")
13
- echo $DATE_TIMESTAMP
14
-
15
- # Loop through pages of workflow runs
16
- PAGE=1
17
- WORKFLOW_RUN_IDS=""
18
- while true; do
19
- echo "Page: $PAGE"
20
- # Get a page of workflow runs for the repository
21
- WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
22
- "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs?per_page=100&page=$PAGE")
23
-
24
- # Clean the JSON response by removing newlines and replacing unescaped \n with \\n
25
- CLEANED_WORKFLOW_RUNS=$(echo "$WORKFLOW_RUNS" | tr '\n' ' ' | sed 's/\\n/\\\\n/g')
26
-
27
- # Extract the workflow run IDs and their created dates
28
- PAGE_RUN_IDS=$(echo "$CLEANED_WORKFLOW_RUNS" | jq -r ".workflow_runs[] | select((.created_at | fromdateiso8601) < $DATE_TIMESTAMP ) | .id")
29
-
30
- # Break the loop if no more runs are found
31
- if [ -z "$PAGE_RUN_IDS" ]; then
32
- break
33
- fi
34
-
35
- # Append the current page's run IDs to the list
36
- WORKFLOW_RUN_IDS="$WORKFLOW_RUN_IDS $PAGE_RUN_IDS"
37
-
38
- # Increment the page number
39
- PAGE=$((PAGE + 1))
40
- done
41
-
42
- # # Get all workflow runs for the repository
43
- # WORKFLOW_RUNS=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
44
- # "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs?per_page=100&page=2")
45
-
46
- # # Clean the JSON response by removing newlines and replacing unescaped \n with \\n
47
- # CLEANED_WORKFLOW_RUNS=$(echo "$WORKFLOW_RUNS" | tr '\n' ' ' | sed 's/\\n/\\\\n/g')
48
-
49
- # WORKFLOW_RUN_IDS=$(echo "$CLEANED_WORKFLOW_RUNS" | jq -r ".workflow_runs[] | select((.created_at | fromdateiso8601) < $DATE_TIMESTAMP ) | .id")
50
-
51
-
52
- echo "$WORKFLOW_RUN_IDS"
53
-
54
- # Loop through and handle the workflow runs that are older than the specified date
55
- for RUN_ID in $WORKFLOW_RUN_IDS; do
56
- if [ "$DRY_RUN" = "true" ]; then
57
- echo "Dry run: Would delete workflow run ID: $RUN_ID"
58
- else
59
- echo "Deleting workflow run ID: $RUN_ID"
60
- DELETE_RESPONSE=$(curl -s -X DELETE -H "Authorization: token $GITHUB_TOKEN" \
61
- "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$RUN_ID")
62
-
63
- # Check if the deletion was successful
64
- if [[ $(echo "$DELETE_RESPONSE" | jq -r '.message') == "Not Found" ]]; then
65
- echo "Error: Failed to delete workflow run ID: $RUN_ID"
66
- else
67
- echo "Successfully deleted workflow run ID: $RUN_ID"
68
- fi
69
- fi
70
- done
@@ -1,220 +0,0 @@
1
- name: "Pipeline"
2
- run-name: "${{ github.ref_name }} #${{ inputs.run_number || github.run_number }}${{ inputs.version && format(' - {0}', inputs.version) || '' }}"
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- version:
7
- description: The version to deploy
8
- required: false
9
- type: string
10
- baseRef:
11
- description: The base reference for comparison
12
- required: false
13
- type: string
14
- run_number:
15
- description: The original run number from develop branch
16
- required: false
17
- type: string
18
- push:
19
- branches:
20
- - develop
21
- - staging
22
- - main
23
- jobs:
24
-
25
- #=============================================================================
26
- # CHANGES DETECTION
27
- #=============================================================================
28
- changes:
29
- runs-on: ubuntu-latest
30
- steps:
31
- - uses: actions/checkout@v4
32
- - uses: ./.github/actions/detect-changes
33
- id: detect
34
- with:
35
- baseRef: ${{ inputs.baseRef || 'main' }}
36
- outputs:
37
- cicd: ${{ steps.detect.outputs.cicd }}
38
- core: ${{ steps.detect.outputs.core }}
39
- test: ${{ steps.detect.outputs.test }}
40
-
41
- #=============================================================================
42
- # TESTING JOBS
43
- #=============================================================================
44
- test-cicd:
45
- needs: changes
46
- if: ${{ needs.changes.outputs.cicd == 'true' }}
47
- runs-on: ubuntu-latest
48
- steps:
49
- # TODO: Replace with your cicd test logic
50
- - name: Run cicd tests
51
- run: |
52
- echo "Running tests for cicd domain"
53
- echo "Replace this with your actual test commands"
54
- # Example: npm test -- --testPathPattern=cicd
55
-
56
- test-core:
57
- needs: changes
58
- if: ${{ needs.changes.outputs.core == 'true' }}
59
- runs-on: ubuntu-latest
60
- steps:
61
- # TODO: Replace with your core test logic
62
- - name: Run core tests
63
- run: |
64
- echo "Running tests for core domain"
65
- echo "Replace this with your actual test commands"
66
- # Example: npm test -- --testPathPattern=core
67
-
68
- test-test:
69
- needs: changes
70
- if: ${{ needs.changes.outputs.test == 'true' }}
71
- runs-on: ubuntu-latest
72
- steps:
73
- # TODO: Replace with your test test logic
74
- - name: Run test tests
75
- run: |
76
- echo "Running tests for test domain"
77
- echo "Replace this with your actual test commands"
78
- # Example: npm test -- --testPathPattern=test
79
-
80
- version:
81
- if: ${{
82
- always() && (
83
- needs.test-cicd.result == 'success' ||
84
- needs.test-core.result == 'success' ||
85
- needs.test-test.result == 'success'
86
- ) &&
87
- (
88
- needs.test-cicd.result != 'failure' &&
89
- needs.test-core.result != 'failure' &&
90
- needs.test-test.result != 'failure'
91
- )
92
- }}
93
- needs: [ changes, test-cicd, test-core, test-test ]
94
- runs-on: ubuntu-latest
95
- steps:
96
- - uses: actions/checkout@v4
97
- - uses: ./.github/actions/calculate-version
98
- id: version
99
- with:
100
- baseRef: ${{ inputs.baseRef || 'main' }}
101
- outputs:
102
- version: ${{ steps.version.outputs.version }}
103
-
104
- #=============================================================================
105
- # DEPLOYMENT JOBS
106
- #=============================================================================
107
- deploy-core:
108
- needs: [ changes, version ]
109
- if: ${{ always() && needs.changes.outputs.core == 'true' && needs.version.result == 'success' }}
110
- runs-on: ubuntu-latest
111
- steps:
112
- - name: Deploy core
113
- run: |
114
- echo "Deploying core"
115
- echo "Replace this with your actual deploy commands"
116
- # Example: npm deploy -- --testPathPattern=core
117
-
118
- #=============================================================================
119
- # REMOTE TESTING JOBS
120
- #=============================================================================
121
- remote-test-core:
122
- needs: [ deploy-core, changes ]
123
- if: ${{ always() && needs.deploy-core.result == 'success' && needs.changes.outputs.core == 'true' }}
124
- runs-on: ubuntu-latest
125
- steps:
126
- - name: Test core
127
- run: |
128
- echo "Testing core remotely"
129
- echo "Replace this with your actual test commands"
130
- # Example: npm test -- --testPathPattern=core
131
-
132
- #=============================================================================
133
- # TAG & PROMOTE
134
- #=============================================================================
135
- tag:
136
- # Needs all deploy and/or remote test jobs to succeed or be skipped
137
- # Needs at least one domain to succeed
138
- needs: [ version, deploy-core, remote-test-core ]
139
- if: ${{
140
- always() &&
141
- github.ref_name == 'develop' &&
142
- needs.version.result == 'success' &&
143
- (
144
- needs.deploy-core.result != 'failure' &&
145
- needs.remote-test-core.result != 'failure'
146
- ) &&
147
- (
148
- needs.deploy-core.result == 'success' ||
149
- needs.remote-test-core.result == 'success'
150
- )
151
- }}
152
- runs-on: ubuntu-latest
153
- steps:
154
- - uses: actions/checkout@v4
155
- - uses: ./.github/actions/create-tag
156
- with:
157
- version: ${{ needs.version.outputs.version }}
158
- #=============================================================================
159
- # PROMOTION JOB
160
- #=============================================================================
161
- promote:
162
- # Only runs on push or manual workflow_dispatch events to branches that can promote
163
- # Waits for version/tag if they run, but doesn't fail if they're skipped
164
- # Needs all deploy and/or remote test jobs to succeed
165
- if: ${{
166
- always() &&
167
- (
168
- github.event_name == 'push' ||
169
- github.event_name == 'workflow_dispatch'
170
- ) &&
171
- (
172
- needs.version.result == 'success' ||
173
- needs.version.result == 'skipped'
174
- ) &&
175
- (
176
- needs.tag.result == 'success' ||
177
- needs.tag.result == 'skipped'
178
- ) &&
179
- (
180
- github.ref_name == 'develop' ||
181
- github.ref_name == 'staging'
182
- )
183
- }}
184
- needs: [ version, tag ]
185
- runs-on: ubuntu-latest
186
- steps:
187
- - uses: actions/checkout@v4
188
- - uses: ./.github/actions/promote-branch
189
- with:
190
- sourceBranch: ${{ github.ref_name }}
191
- version: ${{ needs.version.outputs.version }}
192
- run_number: ${{ inputs.run_number || github.run_number }}
193
- token: ${{ secrets.GITHUB_TOKEN }}
194
-
195
- #=============================================================================
196
- # RELEASE JOB (Main Branch Only)
197
- #=============================================================================
198
- release:
199
- # Create GitHub release on main branch after successful tests and versioning
200
- if: ${{
201
- always() &&
202
- github.ref_name == 'main' &&
203
- (
204
- github.event_name == 'push' ||
205
- github.event_name == 'workflow_dispatch'
206
- ) &&
207
- needs.version.result == 'success' &&
208
- (
209
- needs.tag.result == 'success' ||
210
- needs.tag.result == 'skipped'
211
- )
212
- }}
213
- needs: [ version, tag ]
214
- runs-on: ubuntu-latest
215
- steps:
216
- - uses: actions/checkout@v4
217
- - uses: ./.github/actions/create-release
218
- with:
219
- version: ${{ needs.version.outputs.version }}
220
- token: ${{ secrets.GITHUB_TOKEN }}