Charmcraft test #2318
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2022 Canonical Ltd. | |
# See LICENSE file for licensing details. | |
name: Tests | |
on: | |
pull_request: | |
schedule: | |
- cron: '53 0 * * *' # Daily at 00:53 UTC | |
# Triggered on push to branch "main" by .github/workflows/release.yaml | |
workflow_call: | |
outputs: | |
artifact-prefix: | |
description: build_charm.yaml `artifact-prefix` output | |
value: ${{ jobs.build.outputs.artifact-prefix }} | |
jobs: | |
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 }}' |