Skip to content

Commit

Permalink
Snapshot workflow updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jlantz committed Oct 11, 2024
1 parent 7e646d6 commit c83e222
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
platform: [linux/amd64, linux/arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/feature-test-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Prepare Feature Test Org
id: prepare_org
run: |
cci flow run ci_feature --skip-from run_tests --use-snapshots
cci flow run ci_feature --skip-from run_tests
- name: Start Snapshot Creation
if: inputs.create_pr_snapshot == true
Expand Down
39 changes: 35 additions & 4 deletions .github/workflows/feature-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,46 @@ jobs:
GITHUB_APP_KEY: "${{ secrets.github-app-key }}"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Auth to DevHub
run: /usr/local/bin/devhub.sh
- name: Set ${{ inputs.org }} org as default org
run: cci org default ${{ inputs.org }}
- name: Run Feature Test
run: cci flow run ci_feature --use-snapshots
- name: Delete Scratch Org
if: ${{ always() }}
- name: Delete Scratch Org
if: always()
run: cci org scratch_delete ${{ inputs.org_name }}
shell: bash

- name: Capture CumulusCI Build History
if: always()
run: |
cci history list
cci history dependencies
cci history dependencies --json > cci_dependencies_history.json
cci history list --json > cci_build_history.json
shell: bash

- name: Upload CumulusCI Dependencies History
if: always()
uses: actions/upload-artifact@v4
with:
name: cci-dependencies-history
path: cci_dependencies_history.json

- name: Upload CumulusCI Build History
if: always()
uses: actions/upload-artifact@v4
with:
name: cci-build-history
path: cci_build_history.json

- name: Check Job Status
if: always()
run: |
cci org scratch_delete ${{ inputs.org }}
if [[ "${{ steps.create_2gp.outcome }}" == "failure" || "${{ steps.prepare_org.outcome }}" == "failure" || "${{ steps.feature_test.outcome }}" == "failure" ]]; then
echo "Critical step failed. Failing the job."
exit 1
fi
shell: bash
124 changes: 124 additions & 0 deletions .github/workflows/snapshot-flow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Snapshot Hashed Flow

on:
workflow_call:
inputs:
org_name:
description: "The name of the scratch org profile to use for the source org. If not provided, the org named 'beta' will be used."
required: true
type: string
flow_name:
description: "The name of the flow to run"
required: true
type: string
flow_run_options:
description: "Options to pass to the flow via cci flow run -o 'key=value'"
required: false
type: string
create_snapshot_commit_status:
required: false
default: true
description: "If true, a commit status will be set for the build. This is useful for tracking the status of the snapshot creation task."
type: boolean
create_snapshot_environment:
required: false
default: false
description: "If true, a GitHub Environment will be created for the snapshot."
type: boolean
debug:
description: "Enable debug logging output for CumulusCI"
required: false
default: false
type: boolean
secrets:
dev-hub-auth-url:
required: false
dev-hub-username:
required: false
dev-hub-client-id:
required: false
dev-hub-private-key:
required: false
gh-email:
required: true
github-token:
required: true
github-app-id:
required: false
github-app-key:
required: false

jobs:
predict-hashes
name: "Predict snapshot hashes"
runs-on: ubuntu-latest
container:
image: ghcr.io/muselab-d2x/d2x:cumulusci-next-snapshots
options: --user root
credentials:
username: "${{ github.actor }}"
password: "${{ secrets.github-token }}"
env:
DEV_HUB_AUTH_URL: "${{ secrets.dev-hub-auth-url }}"
DEV_HUB_USERNAME: "${{ secrets.dev-hub-username }}"
DEV_HUB_CLIENT_ID: "${{ secrets.dev-hub-client-id }}"
DEV_HUB_PRIVATE_KEY: "${{ secrets.dev-hub-private-key }}"
CUMULUSCI_SERVICE_github: '{ "username": "${{ github.actor }}", "token": "${{ secrets.github-token }}", "email": "${{ secrets.gh-email }}" }'
GITHUB_APP_ID: "${{ secrets.github-app-id }}"
GITHUB_APP_KEY: "${{ secrets.github-app-key }}"
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v2
- name: Auth to DevHub
id: auth
run: /usr/local/bin/devhub.sh
- name: Set default org
id: default_org
run: cci org default ${{ inputs.org_name }}
# - name: Predict flow hashes
# id: predict_hashes
# run: |
# set -e {
# cci flow run ${{inputs.flow_name}} --predict ${{ inputs.flow_run_options }} \
# $([[ "${{ inputs.debug }}" == "true" ]] && echo " --debug")
# } || {
# echo "::error::Failed to predict hashes. Running cci error info..."
# cci error info
# exit 1
# }
# shell: bash

- name: Run Flow
id: run_flow
run: |
set -e {
cci flow run ${{inputs.flow_name}} ${{ inputs.flow_run_options }} \
$([[ "${{ inputs.debug }}" == "true" ]] && echo " --debug")
} || {
echo "::error::Failed to install dependencies. Running cci error info..."}
cci error info
exit 1
}
shell: bash

- name: Create Hashed Snapshot if Needed
id: create_snapshot
if: ${{ inputs.snapshot_name != '' }}
run: |
set -e {
cci task run create_hashed_snapshot \
$([[ "${{ inputs.create_snapshot_commit_status }}" == "true" ]] && echo " --create-commit-status") \
$([[ "${{ inputs.create_snapshot_environment }}" == "true" ]] && echo " --create-environment") \
$([[ "${{ inputs.debug }}" == "true" ]] && echo " --debug")
} || {
echo "::error::Failed to start the snapshot. Running cci error info..."
cci error info
exit 1
}
shell: bash
- name: Delete Scratch Org
if: ${{ always() }}
run: |
cci org scratch_delete ${{ inputs.org_name }}
shell: bash

0 comments on commit c83e222

Please sign in to comment.