Skip to content

Commit fe2252d

Browse files
ci: let matrix tests run for a single interface from a PR branch (canonical#292)
This PR moves the logic to invoke the matrix tests for an individual interface to a reusable workflow, and allows specifying the repository and branch to fetch the test and interface definitions from. This will allow the tests added by a PR to be (manually) run in the CI context before merging, instead of only being able to test them locally.
1 parent 19aa517 commit fe2252d

File tree

2 files changed

+58
-16
lines changed

2 files changed

+58
-16
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Matrix tests for a specific interface
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
interface:
7+
description: 'The interface to run tests for'
8+
required: true
9+
type: string
10+
repo:
11+
description: 'The repo to fetch the test and interfaces definitions from'
12+
default: 'https://github.com/canonical/charm-relation-interfaces'
13+
required: false
14+
type: string
15+
branch:
16+
description: 'The branch of the repo to fetch the test and interface definitions from'
17+
default: 'main'
18+
required: false
19+
type: string
20+
workflow_call:
21+
inputs:
22+
interface:
23+
description: 'The interface to run tests for'
24+
required: true
25+
type: string
26+
repo:
27+
description: 'The repo to fetch the test and interfaces definitions from'
28+
default: 'https://github.com/canonical/charm-relation-interfaces'
29+
required: false
30+
type: string
31+
branch:
32+
description: 'The branch of the repo to fetch the test and interface definitions from'
33+
default: 'main'
34+
required: false
35+
type: string
36+
37+
jobs:
38+
matrix-tests:
39+
name: 'Matrix tests for ${{ inputs.interface }}'
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 1
46+
- name: Set up python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: 3.8
50+
- name: Install dependencies
51+
run: pip install tox uv poetry
52+
- name: Run tests
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_WITH_TEAM }}
55+
run: tox -e run-interface-test-matrix -- --include ${{ inputs.interface }} --repo ${{ inputs.repo }} --branch ${{ inputs.branch }}

.github/workflows/matrix-tests.yaml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,10 @@ jobs:
2424
main:
2525
name: ${{ matrix.interface }}
2626
needs: set-matrix
27-
runs-on: ubuntu-latest
2827
strategy:
2928
fail-fast: false
3029
matrix:
3130
interface: ${{ fromJSON(needs.set-matrix.outputs.matrix_values) }}
32-
steps:
33-
- name: Checkout
34-
uses: actions/checkout@v4
35-
with:
36-
fetch-depth: 1
37-
- name: Set up python
38-
uses: actions/setup-python@v5
39-
with:
40-
python-version: 3.8
41-
- name: Install dependencies
42-
run: pip install tox uv poetry
43-
- name: Run tests
44-
env:
45-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_WITH_TEAM }}
46-
run: tox -e run-interface-test-matrix -- --include ${{ matrix.interface }}
31+
uses: ./.github/workflows/dispatch-matrix-tests.yaml
32+
with:
33+
interface: ${{ matrix.interface }}

0 commit comments

Comments
 (0)