Skip to content

Commit

Permalink
spread hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical committed Jan 21, 2025
1 parent 7849247 commit 797e606
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,55 @@ jobs:
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
with:
charmcraft-snap-channel: latest/candidate # TODO: remove after charmcraft 3.3 stable release

collect-integration-tests:
name: Collect integration test spread jobs
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up environment
run: sudo snap install charmcraft --classic --channel latest/candidate
- name: Collect spread jobs
id: collect-jobs
shell: python
run: |
import json
import os
import subprocess
jobs = (
subprocess.run(
["charmcraft", "test", "--list", "github-ci"], capture_output=True, check=True, text=True
)
.stdout.strip()
.split("\n")
)
output = f"jobs={json.dumps(jobs)}"
print(output)
with open(os.environ["GITHUB_OUTPUT"], "a") as file:
file.write(output)
outputs:
jobs: ${{ steps.collect-jobs.outputs.jobs }}

integration-test:
strategy:
fail-fast: false
matrix:
spread-job: ${{ fromJSON(needs.collect-integration-tests.outputs.jobs) }}
name: Spread ${{ matrix.spread-job }}
needs:
- collect-integration-tests
runs-on: ubuntu-latest
timeout-minutes: 200 # TODO
steps:
- name: Checkout
timeout-minutes: 3
uses: actions/checkout@v4
- name: Set up environment
timeout-minutes: 5
run: sudo snap install charmcraft --classic --channel latest/candidate
- name: Run spread job
timeout-minutes: 120
run: charmcraft test '${{ matrix.spread-job }}'
28 changes: 28 additions & 0 deletions spread.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
project: mysql-router-k8s-operator

backends:
github-ci:
type: adhoc
# Only run on CI
manual: true
# HACK: spread requires runners to be accessible via SSH
# Configure local sshd & instruct spread to connect to the same machine spread is running on
# (spread cannot provision GitHub Actions runners, so we provision a GitHub Actions runner for
# each spread job & select a single job when running spread)
# Derived from https://github.com/jnsgruk/zinc-k8s-operator/blob/e2371961e0c18a21fc7bdbd0a7046a3550ce8538/spread.yaml#L47
allocate: |
sudo tee /etc/ssh/sshd_config.d/10-spread-github-ci.conf << 'EOF'
PasswordAuthentication yes
PermitEmptyPasswords yes
EOF
ADDRESS localhost
systems:
- ubuntu-latest:
username: runner

suites:
tests/spread/:
summary: Spread tests

path: /remote/path
4 changes: 4 additions & 0 deletions tests/spread/foo/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
summary: foo
execute: |
echo "Hello world!"
exit 1

0 comments on commit 797e606

Please sign in to comment.