Skip to content

Commit c61800c

Browse files
committed
refactoring
1 parent 08bdbe9 commit c61800c

3 files changed

Lines changed: 142 additions & 57 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright 2026 Canonical Ltd.
2+
# See LICENSE file for licensing details.
3+
4+
name: Automatic promotion of bundle revisions
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
9+
from-risk:
10+
description: "Risk level to fetch revisions from"
11+
required: true
12+
default: edge
13+
type: choice
14+
options:
15+
- edge
16+
- beta
17+
- candidate
18+
- stable
19+
20+
to-risk:
21+
description: "Risk level to promote revisions to"
22+
required: true
23+
default: candidate
24+
type: choice
25+
options:
26+
- edge
27+
- beta
28+
- candidate
29+
- stable
30+
31+
gating-workflow:
32+
description: "Workflow to gate promotion on"
33+
required: true
34+
default: ci-tests-single-kyuubi
35+
type: choice
36+
options:
37+
- ci-tests-single-kyuubi
38+
- ci-tests-minimal
39+
40+
dry-run:
41+
description: "Whether to run promotion in dry-run mode"
42+
required: true
43+
default: true
44+
type: boolean
45+
46+
name: Automatic promotion of bundle revisions
47+
48+
jobs:
49+
generate-revisions:
50+
name: Generate tfvars revisions
51+
uses: ./.github/workflows/generate-charm-revisions.yaml
52+
secrets: inherit
53+
with:
54+
risk: ${{ inputs.from-risk }}
55+
56+
tests:
57+
name: Run CI tests on a PR
58+
needs: generate-revisions
59+
uses: ./.github/workflows/${{ inputs.gating-workflow }}.yaml
60+
secrets: inherit
61+
with:
62+
tfvars-file: ${{ needs.generate-revisions.outputs.tfvars-artifact-name }}
63+
64+
promotion:
65+
name: Promotion
66+
needs:
67+
- generate-revisions
68+
- tests
69+
uses: ./.github/workflows/promote-charm-revisions.yaml
70+
secrets: inherit
71+
with:
72+
tfvars-artifact-name: ${{ needs.generate-revisions.outputs.tfvars-artifact-name }}
73+
risk: ${{ inputs.to-risk }}
74+
dry-run: ${{ inputs.dry-run }}

.github/workflows/on_pull_request.yaml

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,66 +8,13 @@ concurrency:
88
cancel-in-progress: true
99

1010
on:
11-
workflow_dispatch:
12-
1311
pull_request:
1412
paths-ignore:
1513
- 'docs/**'
1614
- '**.md'
1715

1816
jobs:
19-
generate-revisions:
20-
name: Generate tfvars revisions
21-
uses: ./.github/workflows/generate-charm-revisions.yaml
22-
secrets: inherit
23-
with:
24-
risk: edge
25-
26-
# tests:
27-
# name: Run CI tests on a PR
28-
# needs: generate-revisions
29-
# uses: ./.github/workflows/ci-tests-single-kyuubi.yaml
30-
# secrets: inherit
31-
# with:
32-
# tfvars-file: ${{ needs.generate-revisions.outputs.tfvars-artifact-name }}
33-
34-
promotion:
35-
name: Promotion
36-
needs:
37-
- generate-revisions
38-
# - tests
39-
runs-on: ubuntu-22.04
40-
steps:
41-
- name: Checkout repo
42-
uses: actions/checkout@v6
43-
44-
- id: setup-python
45-
name: Setup Python
46-
uses: actions/setup-python@v5.0.0
47-
with:
48-
python-version: "3.10"
49-
architecture: x64
50-
51-
- id: download-tfvars
52-
name: Download tfvars artifact
53-
uses: actions/download-artifact@v4
54-
with:
55-
name: ${{ needs.generate-revisions.outputs.tfvars-artifact-name }}
56-
path: tfvars-artifacts
57-
58-
- id: tests-integration
59-
name: Run Integration Tests
60-
shell: bash
61-
env:
62-
CHARMCRAFT_AUTH: ${{ secrets.CHARMHUB_TOKEN }}
63-
run: |
64-
pip install pyyaml
65-
sudo snap install charmcraft --classic
66-
67-
REVISION_FILES=$(find tfvars-artifacts -type f -name "*.yaml")
68-
for REVISION_FILE in $REVISION_FILES; do
69-
echo "Processing $REVISION_FILE"
70-
python3 .github/scripts/charms_promotions.py promote \
71-
--format yaml --promote-to beta --dry-run \
72-
--file $REVISION_FILE
73-
done
17+
tests:
18+
name: Run CI tests on a PR
19+
uses: ./.github/workflows/ci-tests-minimal.yaml
20+
secrets: inherit
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright 2024 Canonical Ltd.
2+
# See LICENSE file for licensing details.
3+
4+
name: Promote charm revisions
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
tfvars-artifact-name:
10+
description: "Name of the artifact containing generated tfvars"
11+
required: true
12+
type: string
13+
risk:
14+
description: "Risk level to promote revisions to"
15+
required: true
16+
type: string
17+
dry-run:
18+
description: "Whether to run promotion in dry-run mode"
19+
required: true
20+
type: boolean
21+
22+
jobs:
23+
promotion:
24+
name: Promotion
25+
runs-on: ubuntu-22.04
26+
steps:
27+
- name: Checkout repo
28+
uses: actions/checkout@v6
29+
30+
- id: setup-python
31+
name: Setup Python
32+
uses: actions/setup-python@v5.0.0
33+
with:
34+
python-version: "3.10"
35+
architecture: x64
36+
37+
- id: download-tfvars
38+
name: Download tfvars artifact
39+
uses: actions/download-artifact@v4
40+
with:
41+
name: ${{ inputs.tfvars-artifact-name }}
42+
path: tfvars-artifacts
43+
44+
- id: run-promotion
45+
name: Run promotion
46+
shell: bash
47+
env:
48+
CHARMCRAFT_AUTH: ${{ secrets.CHARMHUB_TOKEN }}
49+
run: |
50+
pip install pyyaml
51+
sudo snap install charmcraft --classic
52+
53+
PROMOTION_MODE="--dry-run"
54+
if [[ "${{ inputs.dry-run }}" == "false" ]]; then
55+
PROMOTION_MODE="--apply"
56+
fi
57+
58+
REVISION_FILES=$(find tfvars-artifacts -type f -name "*.yaml")
59+
for REVISION_FILE in $REVISION_FILES; do
60+
echo "Processing $REVISION_FILE"
61+
python3 .github/scripts/charms_promotions.py promote \
62+
--format yaml --promote-to "${{ inputs.risk }}" "$PROMOTION_MODE" \
63+
--file "$REVISION_FILE"
64+
done

0 commit comments

Comments
 (0)