|
1 | 1 | #!/bin/bash
|
2 |
| -##===----------------------------------------------------------------------===## |
3 |
| -## |
4 |
| -## This source file is part of the VS Code Swift open source project |
5 |
| -## |
6 |
| -## Copyright (c) 2021 the VS Code Swift project authors |
7 |
| -## Licensed under Apache License v2.0 |
8 |
| -## |
9 |
| -## See LICENSE.txt for license information |
10 |
| -## See CONTRIBUTORS.txt for the list of VS Code Swift project authors |
11 |
| -## |
12 |
| -## SPDX-License-Identifier: Apache-2.0 |
13 |
| -## |
14 |
| -##===----------------------------------------------------------------------===## |
15 | 2 |
|
16 |
| -set -eu |
17 |
| -here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
18 |
| - |
19 |
| -function replace_acceptable_years() { |
20 |
| - # this needs to replace all acceptable forms with 'YEARS' |
21 |
| - sed -e 's/20[12][0123456789]-20[12][0123456789]/YEARS/' -e 's/20[12][0123456789]/YEARS/' |
22 |
| -} |
23 |
| - |
24 |
| -printf "=> Checking for unacceptable language... " |
25 |
| -# This greps for unacceptable terminology. The square bracket[s] are so that |
26 |
| -# "git grep" doesn't find the lines that greps :). |
27 |
| -unacceptable_terms=( |
28 |
| - -e blacklis[t] |
29 |
| - -e whitelis[t] |
30 |
| - -e slav[e] |
31 |
| - -e sanit[y] |
32 |
| -) |
33 |
| - |
34 |
| -# We have to exclude the code of conduct as it gives examples of unacceptable |
35 |
| -# language. |
36 |
| -if git grep --color=never -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md" > /dev/null; then |
37 |
| - printf "\033[0;31mUnacceptable language found.\033[0m\n" |
38 |
| - git grep -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md" |
39 |
| - exit 1 |
40 |
| -fi |
41 |
| -printf "\033[0;32mokay.\033[0m\n" |
42 |
| - |
43 |
| -printf "=> Checking license headers... " |
44 |
| -tmp=$(mktemp /tmp/.vscode-swift-soundness_XXXXXX) |
45 |
| - |
46 |
| -for language in typescript-or-javascript bash; do |
47 |
| - declare -a matching_files |
48 |
| - matching_files=( -name '*' ) |
49 |
| - case "$language" in |
50 |
| - typescript-or-javascript) |
51 |
| - matching_files=( -name '*.js' -o -name '*.ts' ) |
52 |
| - cat > "$tmp" <<"EOF" |
53 |
| -//===----------------------------------------------------------------------===// |
54 |
| -// |
55 |
| -// This source file is part of the VS Code Swift open source project |
56 |
| -// |
57 |
| -// Copyright (c) YEARS the VS Code Swift project authors |
58 |
| -// Licensed under Apache License v2.0 |
59 |
| -// |
60 |
| -// See LICENSE.txt for license information |
61 |
| -// See CONTRIBUTORS.txt for the list of VS Code Swift project authors |
62 |
| -// |
63 |
| -// SPDX-License-Identifier: Apache-2.0 |
64 |
| -// |
65 |
| -//===----------------------------------------------------------------------===// |
66 |
| -EOF |
67 |
| - ;; |
68 |
| - bash) |
69 |
| - matching_files=( -name '*.sh' ) |
70 |
| - cat > "$tmp" <<"EOF" |
71 |
| -#!/bin/bash |
72 |
| -##===----------------------------------------------------------------------===## |
73 |
| -## |
74 |
| -## This source file is part of the VS Code Swift open source project |
75 |
| -## |
76 |
| -## Copyright (c) YEARS the VS Code Swift project authors |
77 |
| -## Licensed under Apache License v2.0 |
78 |
| -## |
79 |
| -## See LICENSE.txt for license information |
80 |
| -## See CONTRIBUTORS.txt for the list of VS Code Swift project authors |
81 |
| -## |
82 |
| -## SPDX-License-Identifier: Apache-2.0 |
83 |
| -## |
84 |
| -##===----------------------------------------------------------------------===## |
85 |
| -EOF |
86 |
| - ;; |
87 |
| - *) |
88 |
| - echo >&2 "ERROR: unknown language '$language'" |
89 |
| - ;; |
90 |
| - esac |
91 |
| - |
92 |
| - expected_lines=$(cat "$tmp" | wc -l) |
93 |
| - expected_sha=$(cat "$tmp" | shasum) |
94 |
| - |
95 |
| - ( |
96 |
| - cd "$here/.." |
97 |
| - { |
98 |
| - find . \ |
99 |
| - \( \! -path './.build/*' -a \ |
100 |
| - \( \! -path './node_modules/*' -a \ |
101 |
| - \( \! -path './out/*' -a \ |
102 |
| - \( \! -path './.vscode-test/*' -a \ |
103 |
| - \( \! -path './docker/*' -a \ |
104 |
| - \( \! -path './dist/*' -a \ |
105 |
| - \( \! -path './assets/*' -a \ |
106 |
| - \( \! -path './coverage/*' -a \ |
107 |
| - \( "${matching_files[@]}" \) \ |
108 |
| - \) \) \) \) \) \) \) \) |
109 |
| - |
110 |
| - if [[ "$language" = bash ]]; then |
111 |
| - # add everything with a shell shebang too |
112 |
| - git grep --full-name -l '#!/bin/bash' |
113 |
| - git grep --full-name -l '#!/bin/sh' |
114 |
| - fi |
115 |
| - } | while read line; do |
116 |
| - if [[ "$(cat "$line" | replace_acceptable_years | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then |
117 |
| - printf "\033[0;31mmissing headers in file '$line'!\033[0m\n" |
118 |
| - diff -u <(cat "$line" | replace_acceptable_years | head -n $expected_lines) "$tmp" |
119 |
| - exit 1 |
120 |
| - fi |
121 |
| - done |
122 |
| - printf "\033[0;32mokay.\033[0m\n" |
123 |
| - ) |
124 |
| -done |
125 |
| - |
126 |
| -rm "$tmp" |
127 |
| - |
128 |
| -printf "=> Checking for broken links in documentation... " |
129 |
| -find . -name node_modules -prune -o -name \*.md -print0 | xargs -0 -n1 npx markdown-link-check |
130 |
| -printf "\033[0;32mokay.\033[0m\n" |
| 3 | +# This file is supplanted by the GitHub Actions enabled in |
| 4 | +# https://github.com/swiftlang/vscode-swift/pull/1159, |
| 5 | +# remove this file once that has been merged. |
| 6 | +exit 0 |
0 commit comments