-
Notifications
You must be signed in to change notification settings - Fork 95
215 lines (189 loc) · 9.32 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
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: |
filename_prefix=".changelog/current/${{ github.event.number }}-"
git diff HEAD~1 --name-only -- $filename_prefix* > /tmp/changed-cl-files
echo "Possibly matching changelog files:"
cat /tmp/changed-cl-files
num_lines=$(wc -l /tmp/changed-cl-files)
if [ "$num_lines" -gt 1 ]
then
{
echo "### Too many changelog files match"
echo ""
echo "There are too many changelog entries found for the PR #${{ github.event.number }} found."
echo "There must be only one entry."
echo ""
echo "The following entries were found:"
echo ""
sed 's@^@- @' /tmp/changed-cl-files
echo ""
echo "Please fix this manually."
} > $GITHUB_STEP_SUMMARY
exit 1
fi
echo "num_lines=$(wc -l /tmp/changed-cl-files)" >> $GITHUB_OUTPUT
- name: Get all changed file names
id: file-names
run: |
git diff HEAD~1 --name-only > /tmp/changed-files-in-pr
echo "Changed files:"
cat /tmp/changed-files-in-pr
totalcnt="$(cat /tmp/changed-files-in-pr | wc -l)"
echo "totalcount=$totalcnt" >> $GITHUB_OUTPUT
#
cat /tmp/changed-files-in-pr | grep -v '^package-lock.json$' | grep -v '^composer.lock$' | grep -v '^\.github/workflows/' | grep -v '^docs/Gemfile.lock' > /tmp/relevant-files-in-pr
cnt="$(cat /tmp/relevant-files-in-pr | 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 no changelog entry was found
run: |
if [ ${{ steps.file-names.outputs.num }} -gt 0 ]; then
echo "::error::There was no change in the changelog detected. Please fill in a valid entry into that file."
{
echo "### No changelog was found"
echo ""
echo "You have in total ${{ steps.file-names.outputs.totalcount }} file(s) changed in the pull request."
echo "From these, there are ${{ steps.file-names.outputs.num }} file(s) which make a changelog entry mandatory."
echo "These files are:"
echo ""
sed 's@^@- @' /tmp/relevant-files-in-pr
echo ""
echo "Please provide a file `.changelog/current/${{ github.event.number }}-foo` where you can set the text `foo` as you like."
echo "A good suggestion is to summarize the PR's content and to replace any non-chars with dashes."
echo "An example file name could be `.changelog/current/1234-update-nc-release-script`.
} > $GITHUB_STEP_SUMMARY
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."
{
echo "### No changelog was needed"
echo ""
echo "No changelog entry was found so far."
echo "This is okay, as no files have been modified that would require a changelog entry."
echo "You might consider if adding a changelog entry would be benefical as significant changes have been made."
} > $GITHUB_STEP_SUMMARY
fi
if: ${{ steps.diff.outputs.num_lines == 0 }}
- name: Install Python package
run: apt-get update && apt-get install python3-venv
- name: Test creation of changelog
run: |
cd .helpers/changelog
virtualenv venv
source venv/bin/activate
pipenc sync
./create-changelog-prerelease.sh
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/cache@v4.0.2
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 }}