Skip to content
Open
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
218 changes: 218 additions & 0 deletions .github/workflows/example-charm-integration-tests-prs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
name: Selected Example Charm Integration Tests

on:
pull_request:

permissions: {}

concurrency:
# Cancel in-flight runs when new commits are pushed to the same PR.
group: example-charm-integration-tests-prs-${{ github.ref }}
cancel-in-progress: true

Comment on lines +8 to +12

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd be fine with dropping this. It can be quite annoying having to wait for integration tests to start from scratch because you pushed a little unrelated docs change or whatever -- and likewise, I think it's bad if you're incentivised to delay pushing to not interrupt the test run.

jobs:
# Detect which example directories have changed on this PR.
detect-changes:
runs-on: ubuntu-latest
outputs:
machine-tinyproxy: ${{ steps.check.outputs.machine-tinyproxy }}
k8s-1-minimal: ${{ steps.check.outputs.k8s-1-minimal }}
k8s-2-configurable: ${{ steps.check.outputs.k8s-2-configurable }}
k8s-3-postgresql: ${{ steps.check.outputs.k8s-3-postgresql }}
k8s-4-action: ${{ steps.check.outputs.k8s-4-action }}
k8s-5-observe: ${{ steps.check.outputs.k8s-5-observe }}
httpbin-demo: ${{ steps.check.outputs.httpbin-demo }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0 # Need full history to diff against the base branch.
- id: check
run: |
examples='machine-tinyproxy k8s-1-minimal k8s-2-configurable k8s-3-postgresql k8s-4-action k8s-5-observe httpbin-demo'
# GITHUB_BASE_REF is a default env var set by GitHub Actions.
base="origin/$GITHUB_BASE_REF"
for dir in $examples; do
if git diff --name-only "$base...HEAD" -- "examples/$dir/" | grep -q .; then
echo "$dir=true" >> "$GITHUB_OUTPUT"
else
echo "$dir=false" >> "$GITHUB_OUTPUT"
fi
done

machine-tinyproxy:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.machine-tinyproxy == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Install Concierge
run: sudo snap install --classic concierge
- name: Prepare for deploying machine charms
run: sudo concierge prepare -p machine
timeout-minutes: 90 # Abandon the job if the GHA runner gets stuck.
- name: Pack charm
working-directory: examples/machine-tinyproxy
run: charmcraft pack
- name: Run integration tests
working-directory: examples/machine-tinyproxy
run: tox -e integration

k8s-1-minimal:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.k8s-1-minimal == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Install Concierge
run: sudo snap install --classic concierge
- name: Prepare for deploying K8s charms
run: sudo concierge prepare -p k8s
timeout-minutes: 90 # Abandon the job if the GHA runner gets stuck.
- name: Pack charm
working-directory: examples/k8s-1-minimal
run: charmcraft pack
- name: Run integration tests
working-directory: examples/k8s-1-minimal
run: tox -e integration

k8s-2-configurable:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.k8s-2-configurable == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Install Concierge
run: sudo snap install --classic concierge
- name: Prepare for deploying K8s charms
run: sudo concierge prepare -p k8s
timeout-minutes: 90 # Abandon the job if the GHA runner gets stuck.
- name: Pack charm
working-directory: examples/k8s-2-configurable
run: charmcraft pack
- name: Run integration tests
working-directory: examples/k8s-2-configurable
run: tox -e integration

k8s-3-postgresql:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.k8s-3-postgresql == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Install Concierge
run: sudo snap install --classic concierge
- name: Prepare for deploying K8s charms
run: sudo concierge prepare -p k8s
timeout-minutes: 90 # Abandon the job if the GHA runner gets stuck.
- name: Fetch charmlibs
working-directory: examples/k8s-3-postgresql
run: charmcraft fetch-libs
- name: Pack charm
working-directory: examples/k8s-3-postgresql
run: charmcraft pack
- name: Run integration tests
working-directory: examples/k8s-3-postgresql
run: tox -e integration

k8s-4-action:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.k8s-4-action == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Install Concierge
run: sudo snap install --classic concierge
- name: Prepare for deploying K8s charms
run: sudo concierge prepare -p k8s
timeout-minutes: 90 # Abandon the job if the GHA runner gets stuck.
- name: Fetch charmlibs
working-directory: examples/k8s-4-action
run: charmcraft fetch-libs
- name: Pack charm
working-directory: examples/k8s-4-action
run: charmcraft pack
- name: Run integration tests
working-directory: examples/k8s-4-action
run: tox -e integration

k8s-5-observe:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.k8s-5-observe == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Install Concierge
run: sudo snap install --classic concierge
- name: Prepare for deploying K8s charms
run: sudo concierge prepare -p k8s
timeout-minutes: 90 # Abandon the job if the GHA runner gets stuck.
- name: Fetch charmlibs
working-directory: examples/k8s-5-observe
run: charmcraft fetch-libs
- name: Pack charm
working-directory: examples/k8s-5-observe
run: charmcraft pack
- name: Run integration tests
working-directory: examples/k8s-5-observe
run: tox -e integration

httpbin-demo:
needs: detect-changes
if: ${{ needs.detect-changes.outputs.httpbin-demo == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
- name: Set up tox and tox-uv
run: uv tool install tox --with tox-uv
- name: Install Concierge
run: sudo snap install --classic concierge
- name: Prepare for deploying K8s charms
run: sudo concierge prepare -p k8s
timeout-minutes: 90 # Abandon the job if the GHA runner gets stuck.
- name: Pack charm
working-directory: examples/httpbin-demo
run: charmcraft pack
- name: Run integration tests
working-directory: examples/httpbin-demo
run: tox -e integration