-
Notifications
You must be signed in to change notification settings - Fork 92
166 lines (140 loc) · 6.38 KB
/
pull-checks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Additional tests for pull requests
on:
pull_request:
jobs:
changelog:
name: Check if the changelog was updated
runs-on: ubuntu-22.04
steps:
- name: Checkout the app
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get the diff
id: diff
run: |
git diff HEAD~1 -- CHANGELOG.md
lines=$(git diff HEAD~1 -- CHANGELOG.md | wc -l)
echo "lines=$lines" >> $GITHUB_OUTPUT
- name: Get all changed file names
id: file-names
run: |
lines="$(git diff HEAD~1 --name-only)"
echo "Changed files:"
echo "$lines"
totalcnt="$(echo "$lines" | wc -l)"
echo "totalcount=$totalcnt" >> $GITHUB_OUTPUT
#
cnt="$(echo "$lines" | grep -v '^package-lock.json$' | grep -v '^composer.lock$' | grep -v '^\.github/workflows/' | wc -l)"
echo "num=$cnt" >> $GITHUB_OUTPUT
#
echo "That are $totalcnt changed files. After reducing the number there are $cnt files left."
- name: Error/warn if the number of diff lines is zero
run: |
if [ ${{ steps.file-names.outputs.num }} -gt 0 ]; then
echo "::error file=CHANGELOG.md::There was no change in the changelog detected. Please fill in a valid entry into that file."
exit 1
else
echo "::warning file=CHANGELOG.md::There was no change in the changelog detected. There are in total ${{ steps.file-names.outputs.totalcount }} changed files."
fi
if: ${{ steps.diff.outputs.lines == 0 }}
todo-checker:
name: Check for added todo messages
runs-on: ubuntu-22.04
steps:
- name: Git version output
run: git version
- name: Manual checkout of the app (base repo)
run: |
REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
BRANCH="${GITHUB_REF/#refs\/heads\//}"
git clone --filter=tree:0 "$REPO" .
- name: Manual checkout of the app (PR head)
env:
URL: ${{ github.event.pull_request.head.repo.html_url }}
HEAD_REF: ${{ github.head_ref }}
run: |
git remote add head "$URL"
git fetch head --filter=tree:0
git checkout -b head-branch head/$HEAD_REF
- name: Status of current git workspace
run: |
git branch
git status
- name: Check for open TODO annotations in source code
uses: ./.github/actions/check-todo
appinfo:
name: Check for matching app info file
runs-on: ubuntu-22.04
steps:
- name: Checkout of the app
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install jq
pip install yq
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Perform the test
env:
MAIN_FILE: appinfo/info.xml
DIST_FILE: .github/actions/deploy/appinfo/info.xml.dist
run: |
echo "Normalize the actual appinfo file"
xq -x 'del(.info.version)' "$MAIN_FILE" > /tmp/main-info.xml
xq -x 'del(.info.version)' "$DIST_FILE" > /tmp/dist-info.xml
echo '::group::Debug output'
tail -n 100 /tmp/main-info.xml /tmp/dist-info.xml
echo '::endgroup::'
if ! diff -q /tmp/main-info.xml /tmp/dist-info.xml > /dev/null; then
echo '::error::The app info file differs from the dist file. Please check manually!'
exit 1
fi
- name: Download schema
run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd
- name: Lint info.xml
uses: ChristophWurst/xmllint-action@v1
with:
xml-file: ./appinfo/info.xml
xml-schema-file: ./info.xsd
package-lint:
name: Make sure the package.json is well-formatted
runs-on: ubuntu-22.04
steps:
- name: Checkout of the app
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get the date
id: date
run: echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
- name: Cache NPM cache
uses: actions/[email protected]
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-node-${{ steps.date.outputs.date }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.date.outputs.date }}-
${{ runner.os }}-node-
- name: Install NPM modules
run: npm ci
- name: Perform the test
run: |
npm run package-lint
if [ $(git diff --name-only package.json | wc -l) -gt 0 ]; then
echo '::error file=package.json::The package.json file is not validly formatted.'
echo '::notice::It is suggested to run `npm run package-lint` and commit locally.'
exit 1
fi
fixup-check:
name: Block fixup and squash commits
runs-on: ubuntu-latest
steps:
- name: Run check
uses: xt0rted/block-autosquash-commits-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}