Skip to content

Commit 58dd2ef

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 58dd2ef

10 files changed

Lines changed: 178 additions & 256 deletions

File tree

.github/workflows/cypress.yml

Lines changed: 42 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,45 @@ 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+
outputs:
42+
should_run: ${{ steps.evaluate.outputs.should_run }}
43+
reason: ${{ steps.evaluate.outputs.reason }}
44+
steps:
45+
- name: Evaluate e2e tests execution conditions
46+
id: evaluate
47+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v8.0.0
48+
with:
49+
script: |
50+
const pr = context.payload.pull_request
51+
52+
const hasForceLabel = pr.labels.some((label) => label.name === 'force-e2e-tests')
53+
const hasToReviewLabel = pr.labels.some((label) => label.name === '3. to review')
54+
const hasToReleaseLabel = pr.labels.some((label) => label.name === '4. to release')
55+
56+
const files = await github.paginate(github.rest.pulls.listFiles, {
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
pull_number: pr.number,
60+
per_page: 100,
61+
})
62+
const cypressTouched = files.some((file) => file.filename.startsWith('cypress'))
63+
64+
if (hasForceLabel || hasToReviewLabel || hasToReleaseLabel || cypressTouched) {
65+
return
66+
} else {
67+
core.setFailed('Skipping Cypress: draft state, missing labels or no cypress path changes.')
68+
}
69+
3270
init:
3371
runs-on: ubuntu-latest
72+
needs: gate
3473
outputs:
3574
nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
3675
npmVersion: ${{ steps.versions.outputs.npmVersion }}
@@ -98,7 +137,7 @@ jobs:
98137

99138
cypress:
100139
runs-on: ubuntu-latest
101-
needs: init
140+
needs: [gate, init]
102141

103142
strategy:
104143
fail-fast: false

.github/workflows/playwright.yml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,54 @@ 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+
outputs:
23+
should_run: ${{ steps.evaluate.outputs.should_run }}
24+
reason: ${{ steps.evaluate.outputs.reason }}
25+
steps:
26+
- name: Evaluate e2e tests execution conditions
27+
id: evaluate
28+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v8.0.0
29+
with:
30+
script: |
31+
const pr = context.payload.pull_request
32+
33+
const hasForceLabel = pr.labels.some((label) => label.name === 'force-e2e-tests')
34+
const hasToReviewLabel = pr.labels.some((label) => label.name === '3. to review')
35+
const hasToReleaseLabel = pr.labels.some((label) => label.name === '4. to release')
36+
37+
const files = await github.paginate(github.rest.pulls.listFiles, {
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
pull_number: pr.number,
41+
per_page: 100,
42+
})
43+
const playwrightTouched = files.some((file) => file.filename.startsWith('tests/playwright'))
44+
45+
if (hasForceLabel || hasToReviewLabel || hasToReleaseLabel || playwrightTouched) {
46+
return
47+
} else {
48+
core.setFailed('Skipping Playwright: draft state, missing labels or no playwright path changes.')
49+
}
50+
1451
playwright-setup:
1552
timeout-minutes: 15
1653
name: Playwright setup
1754
runs-on: ubuntu-latest
55+
needs: gate
1856
steps:
1957
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2058
with:
@@ -40,7 +78,7 @@ jobs:
4078
path: ./
4179

4280
playwright-tests:
43-
needs: [playwright-setup]
81+
needs: [gate, playwright-setup]
4482
timeout-minutes: 60
4583
name: Playwright tests ${{ matrix.shardIndex }} / ${{ matrix.shardTotal }}
4684
runs-on: ubuntu-latest
@@ -115,7 +153,7 @@ jobs:
115153
merge-reports:
116154
# Merge reports after playwright-tests, even if some shards have failed
117155
if: ${{ !cancelled() }}
118-
needs: [playwright-tests]
156+
needs: [gate, playwright-tests]
119157

120158
runs-on: ubuntu-latest-low
121159
steps:
@@ -171,7 +209,7 @@ jobs:
171209
permissions:
172210
contents: none
173211
runs-on: ubuntu-latest-low
174-
needs: [playwright-tests]
212+
needs: [gate, playwright-tests]
175213

176214
if: always()
177215

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)