|
| 1 | +name: SF CLI Integration Test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +jobs: |
| 7 | + sf-cli-integration: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + env: |
| 10 | + SF_AUTOUPDATE_DISABLE: true |
| 11 | + NO_COLOR: '1' |
| 12 | + |
| 13 | + steps: |
| 14 | + # ── Setup ───────────────────────────────────────────────────────────────── |
| 15 | + |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Python 3.11 |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: '3.11' |
| 23 | + |
| 24 | + - name: Install Poetry and Python SDK |
| 25 | + run: | |
| 26 | + python -m pip install --upgrade pip |
| 27 | + pip install poetry |
| 28 | + make develop |
| 29 | +
|
| 30 | + - name: Set up Node.js |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: lts/* |
| 34 | + |
| 35 | + - name: Install Salesforce CLI |
| 36 | + run: npm install -g @salesforce/cli |
| 37 | + |
| 38 | + - name: Install data-code-extension plugin |
| 39 | + run: sf plugins install @salesforce/plugin-data-code-extension --force |
| 40 | + |
| 41 | + # ── Script: init ────────────────────────────────────────────────────────── |
| 42 | + |
| 43 | + - name: '[script] init — sf data-code-extension script init --package-dir testScript' |
| 44 | + run: | |
| 45 | + sf data-code-extension script init --package-dir testScript || { |
| 46 | + echo "::error::sf data-code-extension script init FAILED. Verify --package-dir is still a recognised flag and that the command exits 0 on success." |
| 47 | + exit 1 |
| 48 | + } |
| 49 | +
|
| 50 | + - name: '[script] verify init — expected files exist' |
| 51 | + run: | |
| 52 | + test -f testScript/payload/entrypoint.py || { |
| 53 | + echo "::error::testScript/payload/entrypoint.py not found after init. The init command may not have copied the script template." |
| 54 | + exit 1 |
| 55 | + } |
| 56 | + test -f testScript/.datacustomcode_proj/sdk_config.json || { |
| 57 | + echo "::error::testScript/.datacustomcode_proj/sdk_config.json not found after init. The SDK config marker was not written." |
| 58 | + exit 1 |
| 59 | + } |
| 60 | +
|
| 61 | + # ── Script: scan ────────────────────────────────────────────────────────── |
| 62 | + |
| 63 | + - name: '[script] scan — sf data-code-extension script scan --entrypoint testScript/payload/entrypoint.py' |
| 64 | + run: | |
| 65 | + sf data-code-extension script scan --entrypoint testScript/payload/entrypoint.py || { |
| 66 | + echo "::error::sf data-code-extension script scan FAILED. Verify --entrypoint is still a recognised flag and the command exits 0." |
| 67 | + exit 1 |
| 68 | + } |
| 69 | +
|
| 70 | + - name: '[script] verify scan — config.json contains permissions' |
| 71 | + run: | |
| 72 | + python - <<'EOF' |
| 73 | + import json, sys |
| 74 | + path = "testScript/payload/config.json" |
| 75 | + try: |
| 76 | + with open(path) as f: |
| 77 | + data = json.load(f) |
| 78 | + except Exception as e: |
| 79 | + print(f"::error::Could not read {path}: {e}") |
| 80 | + sys.exit(1) |
| 81 | + if "permissions" not in data: |
| 82 | + print(f"::error::{path} is missing 'permissions' key after scan. Got: {json.dumps(data)}") |
| 83 | + sys.exit(1) |
| 84 | + print("config.json OK:", json.dumps(data, indent=2)) |
| 85 | + EOF |
| 86 | +
|
| 87 | + # ── Script: zip ─────────────────────────────────────────────────────────── |
| 88 | + |
| 89 | + - name: '[script] prepare for zip — clear requirements.txt to skip native-dep Docker build' |
| 90 | + run: echo "" > testScript/payload/requirements.txt |
| 91 | + |
| 92 | + - name: '[script] zip — sf data-code-extension script zip --package-dir testScript' |
| 93 | + run: | |
| 94 | + sf data-code-extension script zip --package-dir testScript || { |
| 95 | + echo "::error::sf data-code-extension script zip FAILED. Verify --package-dir is still recognised and the command exits 0." |
| 96 | + exit 1 |
| 97 | + } |
| 98 | +
|
| 99 | + - name: '[script] verify zip — deployment.zip exists' |
| 100 | + run: | |
| 101 | + test -f deployment.zip || { |
| 102 | + echo "::error::deployment.zip not found after sf data-code-extension script zip. The zip command may have written to a different path or failed silently." |
| 103 | + exit 1 |
| 104 | + } |
| 105 | +
|
| 106 | + # ── Function: init ──────────────────────────────────────────────────────── |
| 107 | + |
| 108 | + - name: '[function] init — sf data-code-extension function init --package-dir testFunction' |
| 109 | + run: | |
| 110 | + sf data-code-extension function init --package-dir testFunction || { |
| 111 | + echo "::error::sf data-code-extension function init FAILED. Verify --package-dir is still recognised and the function template copies correctly." |
| 112 | + exit 1 |
| 113 | + } |
| 114 | +
|
| 115 | + - name: '[function] verify init — expected files exist' |
| 116 | + run: | |
| 117 | + test -f testFunction/payload/entrypoint.py || { |
| 118 | + echo "::error::testFunction/payload/entrypoint.py not found after function init." |
| 119 | + exit 1 |
| 120 | + } |
| 121 | + test -f testFunction/.datacustomcode_proj/sdk_config.json || { |
| 122 | + echo "::error::testFunction/.datacustomcode_proj/sdk_config.json not found after function init." |
| 123 | + exit 1 |
| 124 | + } |
| 125 | +
|
| 126 | + # ── Function: scan ──────────────────────────────────────────────────────── |
| 127 | + |
| 128 | + - name: '[function] scan — sf data-code-extension function scan --entrypoint testFunction/payload/entrypoint.py' |
| 129 | + run: | |
| 130 | + sf data-code-extension function scan --entrypoint testFunction/payload/entrypoint.py || { |
| 131 | + echo "::error::sf data-code-extension function scan FAILED." |
| 132 | + exit 1 |
| 133 | + } |
| 134 | +
|
| 135 | + - name: '[function] verify scan — config.json contains entryPoint' |
| 136 | + run: | |
| 137 | + python - <<'EOF' |
| 138 | + import json, sys |
| 139 | + path = "testFunction/payload/config.json" |
| 140 | + try: |
| 141 | + with open(path) as f: |
| 142 | + data = json.load(f) |
| 143 | + except Exception as e: |
| 144 | + print(f"::error::Could not read {path}: {e}") |
| 145 | + sys.exit(1) |
| 146 | + if "entryPoint" not in data: |
| 147 | + print(f"::error::{path} is missing 'entryPoint' key after scan. Got: {json.dumps(data)}") |
| 148 | + sys.exit(1) |
| 149 | + print("config.json OK:", json.dumps(data, indent=2)) |
| 150 | + EOF |
| 151 | +
|
| 152 | + # ── Function: zip ───────────────────────────────────────────────────────── |
| 153 | + |
| 154 | + - name: '[function] prepare for zip — clear requirements.txt to skip native-dep Docker build' |
| 155 | + run: echo "" > testFunction/payload/requirements.txt |
| 156 | + |
| 157 | + - name: '[function] clean up previous deployment.zip before function zip' |
| 158 | + run: rm -f deployment.zip |
| 159 | + |
| 160 | + - name: '[function] zip — sf data-code-extension function zip --package-dir testFunction' |
| 161 | + run: | |
| 162 | + sf data-code-extension function zip --package-dir testFunction || { |
| 163 | + echo "::error::sf data-code-extension function zip FAILED." |
| 164 | + exit 1 |
| 165 | + } |
| 166 | +
|
| 167 | + - name: '[function] verify zip — deployment.zip exists' |
| 168 | + run: | |
| 169 | + test -f deployment.zip || { |
| 170 | + echo "::error::deployment.zip not found after sf data-code-extension function zip." |
| 171 | + exit 1 |
| 172 | + } |
0 commit comments