Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MISC] Reusable workflow #168

Merged
merged 23 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>canonical/data-platform//renovate_presets/charm.json5"],
"reviewers": ["dragomirp", "marceloneppel", "taurus-forever"],
"packageRules": [
// Later rules override earlier rules
{
"matchPackageNames": ["pydantic"],
"allowedVersions": "<2.0.0"
}, {
Comment on lines +7 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permanent ignores for temporary issues make me worried that we'll forget about them

maybe a better option would be to manually close the PR that renovate opens so that it adds it to the ignore list?

at the least, I'd suggest adding a comment to explain why this ignore was added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't consider this a temporary issue. There are multiple charm libs that will need to be updated to work with pydantic 2 and it also fails to compile with focal's rustc. I doubt we can make the jump anytime soon.

"matchPackageNames": ["python"],
"allowedVersions": "<3.11"
Comment on lines +11 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider disabling python updates instead—maybe we should add this to shared config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The python version is charm specific, it will vary depending on the base.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is to disable automatic python updates for all charms

}
]
}
91 changes: 23 additions & 68 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- '.jujuignore'
- 'LICENSE'
- '**.md'
- 'renovate.json'
- .github/renovate.json5
schedule:
- cron: '53 0 * * *' # Daily at 00:53 UTC
# Triggered on push to branch "main" by .github/workflows/release.yaml
Expand All @@ -22,90 +22,45 @@ on:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install tox
# TODO: Consider replacing with custom image on self-hosted runner OR pinning version
run: python3 -m pip install tox
- name: Run linters
run: tox run -e lint
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v8.0.0

unit-test:
name: Unit tests
name: Unit test charm
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install tox
# TODO: Consider replacing with custom image on self-hosted runner OR pinning version
run: python3 -m pip install tox
- name: Install tox & poetry
run: |
pipx install tox
pipx install poetry
- name: Run tests
run: tox run -e unit

build:
name: Build charms
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v2
name: Build charm
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v8.0.0
permissions:
actions: write # Needed to manage GitHub Actions cache

integration-test:
strategy:
fail-fast: false
max-parallel: 6
matrix:
tox-environments:
- backend-integration
- client-relation-integration
- scaling-integration
- tls-integration
- standalone-integration
- legacy-client-relation-integration
- upgrade-integration
agent-versions:
- "2.9.45" # renovate: latest juju 2
- "3.1.6" # renovate: latest juju 3
name: ${{ matrix.tox-environments }} | ${{ matrix.agent-versions }}
juju:
- agent: 2.9.46
libjuju: ^2
- agent: 3.1.6
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backend relation fails on 3.1.7. Will investigate separately.

name: Integration test charm | ${{ matrix.juju.agent }}
needs:
- lint
- unit-test
- build
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set channel
run: |
juju_channel=$(echo "${{ matrix.agent-versions }}" | cut -c 1-3)
echo "channel=${juju_channel}/stable" >> "$GITHUB_ENV"
juju_major=$(echo "${{ matrix.agent-versions }}" | cut -c 1)
echo "libjuju=juju${juju_major}" >> "$GITHUB_ENV"
- name: Setup operator environment
# TODO: Replace with custom image on self-hosted runner
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
channel: "1.28-strict/stable"
bootstrap-options: "--agent-version ${{ matrix.agent-versions }}"
juju-channel: "${{ env.channel }}"
- name: Download packed charm(s)
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.artifact-name }}
- name: Select tests
id: select-tests
run: |
if [ "${{ github.event_name }}" == "schedule" ]
then
echo Running unstable and stable tests
echo "mark_expression=" >> $GITHUB_OUTPUT
else
echo Skipping unstable tests
echo "mark_expression=not unstable" >> $GITHUB_OUTPUT
fi
- name: Run integration tests
run: tox run -e ${{ matrix.tox-environments }}-${{ env.libjuju }} -- -m '${{ steps.select-tests.outputs.mark_expression }}'
env:
CI_PACKED_CHARMS: ${{ needs.build.outputs.charms }}
uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v8.0.0
with:
artifact-name: ${{ needs.build.outputs.artifact-name }}
cloud: microk8s
microk8s-snap-channel: 1.29-strict/stable
juju-agent-version: ${{ matrix.juju.agent }}
libjuju-version-constraint: ${{ matrix.juju.libjuju }}
11 changes: 11 additions & 0 deletions .github/workflows/lib-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up environment
run: |
pipx install tox
pipx install poetry
pipx inject poetry poetry-plugin-export
# TODO: Remove after https://github.com/python-poetry/poetry/pull/5980 is closed
poetry config warnings.export false
- name: Generate requirements
run: |
tox run -e pack-wrapper
mv requirements-last-build.txt requirements.txt
- name: Check libs
uses: canonical/charming-actions/check-libraries@2.4.0
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ on:
paths-ignore:
- 'tests/**'
- 'docs/**'
- renovate.json
- poetry.lock
- .github/renovate.json5
- pyproject.toml
- '.github/workflows/ci.yaml'
- '.github/workflows/lib-check.yaml'
Expand All @@ -20,6 +19,8 @@ jobs:
name: Tests
uses: ./.github/workflows/ci.yaml
secrets: inherit
permissions:
actions: write # Needed to manage GitHub Actions cache

release-libraries:
name: Release libraries
Expand All @@ -40,14 +41,14 @@ jobs:

build:
name: Build charm
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v2
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v8.0.0

release:
name: Release charm
needs:
- ci-tests
- build
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v2
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v8.0.0
with:
channel: 1/edge
artifact-name: ${{ needs.build.outputs.artifact-name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync_issue_to_jira.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
sync:
name: Sync GitHub issue to Jira
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v2
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v8.0.0
with:
jira-base-url: https://warthogs.atlassian.net
jira-project-key: DPE
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ build/
.coverage
__pycache__/
*.py[cod]
*.log
*.log
/requirements.txt
/requirements-last-build.txt
12 changes: 10 additions & 2 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ bases:

parts:
charm:
override-pull: |
craftctl default
if [[ ! -f requirements.txt ]]
then
echo 'ERROR: Use "tox run -e build" instead of calling "charmcraft pack" directly' >&2
exit 1
fi
charm-strict-dependencies: true
build-packages:
- libffi-dev
- libssl-dev
- rustc
- cargo
- pkg-config
charm-binary-python-packages:
- psycopg2-binary==2.9.9 # renovate
- psycopg[binary]==3.1.12 # renovate
- psycopg2-binary
- psycopg-binary
Loading