|
| 1 | +name: Staging Smoke |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - ".github/workflows/staging-smoke.yml" |
| 8 | + - "Makefile" |
| 9 | + - "docs/STAGING_SMOKE.md" |
| 10 | + - "docs/VERSIONING_AND_RELEASE.md" |
| 11 | + - "scripts/staging_smoke.py" |
| 12 | + - "tests/test_staging_smoke.py" |
| 13 | + - "template/**" |
| 14 | + - "template-contract.yml" |
| 15 | + - "template-manifest.yml" |
| 16 | + - "dashboard_action/runtime/managed_docs/**" |
| 17 | + push: |
| 18 | + branches: [main] |
| 19 | + paths: |
| 20 | + - ".github/workflows/staging-smoke.yml" |
| 21 | + - "Makefile" |
| 22 | + - "docs/STAGING_SMOKE.md" |
| 23 | + - "docs/VERSIONING_AND_RELEASE.md" |
| 24 | + - "scripts/staging_smoke.py" |
| 25 | + - "tests/test_staging_smoke.py" |
| 26 | + - "template/**" |
| 27 | + - "template-contract.yml" |
| 28 | + - "template-manifest.yml" |
| 29 | + - "dashboard_action/runtime/managed_docs/**" |
| 30 | + workflow_dispatch: |
| 31 | + inputs: |
| 32 | + source_ref: |
| 33 | + description: "Git ref to build the staging smoke tree from" |
| 34 | + required: true |
| 35 | + type: string |
| 36 | + default: main |
| 37 | + repositories: |
| 38 | + description: "Space- or comma-separated public repos for collect.repositories" |
| 39 | + required: true |
| 40 | + type: string |
| 41 | + default: reponomics/reponomics-dashboard-action |
| 42 | + publish_repositories: |
| 43 | + description: "Optional space- or comma-separated publish.repositories subset" |
| 44 | + required: false |
| 45 | + type: string |
| 46 | + default: "" |
| 47 | + publish: |
| 48 | + description: "Replace the copied staging repository branch" |
| 49 | + required: true |
| 50 | + type: boolean |
| 51 | + default: false |
| 52 | + |
| 53 | +permissions: |
| 54 | + contents: read |
| 55 | + |
| 56 | +concurrency: |
| 57 | + group: staging-smoke-${{ github.event.inputs.source_ref || github.ref }} |
| 58 | + cancel-in-progress: false |
| 59 | + |
| 60 | +env: |
| 61 | + PYTHON_VERSION: "3.11" |
| 62 | + STAGING_SMOKE_EXPECTED_REPO: reponomics/reponomics-dashboard-staging |
| 63 | + STAGING_SMOKE_BRANCH: main |
| 64 | + STAGING_SMOKE_OUTPUT: dist/staging-smoke |
| 65 | + STAGING_SMOKE_EVIDENCE: dist/staging-smoke-evidence.md |
| 66 | + STAGING_SMOKE_MESSAGE: "chore: publish staging smoke dashboard" |
| 67 | + |
| 68 | +jobs: |
| 69 | + validate-staging-smoke: |
| 70 | + name: Validate staging smoke tree |
| 71 | + if: ${{ github.event_name != 'workflow_dispatch' || !inputs.publish }} |
| 72 | + runs-on: ubuntu-24.04 |
| 73 | + permissions: |
| 74 | + contents: read |
| 75 | + env: |
| 76 | + STAGING_SMOKE_REPOSITORIES: ${{ inputs.repositories || 'reponomics/reponomics-dashboard-action' }} |
| 77 | + STAGING_SMOKE_PUBLISH_REPOSITORIES: ${{ inputs.publish_repositories || '' }} |
| 78 | + steps: |
| 79 | + - name: Checkout source |
| 80 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 81 | + with: |
| 82 | + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.source_ref || github.ref }} |
| 83 | + |
| 84 | + - name: Set up Python |
| 85 | + uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 |
| 86 | + with: |
| 87 | + python-version: ${{ env.PYTHON_VERSION }} |
| 88 | + cache: pip |
| 89 | + cache-dependency-path: pyproject.toml |
| 90 | + |
| 91 | + - name: Build staging smoke tree |
| 92 | + run: | |
| 93 | + set -euo pipefail |
| 94 | + make staging-smoke |
| 95 | +
|
| 96 | + - name: Test staging smoke harness |
| 97 | + run: | |
| 98 | + set -euo pipefail |
| 99 | + PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 venv/bin/python -m pytest tests/test_staging_smoke.py -v |
| 100 | +
|
| 101 | + - name: Upload staging smoke evidence |
| 102 | + if: always() |
| 103 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 104 | + with: |
| 105 | + name: staging-smoke-evidence-${{ github.run_id }} |
| 106 | + path: | |
| 107 | + dist/staging-smoke-evidence.md |
| 108 | + dist/staging-smoke/.reponomics/staging-smoke.json |
| 109 | + if-no-files-found: warn |
| 110 | + retention-days: 7 |
| 111 | + |
| 112 | + publish-staging-smoke: |
| 113 | + name: Publish staging smoke repository |
| 114 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish }} |
| 115 | + runs-on: ubuntu-24.04 |
| 116 | + permissions: |
| 117 | + contents: read |
| 118 | + steps: |
| 119 | + - name: Resolve publication source |
| 120 | + id: source-ref |
| 121 | + env: |
| 122 | + SOURCE_REF: ${{ inputs.source_ref }} |
| 123 | + run: | |
| 124 | + set -euo pipefail |
| 125 | +
|
| 126 | + if [[ -z "$SOURCE_REF" ]]; then |
| 127 | + echo "Staging smoke source ref is empty." >&2 |
| 128 | + exit 1 |
| 129 | + fi |
| 130 | +
|
| 131 | + case "$SOURCE_REF" in |
| 132 | + main|refs/heads/main|reponomics-dashboard-v*|refs/tags/reponomics-dashboard-v*|v*|refs/tags/v*) ;; |
| 133 | + *) |
| 134 | + echo "Staging smoke publication is restricted to main or release tags; got $SOURCE_REF." >&2 |
| 135 | + exit 1 |
| 136 | + ;; |
| 137 | + esac |
| 138 | +
|
| 139 | + echo "source_ref=$SOURCE_REF" >> "$GITHUB_OUTPUT" |
| 140 | +
|
| 141 | + - name: Checkout source |
| 142 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 143 | + with: |
| 144 | + ref: ${{ steps.source-ref.outputs.source_ref }} |
| 145 | + |
| 146 | + - name: Set up Python |
| 147 | + uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 |
| 148 | + with: |
| 149 | + python-version: ${{ env.PYTHON_VERSION }} |
| 150 | + cache: pip |
| 151 | + cache-dependency-path: pyproject.toml |
| 152 | + |
| 153 | + - name: Create staging publication app token |
| 154 | + id: app-token |
| 155 | + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 |
| 156 | + with: |
| 157 | + client-id: ${{ vars.STAGING_SMOKE_APP_CLIENT_ID }} |
| 158 | + private-key: ${{ secrets.STAGING_SMOKE_APP_PRIVATE_KEY }} |
| 159 | + owner: ${{ github.repository_owner }} |
| 160 | + repositories: reponomics-dashboard-staging |
| 161 | + permission-contents: write |
| 162 | + permission-workflows: write |
| 163 | + |
| 164 | + - name: Publish staging smoke tree |
| 165 | + shell: bash |
| 166 | + env: |
| 167 | + STAGING_TOKEN: ${{ steps.app-token.outputs.token }} |
| 168 | + STAGING_SMOKE_REPOSITORIES: ${{ inputs.repositories }} |
| 169 | + STAGING_SMOKE_PUBLISH_REPOSITORIES: ${{ inputs.publish_repositories }} |
| 170 | + run: | |
| 171 | + set -euo pipefail |
| 172 | +
|
| 173 | + make install |
| 174 | + remote="https://x-access-token:${STAGING_TOKEN}@github.com/${STAGING_SMOKE_EXPECTED_REPO}.git" |
| 175 | + args=( |
| 176 | + --output "$STAGING_SMOKE_OUTPUT" |
| 177 | + --remote "$remote" |
| 178 | + --expected-repo "$STAGING_SMOKE_EXPECTED_REPO" |
| 179 | + --branch "$STAGING_SMOKE_BRANCH" |
| 180 | + --message "$STAGING_SMOKE_MESSAGE" |
| 181 | + --evidence "$STAGING_SMOKE_EVIDENCE" |
| 182 | + --repository "$STAGING_SMOKE_REPOSITORIES" |
| 183 | + --push |
| 184 | + ) |
| 185 | + if [[ -n "$STAGING_SMOKE_PUBLISH_REPOSITORIES" ]]; then |
| 186 | + args+=(--publish-repository "$STAGING_SMOKE_PUBLISH_REPOSITORIES") |
| 187 | + fi |
| 188 | +
|
| 189 | + venv/bin/python scripts/staging_smoke.py "${args[@]}" |
| 190 | +
|
| 191 | + - name: Add staging smoke evidence to summary |
| 192 | + if: always() |
| 193 | + run: | |
| 194 | + set -euo pipefail |
| 195 | + if [[ -f "$STAGING_SMOKE_EVIDENCE" ]]; then |
| 196 | + cat "$STAGING_SMOKE_EVIDENCE" >> "$GITHUB_STEP_SUMMARY" |
| 197 | + fi |
| 198 | +
|
| 199 | + - name: Upload staging smoke evidence |
| 200 | + if: always() |
| 201 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 202 | + with: |
| 203 | + name: staging-smoke-published-${{ github.run_id }} |
| 204 | + path: | |
| 205 | + dist/staging-smoke-evidence.md |
| 206 | + dist/staging-smoke/.reponomics/staging-smoke.json |
| 207 | + if-no-files-found: error |
| 208 | + retention-days: 14 |
0 commit comments