Skip to content

Commit 79ef277

Browse files
committed
ci: compile on CI after merge to reduce conflicts and total CI time
One of the biggest CI problems we currently face are conflicts, not within source code but in compiled assets. So if you have 2 PRs targeting e.g. files then the assets will likely conflict even if the source can be merged without problems. This causes unnecessary CI time and developer frustration. Another really bad example: Dependency updates. So this solution is the currently lived soltion of the `text` app: 1. we add a CI check to forbid checking in compiled assets 2. we adjust the node workflow to no longer check for asset changes 3. we add a CI workflow to compile after merges. For the corner case where a new PR is merged before the compilation has finished this will abort the first compile and start a new one for the current HEAD. So this also reduces the repository size in cases of many quick merged like during dependabot updates. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 887dfeb commit 79ef277

3 files changed

Lines changed: 127 additions & 16 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
name: Check node dist files
5+
6+
on:
7+
pull_request:
8+
9+
10+
jobs:
11+
changed_files:
12+
runs-on: ubuntu-latest
13+
name: Check node dist files
14+
permissions:
15+
pull-requests: read
16+
17+
steps:
18+
- name: Get changed files
19+
id: changed-files
20+
uses: tj-actions/changed-files@dcc7a0cba800f454d79fff4b993e8c3555bcc0a8 # v45.0.7
21+
with:
22+
files: dist/**
23+
24+
- name: Run step if any file(s) in the docs folder change
25+
if: steps.changed-files.outputs.any_changed == 'true'
26+
run: |
27+
echo "One or more files in the js folder has changed. Do NOT commit files in there as they will be generated automatically once a pull request is merged"
28+
echo "List all the files that have changed: ${{ steps.changed-files.outputs.all_changed_files }}"
29+
exit 1
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
77
# SPDX-License-Identifier: MIT
88

9-
name: Node
9+
name: Build Javascript
1010

1111
on: pull_request
1212

@@ -35,17 +35,14 @@ jobs:
3535
filters: |
3636
src:
3737
- '.github/workflows/**'
38-
- '**/src/**'
39-
- '**/appinfo/info.xml'
40-
- 'core/css/*'
41-
- 'core/img/**'
38+
- 'src/**'
39+
- 'appinfo/info.xml'
4240
- 'package.json'
43-
- '**/package-lock.json'
41+
- 'package-lock.json'
4442
- 'tsconfig.json'
4543
- '**.js'
4644
- '**.ts'
4745
- '**.vue'
48-
- 'version.php'
4946
5047
build:
5148
runs-on: ubuntu-latest
@@ -90,16 +87,17 @@ jobs:
9087
npm ci
9188
npm run build --if-present
9289
93-
- name: Check build changes
94-
run: |
95-
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
90+
# Not used as we compile on CI, see update-node-dist.yml and node-dist-unchanged.yml
91+
# - name: Check build changes
92+
# run: |
93+
# bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
9694

97-
- name: Show changes on failure
98-
if: failure()
99-
run: |
100-
git status
101-
git --no-pager diff
102-
exit 1 # make it red to grab attention
95+
# - name: Show changes on failure
96+
# if: failure()
97+
# run: |
98+
# git status
99+
# git --no-pager diff
100+
# exit 1 # make it red to grab attention
103101

104102
summary:
105103
permissions:
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
name: Update Node dist
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
# implemented since 35, once branched off, add your stable branch here
11+
- master
12+
13+
permissions:
14+
contents: write
15+
16+
concurrency:
17+
group: update-node-dist-${{ github.head_ref || github.ref || github.run_id }}
18+
19+
jobs:
20+
update-node-dist:
21+
runs-on: ubuntu-latest
22+
environment: update-node-dist
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
with:
28+
# Needed to allow force push later
29+
persist-credentials: true
30+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
31+
32+
- name: Read package.json node and npm engines version
33+
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.1
34+
id: versions
35+
with:
36+
fallbackNode: '^20'
37+
fallbackNpm: '^9'
38+
39+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
40+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
41+
with:
42+
node-version: ${{ steps.versions.outputs.nodeVersion }}
43+
44+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
45+
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
46+
47+
- name: Setup git
48+
run: |
49+
git config --local user.email "nextcloud-command@users.noreply.github.com"
50+
git config --local user.name "nextcloud-command"
51+
52+
- name: Get last commit message if it was not a recompile
53+
id: last_commit
54+
run: |
55+
{
56+
echo 'MESSAGE<<EOF'
57+
git log -1 --pretty=%s | grep -v '^chore(assets): recompile assets$' || test $? -eq 1
58+
echo 'EOF'
59+
} >> $GITHUB_OUTPUT
60+
61+
- name: Install dependencies & build
62+
if: steps.last_commit.outputs.MESSAGE != ''
63+
env:
64+
CYPRESS_INSTALL_BINARY: 0
65+
run: |
66+
npm ci
67+
npm run build --if-present
68+
69+
- name: Check webpack build changes
70+
id: changes
71+
continue-on-error: true
72+
run: |
73+
{
74+
echo 'CHANGED<<EOF'
75+
git status --porcelain
76+
echo 'EOF'
77+
} >> "$GITHUB_OUTPUT"
78+
79+
- name: Add and commit
80+
if: steps.changes.outputs.CHANGED != ''
81+
run: |
82+
git add --force dist/ core/css/
83+
git commit --signoff -m 'chore(assets): recompile assets'
84+
git push origin ${{ github.head_ref }}

0 commit comments

Comments
 (0)