-
-
Notifications
You must be signed in to change notification settings - Fork 11
95 lines (90 loc) · 3.74 KB
/
check-extensions.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
name: Check Extensions
on:
workflow_dispatch:
pull_request:
permissions:
pull-requests: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUMBER: ${{ github.event.pull_request.number }}
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
check-duplicate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for duplicates
shell: bash
run: |
error=false
add_extension=$(gh pr view "${NUMBER}" --json files --jq '.files[] | select(.path == "extensions/quarto-extensions.csv")')
if [[ -n "${add_extension}" ]]; then
echo "extensions/quarto-extensions.csv is being added"
FILE='extensions/quarto-extensions.csv'
COLUMN=2
duplicates=$(awk -F, -v col=$COLUMN '{print $col}' $FILE | sort | uniq -d)
if [[ -n "$duplicates" ]]; then
while read -r duplicate; do
grep -n "$duplicate" $FILE | tail -n +2 | while read -r line ; do
lineNumber=$(echo $line | cut -d: -f1)
echo "::error file=$FILE,line=$lineNumber,endLine=$lineNumber,title=Duplicate Entry::Duplicate value '$duplicate' found"
error=true
done
done <<< "$duplicates"
fi
if [[ "${error}" = true ]]; then
exit 1
fi
fi
check-topics:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for topics
shell: bash
run: |
error=false
add_extension=$(gh pr view "${NUMBER}" --json files --jq '.files[] | select(.path == "extensions/quarto-extensions.csv")')
if [[ -n "${add_extension}" ]]; then
gh pr diff ${NUMBER} --patch | awk '/\+\+\+ b\/extensions\/quarto-extensions\.csv/{flag=1; next} flag && /^\+/' | sed 's/^+//' > diff.patch
if [[ -s diff.patch ]]; then
while IFS=, read -r repo; do
repo_topics=$(gh repo view --json repositoryTopics "${repo}" --jq ".repositoryTopics")
if [[ -z "${repo_topics}" ]]; then
lineNumber=$(grep -n "${repo}" extensions/quarto-extensions.csv | cut -d: -f1)
echo "::error file=extensions/quarto-extensions.csv,line=$lineNumber,endLine=$lineNumber::Repository '${repo}' is missing topics!"
error=true
fi
done < diff.patch
fi
if [[ "${error}" = true ]]; then
exit 1
fi
fi
check-description:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for description
shell: bash
run: |
error=false
add_extension=$(gh pr view "${NUMBER}" --json files --jq '.files[] | select(.path == "extensions/quarto-extensions.csv")')
if [[ -n "${add_extension}" ]]; then
gh pr diff ${NUMBER} --patch | awk '/\+\+\+ b\/extensions\/quarto-extensions\.csv/{flag=1; next} flag && /^\+/' | sed 's/^+//' > diff.patch
if [[ -s diff.patch ]]; then
while IFS=, read -r repo; do
repo_description=$(gh repo view --json description "${repo}" --jq ".description")
if [[ -z "${repo_description}" ]]; then
lineNumber=$(grep -n "${repo}" extensions/quarto-extensions.csv | cut -d: -f1)
echo "::error file=extensions/quarto-extensions.csv,line=$lineNumber,endLine=$lineNumber::Repository '${repo}' is missing description!"
error=true
fi
done < diff.patch
fi
if [[ "${error}" = true ]]; then
exit 1
fi
fi