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.
- package/README.md +126 -108
- package/dist/cli/index.d.ts +69 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +94 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/generators/init.tpl.d.ts +70 -0
- package/dist/generators/init.tpl.d.ts.map +1 -1
- package/dist/generators/init.tpl.js +100 -8
- package/dist/generators/init.tpl.js.map +1 -1
- package/dist/generators/workflows.tpl.d.ts +86 -0
- package/dist/generators/workflows.tpl.d.ts.map +1 -1
- package/dist/generators/workflows.tpl.js +101 -9
- package/dist/generators/workflows.tpl.js.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts +47 -0
- package/dist/templates/actions/calculate-version.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/calculate-version.yml.tpl.js +72 -3
- package/dist/templates/actions/calculate-version.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-pr.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-pr.yml.tpl.js +22 -2
- package/dist/templates/actions/create-pr.yml.tpl.js.map +1 -1
- package/dist/templates/actions/create-release.yml.tpl.d.ts +18 -0
- package/dist/templates/actions/create-release.yml.tpl.d.ts.map +1 -0
- package/dist/templates/actions/create-release.yml.tpl.js +141 -0
- package/dist/templates/actions/create-release.yml.tpl.js.map +1 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/create-tag.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/create-tag.yml.tpl.js +22 -2
- package/dist/templates/actions/create-tag.yml.tpl.js.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts +70 -0
- package/dist/templates/actions/detect-changes.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/detect-changes.yml.tpl.js +98 -2
- package/dist/templates/actions/detect-changes.yml.tpl.js.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/manage-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/manage-branch.yml.tpl.js +22 -2
- package/dist/templates/actions/manage-branch.yml.tpl.js.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts +14 -0
- package/dist/templates/actions/promote-branch.yml.tpl.d.ts.map +1 -1
- package/dist/templates/actions/promote-branch.yml.tpl.js +50 -7
- package/dist/templates/actions/promote-branch.yml.tpl.js.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts +114 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.d.ts.map +1 -1
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js +479 -74
- package/dist/templates/workflows/pipeline-path-based.yml.tpl.js.map +1 -1
- package/dist/types/index.d.ts +231 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/ast-path-operations.d.ts.map +1 -1
- package/dist/utils/ast-path-operations.js +24 -11
- package/dist/utils/ast-path-operations.js.map +1 -1
- package/dist/utils/config.d.ts +63 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +71 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/github-setup.d.ts +323 -2
- package/dist/utils/github-setup.d.ts.map +1 -1
- package/dist/utils/github-setup.js +551 -23
- package/dist/utils/github-setup.js.map +1 -1
- package/dist/utils/idempotency.d.ts +147 -7
- package/dist/utils/idempotency.d.ts.map +1 -1
- package/dist/utils/idempotency.js +143 -15
- package/dist/utils/idempotency.js.map +1 -1
- package/dist/utils/logger.d.ts +134 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +153 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/preflight.d.ts +223 -12
- package/dist/utils/preflight.d.ts.map +1 -1
- package/dist/utils/preflight.js +216 -16
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/versioning.d.ts +160 -8
- package/dist/utils/versioning.d.ts.map +1 -1
- package/dist/utils/versioning.js +179 -15
- package/dist/utils/versioning.js.map +1 -1
- package/package.json +26 -5
- package/.claude/settings.local.json +0 -35
- package/.github/actions/calculate-version/action.yml +0 -106
- package/.github/actions/create-pr/action.yml +0 -122
- package/.github/actions/create-release/action.yml +0 -74
- package/.github/actions/create-tag/action.yml +0 -94
- package/.github/actions/detect-changes/action.yml +0 -62
- package/.github/actions/manage-branch/action.yml +0 -113
- package/.github/actions/promote-branch/action.yml +0 -352
- package/.github/example/workflows/job.analyze.code.yml +0 -26
- package/.github/example/workflows/job.analyze.docker.yml +0 -32
- package/.github/example/workflows/job.app.api.deploy.yml +0 -127
- package/.github/example/workflows/job.app.api.test.yml +0 -102
- package/.github/example/workflows/job.app.docs.deploy.yml +0 -40
- package/.github/example/workflows/job.app.docs.test.yml +0 -50
- package/.github/example/workflows/job.app.web.deploy.yml +0 -96
- package/.github/example/workflows/job.app.web.test.yml +0 -49
- package/.github/example/workflows/job.changes.yml +0 -82
- package/.github/example/workflows/job.create-pr.yml +0 -96
- package/.github/example/workflows/job.env-check.yml +0 -43
- package/.github/example/workflows/job.fast-forward.yml +0 -103
- package/.github/example/workflows/job.lint.yml +0 -64
- package/.github/example/workflows/job.pr-name.yml +0 -70
- package/.github/example/workflows/job.pr-squash-name.yml +0 -27
- package/.github/example/workflows/job.tag.yml +0 -38
- package/.github/example/workflows/job.version.yml +0 -99
- package/.github/example/workflows/lib.plugin-base.publish.yml +0 -59
- package/.github/example/workflows/pipe.yml +0 -178
- package/.github/example/workflows/scripts/fastforward.sh +0 -51
- package/.github/example/workflows/scripts/pipe-cleaner.sh +0 -70
- package/.github/scripts/fastforward.sh +0 -51
- package/.github/scripts/pipe-cleaner.sh +0 -70
- package/.github/workflows/pipeline.yml +0 -220
- package/.github/workflows/pr-title-check.yml +0 -70
- package/.github/workflows/publish.yml +0 -39
- package/.pipecraftrc.json +0 -78
- package/.release-it.cjs +0 -71
- package/PIPELINE_TESTING_PLAN.md +0 -499
- package/TRUNK_FLOW_PLAN.md +0 -401
- package/assets/logo_banner.png +0 -0
- package/assets/logo_banner.webp +0 -0
- package/docs/USER_JOURNEY_ERRORS.md +0 -352
- package/eslint.config.js +0 -77
- package/examples/basic-config.json +0 -41
- package/examples/monorepo-config.json +0 -49
- package/examples/usage.md +0 -289
- package/scripts/debug-workflows.sh +0 -339
- package/scripts/parse-pipeline.js +0 -29
- package/scripts/test-job-order.cjs +0 -140
- package/scripts/validate-pipeline.cjs +0 -379
- package/scripts/verify-job-order.sh +0 -30
- package/src/cli/index.ts +0 -414
- package/src/generators/init.tpl.ts +0 -126
- package/src/generators/workflows.tpl.ts +0 -80
- package/src/templates/actions/calculate-version.yml.tpl.ts +0 -124
- package/src/templates/actions/create-pr.yml.tpl.ts +0 -147
- package/src/templates/actions/create-tag.yml.tpl.ts +0 -112
- package/src/templates/actions/detect-changes.yml.tpl.ts +0 -87
- package/src/templates/actions/manage-branch.yml.tpl.ts +0 -132
- package/src/templates/actions/promote-branch.yml.tpl.ts +0 -364
- package/src/templates/workflows/pipeline-path-based.yml.tpl.ts +0 -706
- package/src/types/index.ts +0 -64
- package/src/utils/README-ast-path-operations.md +0 -390
- package/src/utils/ast-path-operations.ts +0 -581
- package/src/utils/config.ts +0 -64
- package/src/utils/github-setup.ts +0 -558
- package/src/utils/idempotency.ts +0 -215
- package/src/utils/preflight.ts +0 -306
- package/src/utils/versioning.ts +0 -244
- package/tests/README.md +0 -229
- package/tests/TEST_STRUCTURE.md +0 -256
- package/tests/act/run-act-tests.sh +0 -345
- package/tests/debugging/debug-utils.ts +0 -538
- package/tests/debugging/debug-workflow.test.ts +0 -339
- package/tests/debugging/debug-workflows.sh +0 -339
- package/tests/debugging/iterative-debug.ts +0 -652
- package/tests/debugging/run-debug-tests.sh +0 -431
- package/tests/fixtures/basic-config.json +0 -51
- package/tests/fixtures/invalid-config.json +0 -9
- package/tests/fixtures/pipeline-generated.yml +0 -235
- package/tests/fixtures/pipeline-preserve-comments.yml +0 -245
- package/tests/fixtures/pipeline-user-modified.yml +0 -245
- package/tests/fixtures/test-config.json +0 -58
- package/tests/github-live/README.md +0 -250
- package/tests/github-local/JOB_WORKFLOW_TESTS.md +0 -296
- package/tests/github-local/README.md +0 -240
- package/tests/github-local/run-all-tests.sh +0 -422
- package/tests/github-local/test-job-workflows.sh +0 -631
- package/tests/github-local/test-pipeline-workflow.sh +0 -440
- package/tests/integration/generators.test.ts +0 -578
- package/tests/integration/path-based-template.test.ts +0 -510
- package/tests/integration/simple-path-based.test.ts +0 -415
- package/tests/setup.ts +0 -56
- package/tests/unit/ast-path-operations-extended.test.ts +0 -302
- package/tests/unit/cli.test.ts +0 -541
- package/tests/unit/config-extended.test.ts +0 -412
- package/tests/unit/config.test.ts +0 -152
- package/tests/unit/github-setup.test.ts +0 -189
- package/tests/unit/idempotency-isolated.test.ts +0 -297
- package/tests/unit/job-order.test.ts +0 -157
- package/tests/unit/pipeline-path-based.test.ts +0 -511
- package/tests/unit/validate-pipeline.test.ts +0 -384
- package/tests/unit/versioning-extended.test.ts +0 -279
- package/tests/unit/versioning.test.ts +0 -241
- package/tsconfig.debug.json +0 -17
- package/tsconfig.json +0 -28
- 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 }}
|