Skip to content

Commit 567a354

Browse files
authored
Reduce number of tests. By @bigtedde (#1780)
1 parent e5c9b22 commit 567a354

File tree

2 files changed

+61
-17
lines changed

2 files changed

+61
-17
lines changed

.github/scripts/generate-matrix.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
event_name="$1"
2+
branch_name="$2"
3+
4+
if [[ "$event_name" == "workflow_dispatch" ]] || [[ "$branch_name" == "master" ]]; then
5+
echo '{
6+
"python-version": ["3.8", "3.9", "3.10", "3.11"],
7+
"os": ["ubuntu-latest", "macos-latest"],
8+
"borg-version": ["1.2.4"]
9+
}' | jq -c . > matrix-unit.json
10+
11+
echo '{
12+
"python-version": ["3.8", "3.9", "3.10", "3.11"],
13+
"os": ["ubuntu-latest", "macos-latest"],
14+
"borg-version": ["1.1.18", "1.2.2", "1.2.4", "2.0.0b5"],
15+
"exclude": [{"borg-version": "2.0.0b5", "python-version": "3.8"}]
16+
}' | jq -c . > matrix-integration.json
17+
18+
elif [[ "$event_name" == "push" ]] || [[ "$event_name" == "pull_request" ]]; then
19+
echo '{
20+
"python-version": ["3.8", "3.9", "3.10", "3.11"],
21+
"os": ["ubuntu-latest", "macos-latest"],
22+
"borg-version": ["1.2.4"]
23+
}' | jq -c . > matrix-unit.json
24+
25+
echo '{
26+
"python-version": ["3.10"],
27+
"os": ["ubuntu-latest"],
28+
"borg-version": ["1.2.4"]
29+
}' | jq -c . > matrix-integration.json
30+
fi

.github/workflows/test.yml

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,36 @@ jobs:
2626
shell: bash
2727
run: make lint
2828

29+
prepare-matrix:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
matrix-unit: ${{ steps.set-matrix-unit.outputs.matrix }}
33+
matrix-integration: ${{ steps.set-matrix-integration.outputs.matrix }}
34+
steps:
35+
- uses: actions/checkout@v3
36+
37+
- name: Give execute permission to script
38+
run: chmod +x ./.github/scripts/generate-matrix.sh
39+
40+
- name: Generate matrices
41+
run: |
42+
./.github/scripts/generate-matrix.sh "${{ github.event_name }}" "${GITHUB_REF##refs/heads/}"
43+
44+
- name: Set matrix for unit tests
45+
id: set-matrix-unit
46+
run: echo "matrix=$(cat matrix-unit.json)" >> $GITHUB_OUTPUT
47+
48+
- name: Set matrix for integration tests
49+
id: set-matrix-integration
50+
run: echo "matrix=$(cat matrix-integration.json)" >> $GITHUB_OUTPUT
51+
2952
test-unit:
53+
needs: prepare-matrix
3054
timeout-minutes: 20
3155
runs-on: ${{ matrix.os }}
3256
strategy:
3357
fail-fast: false
34-
35-
matrix:
36-
python-version: ["3.8", "3.9", "3.10", "3.11"]
37-
os: [ubuntu-latest, macos-latest]
38-
borg-version: ["1.2.4"]
58+
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix-unit)}}
3959

4060
steps:
4161
- uses: actions/checkout@v3
@@ -51,15 +71,15 @@ jobs:
5171

5272
- name: Setup tmate session
5373
uses: mxschmitt/action-tmate@v3
54-
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
74+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
5575

5676
- name: Run Unit Tests with pytest (Linux)
5777
if: runner.os == 'Linux'
5878
env:
5979
BORG_VERSION: ${{ matrix.borg-version }}
6080
run: |
6181
xvfb-run --server-args="-screen 0 1024x768x24+32" \
62-
-a dbus-run-session -- make test-unit
82+
-a dbus-run-session -- make test-unit
6383
6484
- name: Run Unit Tests with pytest (macOS)
6585
if: runner.os == 'macOS'
@@ -78,18 +98,12 @@ jobs:
7898
env_vars: OS, python
7999

80100
test-integration:
101+
needs: prepare-matrix
81102
timeout-minutes: 20
82103
runs-on: ${{ matrix.os }}
83104
strategy:
84105
fail-fast: false
85-
86-
matrix:
87-
python-version: ["3.8", "3.9", "3.10", "3.11"]
88-
os: [ubuntu-latest, macos-latest]
89-
borg-version: ["1.1.18", "1.2.2", "1.2.4", "2.0.0b5"]
90-
exclude:
91-
- borg-version: "2.0.0b5"
92-
python-version: "3.8"
106+
matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix-integration)}}
93107

94108
steps:
95109
- uses: actions/checkout@v3
@@ -105,15 +119,15 @@ jobs:
105119

106120
- name: Setup tmate session
107121
uses: mxschmitt/action-tmate@v3
108-
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
122+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true'}}
109123

110124
- name: Run Integration Tests with pytest (Linux)
111125
if: runner.os == 'Linux'
112126
env:
113127
BORG_VERSION: ${{ matrix.borg-version }}
114128
run: |
115129
xvfb-run --server-args="-screen 0 1024x768x24+32" \
116-
-a dbus-run-session -- make test-integration
130+
-a dbus-run-session -- make test-integration
117131
118132
- name: Run Integration Tests with pytest (macOS)
119133
if: runner.os == 'macOS'

0 commit comments

Comments
 (0)