Skip to content

Commit 184866a

Browse files
CarlSchwanartonge
authored andcommitted
test(ci): Do not always run e2e tests
Signed-off-by: Louis Chmn <louis@chmn.me>
2 parents 6470514 + a459b9c commit 184866a

10 files changed

Lines changed: 172 additions & 256 deletions

File tree

.github/workflows/cypress.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88

99
name: Cypress
1010

11-
on: pull_request
11+
on:
12+
pull_request:
13+
types:
14+
- opened
15+
- synchronize
16+
- reopened
17+
- ready_for_review
18+
- labeled
1219

1320
concurrency:
1421
group: cypress-${{ github.head_ref || github.run_id }}
@@ -24,13 +31,42 @@ env:
2431
# n.b. server will use head_ref, as we want to test the PR branch.
2532
BRANCH: ${{ github.base_ref || github.ref_name }}
2633

27-
2834
permissions:
2935
contents: read
36+
pull-requests: read
3037

3138
jobs:
39+
gate:
40+
runs-on: ubuntu-latest-low
41+
steps:
42+
- name: Evaluate e2e tests execution conditions
43+
id: gate-e2e
44+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v8.0.0
45+
with:
46+
script: |
47+
const pr = context.payload.pull_request
48+
49+
const hasForceLabel = pr.labels.some((label) => label.name === 'force-e2e-tests')
50+
const hasToReviewLabel = pr.labels.some((label) => label.name === '3. to review')
51+
const hasToReleaseLabel = pr.labels.some((label) => label.name === '4. to release')
52+
53+
const files = await github.paginate(github.rest.pulls.listFiles, {
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
pull_number: pr.number,
57+
per_page: 100,
58+
})
59+
const cypressTouched = files.some((file) => file.filename.startsWith('cypress'))
60+
61+
if (hasForceLabel || hasToReviewLabel || hasToReleaseLabel || cypressTouched) {
62+
return
63+
} else {
64+
core.setFailed('Skipping Cypress: draft state, missing labels or no cypress path changes.')
65+
}
66+
3267
init:
3368
runs-on: ubuntu-latest
69+
needs: gate
3470
outputs:
3571
nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
3672
npmVersion: ${{ steps.versions.outputs.npmVersion }}
@@ -98,7 +134,7 @@ jobs:
98134

99135
cypress:
100136
runs-on: ubuntu-latest
101-
needs: init
137+
needs: [gate, init]
102138

103139
strategy:
104140
fail-fast: false

.github/workflows/playwright.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,51 @@ name: Playwright Tests
55

66
on:
77
pull_request:
8-
branches: [ master ]
8+
branches: [master]
9+
types:
10+
- opened
11+
- synchronize
12+
- reopened
13+
- ready_for_review
14+
- labeled
915

1016
permissions:
1117
contents: read
1218

1319
jobs:
20+
gate:
21+
runs-on: ubuntu-latest-low
22+
steps:
23+
- name: Evaluate e2e tests execution conditions
24+
id: gate-e2e
25+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v8.0.0
26+
with:
27+
script: |
28+
const pr = context.payload.pull_request
29+
30+
const hasForceLabel = pr.labels.some((label) => label.name === 'force-e2e-tests')
31+
const hasToReviewLabel = pr.labels.some((label) => label.name === '3. to review')
32+
const hasToReleaseLabel = pr.labels.some((label) => label.name === '4. to release')
33+
34+
const files = await github.paginate(github.rest.pulls.listFiles, {
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
pull_number: pr.number,
38+
per_page: 100,
39+
})
40+
const playwrightTouched = files.some((file) => file.filename.startsWith('tests/playwright'))
41+
42+
if (hasForceLabel || hasToReviewLabel || hasToReleaseLabel || playwrightTouched) {
43+
return
44+
} else {
45+
core.setFailed('Skipping Playwright: draft state, missing labels or no playwright path changes.')
46+
}
47+
1448
playwright-setup:
1549
timeout-minutes: 15
1650
name: Playwright setup
1751
runs-on: ubuntu-latest
52+
needs: gate
1853
steps:
1954
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2055
with:
@@ -40,7 +75,7 @@ jobs:
4075
path: ./
4176

4277
playwright-tests:
43-
needs: [playwright-setup]
78+
needs: [gate, playwright-setup]
4479
timeout-minutes: 60
4580
name: Playwright tests ${{ matrix.shardIndex }} / ${{ matrix.shardTotal }}
4681
runs-on: ubuntu-latest
@@ -115,7 +150,7 @@ jobs:
115150
merge-reports:
116151
# Merge reports after playwright-tests, even if some shards have failed
117152
if: ${{ !cancelled() }}
118-
needs: [playwright-tests]
153+
needs: [gate, playwright-tests]
119154

120155
runs-on: ubuntu-latest-low
121156
steps:
@@ -171,7 +206,7 @@ jobs:
171206
permissions:
172207
contents: none
173208
runs-on: ubuntu-latest-low
174-
needs: [playwright-tests]
209+
needs: [gate, playwright-tests]
175210

176211
if: always()
177212

config/config.sample.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,15 +1659,6 @@
16591659
*/
16601660
'comments.managerFactory' => '\OC\Comments\ManagerFactory',
16611661

1662-
/**
1663-
* Replaces the default System Tags Manager Factory. This can be utilized if an
1664-
* own or 3rd-party SystemTagsManager should be used that – for instance – uses the
1665-
* filesystem instead of the database to keep the tags.
1666-
*
1667-
* Defaults to ``\OC\SystemTag\ManagerFactory``
1668-
*/
1669-
'systemtags.managerFactory' => '\OC\SystemTag\ManagerFactory',
1670-
16711662
/**
16721663
* Maintenance
16731664
*

lib/private/Activity/EventMerger.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
use OCP\Activity\IEvent;
1111
use OCP\Activity\IEventMerger;
1212
use OCP\IL10N;
13+
use OCP\L10N\IFactory;
1314

1415
class EventMerger implements IEventMerger {
15-
/**
16-
* @param IL10N $l10n
17-
*/
16+
private readonly IL10N $l10n;
17+
1818
public function __construct(
19-
protected IL10N $l10n,
19+
IFactory $factory,
2020
) {
21+
$this->l10n = $factory->get('lib');
2122
}
2223

2324
/**

lib/private/App/AppStore/Bundles/BundleFetcher.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
namespace OC\App\AppStore\Bundles;
99

1010
use OCP\IL10N;
11+
use OCP\L10N\IFactory;
1112

1213
class BundleFetcher {
14+
private IL10N $l10n;
1315
public function __construct(
14-
private IL10N $l10n,
16+
IFactory $factory,
1517
) {
18+
$this->l10n = $factory->get('lib');
1619
}
1720

1821
/**

lib/private/Diagnostics/QueryLogger.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace OC\Diagnostics;
1010

11+
use OC\SystemConfig;
1112
use OCP\Cache\CappedMemoryCache;
1213
use OCP\Diagnostics\IQueryLogger;
1314

@@ -20,7 +21,11 @@ class QueryLogger implements IQueryLogger {
2021
/**
2122
* QueryLogger constructor.
2223
*/
23-
public function __construct() {
24+
public function __construct(SystemConfig $config) {
25+
if ($config->getValue('debug', false)) {
26+
// In debug mode, module is being activated by default
27+
$this->activate();
28+
}
2429
$this->queries = new CappedMemoryCache(1024);
2530
}
2631

0 commit comments

Comments
 (0)