Skip to content

Commit 1e73df9

Browse files
authored
[DPE-2789] update data-platform-workflows (#263)
* Tweak workflows * Initial pass * Tweak conftest * Move renovate configs * Add wrapper * Copy from mysql-k8s * Linting * Partial merge * Saner marks * Tweak excludes * Bump dpw version * Bump deps * Tweak backup tests * Conditional free space * Revert "Conditional free space" This reverts commit c4f72d2. * Bump jira sync version * Bump lock * Remove schedule and call * Bump libs and actions
1 parent 6790adc commit 1e73df9

File tree

16 files changed

+1084
-939
lines changed

16 files changed

+1084
-939
lines changed

.github/renovate.json5

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["github>canonical/data-platform//renovate_presets/charm.json5"],
4+
"reviewers": ["dragomirp", "marceloneppel", "taurus-forever"],
5+
"packageRules": [
6+
// Later rules override earlier rules
7+
],
8+
"regexManagers": [
9+
{
10+
"fileMatch": ["(^|/)([\\w-]*)charmcraft\\.ya?ml$"],
11+
"matchStrings": ["- (?<depName>.*?)(?:\\[.*?\\])?==(?<currentValue>.*?) +# renovate"],
12+
"datasourceTemplate": "pypi",
13+
"versioningTemplate": "loose"
14+
}
15+
]
16+
}

.github/workflows/ci.yaml

Lines changed: 57 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,40 @@ on:
2222
jobs:
2323
lint:
2424
name: Lint
25-
runs-on: ubuntu-latest
26-
timeout-minutes: 5
27-
steps:
28-
- name: Checkout
29-
uses: actions/checkout@v3
30-
- name: Install tox
31-
# TODO: Consider replacing with custom image on self-hosted runner OR pinning version
32-
run: python3 -m pip install tox
33-
- name: Run linters
34-
run: tox run -e lint
25+
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
3526

3627
unit-test:
37-
name: Unit tests
28+
name: Unit test charm
3829
runs-on: ubuntu-latest
3930
timeout-minutes: 5
4031
steps:
4132
- name: Checkout
42-
uses: actions/checkout@v3
43-
- name: Install tox
44-
# TODO: Consider replacing with custom image on self-hosted runner OR pinning version
45-
run: python3 -m pip install tox
33+
uses: actions/checkout@v4
34+
- name: Install tox & poetry
35+
run: |
36+
pipx install tox
37+
pipx install poetry
4638
- name: Run tests
4739
run: tox run -e unit
4840
- name: Upload Coverage to Codecov
4941
uses: codecov/codecov-action@v3
5042

5143
build:
52-
name: Build charms
53-
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v2
44+
name: Build charm
45+
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
46+
permissions:
47+
actions: write # Needed to manage GitHub Actions cache
5448

55-
integration-test:
49+
gh-hosted-integration-test:
5650
strategy:
5751
fail-fast: false
58-
max-parallel: 6
5952
matrix:
60-
tox-environments:
53+
tox-environment:
6154
- backup-integration
6255
- charm-integration
56+
- database-relation-integration
6357
- db-relation-integration
58+
- db-admin-relation-integration
6459
- ha-replication-integration
6560
- ha-self-healing-integration
6661
- ha-restore-cluster-integration
@@ -69,22 +64,21 @@ jobs:
6964
- tls-integration
7065
- upgrade-integration
7166
- upgrade-from-stable-integration
72-
agent-versions:
73-
- "2.9.45" # renovate: latest juju 2
74-
- "3.1.6" # renovate: latest juju 3
75-
free-disk-space:
76-
- false
67+
juju-snap-channel: ["2.9/stable", "3.1/stable"]
68+
exclude:
69+
# Admin tests need landscape on juju 2
70+
- tox-environment: db-admin-relation-integration
71+
juju-snap-channel: "3.1/stable"
7772
include:
78-
- tox-environments: database-relation-integration
79-
agent-versions: "2.9.45" # renovate: latest juju 2
80-
free-disk-space: true
81-
- tox-environments: database-relation-integration
82-
agent-versions: "3.1.6" # renovate: latest juju 3
83-
free-disk-space: true
84-
- tox-environments: db-admin-relation-integration
85-
agent-versions: "2.9.45" # renovate: latest juju 2
86-
free-disk-space: true
87-
name: ${{ matrix.tox-environments }} | ${{ matrix.agent-versions }}
73+
- juju-snap-channel: "3.1/stable"
74+
agent-version: "3.1.6"
75+
libjuju-version: "3.2.2"
76+
exclude-mark: "juju2"
77+
- juju-snap-channel: "2.9/stable"
78+
agent-version: "2.9.45"
79+
libjuju-version: "2.9.45.0"
80+
exclude-mark: "juju3"
81+
name: ${{ matrix.juju-snap-channel }} - (GH hosted) ${{ matrix.tox-environment }}
8882
needs:
8983
- lint
9084
- unit-test
@@ -93,48 +87,49 @@ jobs:
9387
timeout-minutes: 120
9488
steps:
9589
- name: Checkout
96-
uses: actions/checkout@v3
97-
- name: Free disk space
98-
if: ${{ matrix.free-disk-space == true }}
90+
uses: actions/checkout@v4
91+
- name: Install tox & poetry
9992
run: |
100-
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
101-
sudo rm -rf \
102-
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
103-
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
104-
/usr/lib/jvm || true
105-
- name: Set channel
93+
pipx install tox
94+
pipx install poetry
95+
- name: Free up disk space
10696
run: |
107-
juju_channel=$(echo "${{ matrix.agent-versions }}" | cut -c 1-3)
108-
echo "channel=${juju_channel}/stable" >> "$GITHUB_ENV"
109-
juju_major=$(echo "${{ matrix.agent-versions }}" | cut -c 1)
110-
echo "libjuju=juju${juju_major}" >> "$GITHUB_ENV"
97+
# From https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
98+
sudo rm -rf /usr/share/dotnet
99+
sudo rm -rf /opt/ghc
100+
sudo rm -rf /usr/local/share/boost
101+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
111102
- name: Setup operator environment
112-
# TODO: Replace with custom image on self-hosted runner
113103
uses: charmed-kubernetes/actions-operator@main
114104
with:
115105
provider: lxd
116-
bootstrap-options: "--agent-version ${{ matrix.agent-versions }}"
117-
juju-channel: "${{ env.channel }}"
106+
bootstrap-options: "--agent-version ${{ matrix.agent-version }}"
107+
juju-channel: ${{ matrix.juju-snap-channel }}
108+
- name: Update python-libjuju version
109+
if: ${{ matrix.juju-snap-channel == '2.9/stable' }}
110+
run: poetry add --lock --group integration juju@'${{ matrix.libjuju-version }}'
118111
- name: Download packed charm(s)
119112
uses: actions/download-artifact@v3
120113
with:
121114
name: ${{ needs.build.outputs.artifact-name }}
122-
- name: Select tests
123-
id: select-tests
115+
- name: Select test stability level
116+
id: select-test-stability
124117
run: |
125-
if [ "${{ github.event_name }}" == "schedule" ]
118+
if [[ "${{ github.event_name }}" == "schedule" ]]
126119
then
127120
echo Running unstable and stable tests
128-
echo "mark_expression=" >> $GITHUB_OUTPUT
121+
echo "mark_expression=" >> "$GITHUB_OUTPUT"
129122
else
130123
echo Skipping unstable tests
131-
echo "mark_expression=and not unstable" >> $GITHUB_OUTPUT
124+
echo "mark_expression=and not unstable" >> "$GITHUB_OUTPUT"
132125
fi
133126
- name: Run integration tests
134-
run: tox run -e ${{ matrix.tox-environments }}-${{ env.libjuju }} -- -m 'not not${{ env.libjuju }} ${{ steps.select-tests.outputs.mark_expression }}' --keep-models
127+
run: tox run -e ${{ matrix.tox-environment }} -- -m 'not ${{ matrix.exclude-mark }} ${{ steps.select-test-stability.outputs.mark_expression }}' --keep-models
135128
env:
136-
AWS_ACCESS_KEY: "${{ secrets.AWS_ACCESS_KEY }}"
137-
AWS_SECRET_KEY: "${{ secrets.AWS_SECRET_KEY }}"
138-
GCP_ACCESS_KEY: "${{ secrets.GCP_ACCESS_KEY }}"
139-
GCP_SECRET_KEY: "${{ secrets.GCP_SECRET_KEY }}"
140-
CI_PACKED_CHARMS: ${{ needs.build.outputs.charms }}
129+
SECRETS_FROM_GITHUB: |
130+
{
131+
"AWS_ACCESS_KEY": "${{ secrets.AWS_ACCESS_KEY }}",
132+
"AWS_SECRET_KEY": "${{ secrets.AWS_SECRET_KEY }}",
133+
"GCP_ACCESS_KEY": "${{ secrets.GCP_ACCESS_KEY }}",
134+
"GCP_SECRET_KEY": "${{ secrets.GCP_SECRET_KEY }}",
135+
}

.github/workflows/lib-check.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ on:
1414
- 'LICENSE'
1515
- '**.md'
1616
- 'renovate.json'
17-
schedule:
18-
- cron: '53 0 * * *' # Daily at 00:53 UTC
19-
# Triggered on push to branch "main" by .github/workflows/release.yaml
20-
workflow_call:
2117

2218
jobs:
2319
lib-check:
@@ -27,7 +23,7 @@ jobs:
2723
if: ${{ github.event.pull_request.head.repo.full_name == 'canonical/postgresql-operator' }}
2824
steps:
2925
- name: Checkout
30-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
26+
uses: actions/checkout@v4
3127
with:
3228
fetch-depth: 0
3329
- name: Check libs

.github/workflows/release.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@ jobs:
2020
name: Tests
2121
uses: ./.github/workflows/ci.yaml
2222
secrets: inherit
23+
permissions:
24+
actions: write # Needed to manage GitHub Actions cache
2325

2426
build:
2527
name: Build charm
26-
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v2
28+
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v5.1.2
2729

2830
release:
2931
name: Release charm
3032
needs:
3133
- ci-tests
3234
- build
33-
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v2
35+
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v5.1.2
3436
with:
3537
channel: 14/edge
3638
artifact-name: ${{ needs.build.outputs.artifact-name }}

.github/workflows/sync_issue_to_jira.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
sync:
1111
name: Sync GitHub issue to Jira
12-
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v2
12+
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v5.1.2
1313
with:
1414
jira-base-url: https://warthogs.atlassian.net
1515
jira-project-key: DPE

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ build/
66
__pycache__/
77
*.py[cod]
88
coverage.xml
9-
patroni.tar.gz
9+
requirements.txt
10+
requirements-last-build.txt
1011

1112
# PyCharm project folder.
1213
.idea/

charmcraft.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ bases:
1111
channel: "22.04"
1212
parts:
1313
charm:
14+
override-pull: |
15+
craftctl default
16+
if [[ ! -f requirements.txt ]]
17+
then
18+
echo 'ERROR: Use "tox run -e build" instead of calling "charmcraft pack" directly' >&2
19+
exit 1
20+
fi
1421
build-packages:
1522
- libffi-dev
1623
- libssl-dev

0 commit comments

Comments
 (0)