|
| 1 | +name: "Copilot Setup Steps" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + paths: |
| 7 | + - .github/workflows/copilot-setup-steps.yml |
| 8 | + pull_request: |
| 9 | + paths: |
| 10 | + - .github/workflows/copilot-setup-steps.yml |
| 11 | + |
| 12 | +jobs: |
| 13 | + # IMPORTANT: Job name must be exactly this. |
| 14 | + copilot-setup-steps: |
| 15 | + # You can upgrade to a larger Ubuntu runner label later if needed (e.g. ubuntu-4-core) |
| 16 | + runs-on: ubuntu-latest |
| 17 | + timeout-minutes: 40 |
| 18 | + |
| 19 | + # Minimize permissions; Copilot will get its own token later. |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v5 |
| 26 | + with: |
| 27 | + # fetch-depth overridden internally for Copilot anyway; keep explicit for normal runs |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Set up Python |
| 31 | + uses: actions/setup-python@v6 |
| 32 | + with: |
| 33 | + python-version: '3.x' |
| 34 | + |
| 35 | + - name: Cache PlatformIO core and packages |
| 36 | + uses: actions/cache@v4 |
| 37 | + with: |
| 38 | + path: | |
| 39 | + ~/.platformio |
| 40 | + key: pio-${{ runner.os }}-${{ hashFiles('platformio.ini', 'dependencies.lock') }} |
| 41 | + restore-keys: | |
| 42 | + pio-${{ runner.os }}- |
| 43 | +
|
| 44 | + - name: Install PlatformIO Core |
| 45 | + run: | |
| 46 | + python -m pip install --upgrade pip |
| 47 | + pip install --upgrade platformio |
| 48 | +
|
| 49 | + - name: Show PlatformIO info |
| 50 | + run: | |
| 51 | + platformio --version |
| 52 | + platformio system info |
| 53 | +
|
| 54 | + - name: Pre-download native test dependencies |
| 55 | + run: | |
| 56 | + platformio pkg install -e native || echo "Native env install attempted" |
| 57 | +
|
| 58 | + - name: Pre-download ESP32 toolchains and libraries (release env) |
| 59 | + run: | |
| 60 | + # Only install packages (faster + ensures offline availability later) |
| 61 | + platformio pkg install -e release |
| 62 | +
|
| 63 | + - name: Warm build cache (lightweight compile) for release env |
| 64 | + run: | |
| 65 | + # A full build ensures toolchains, frameworks, and libs are all present |
| 66 | + # If this becomes too slow, you can remove this step and rely on pkg install only. |
| 67 | + platformio run -e release || exit 0 |
| 68 | +
|
| 69 | + - name: Warm build cache for native env (tests) |
| 70 | + run: | |
| 71 | + platformio run -e native || exit 0 |
| 72 | +
|
| 73 | + - name: Validate native tests (non-blocking) |
| 74 | + run: | |
| 75 | + set +e |
| 76 | + platformio test -e native |
| 77 | + # Do not fail setup if tests fail; Copilot will handle fixes. |
| 78 | + exit 0 |
| 79 | +
|
| 80 | + - name: Summarize cached packages |
| 81 | + run: | |
| 82 | + du -sh ~/.platformio/packages/* || true |
| 83 | + du -sh ~/.platformio/platforms/* || true |
| 84 | +
|
| 85 | + - name: Guidance for future adjustments |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + echo "Setup steps completed. You can:" |
| 89 | + echo " - Upgrade runner: change runs-on to ubuntu-4-core if builds are slow." \ |
| 90 | + "\n - Enable LFS: add 'with: lfs: true' to checkout step if using Git LFS." \ |
| 91 | + "\n - Trim steps: remove warm build steps if time exceeds limits." \ |
| 92 | + "\n - Add more pkg installs for other environments if created later." |
0 commit comments